Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6783217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:50:15+00:00 2026-05-26T16:50:15+00:00

I am reading an apache logfile using read.table and am wondering if it’s somehow

  • 0

I am reading an apache logfile using read.table and am wondering if it’s somehow possible to apply a function (i.e. strptime ) while the data are being imported, instead of post-processing it.

More details as requested:
The column containing the date has the format:

[10/Nov/2011:06:25:14

I can successfully parse it using:

strptime(red[1,4],format="[%d/%b/%Y:%H:%M:%S")

or

as.POSIXct(strptime(red[1,4],format="[%d/%b/%Y:%H:%M:%S"))

but

as.POSIXct(red[1,4],format="[%d/%b/%Y:%H:%M:%S")

fails. Hence I cannot use POSIXct in colClasses AFAIK.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:50:16+00:00Added an answer on May 26, 2026 at 4:50 pm

    If there is an as. method you can use colClasses with that class. Since Date is a class and has a default format of YYYY-MM-DD, if your dates are in that format, you could just include Date in the colClasses vector. It is also possible to define new as.function‘s. As always, the more detail you supply about the problem, the better the answer.

     library(methods)
     setClass("logDate")
    #[1] "logDate"
     setAs("character", "logDate", function(from) 
                                  as.POSIXct(from, format="[%d/%b/%Y:%H:%M:%S"))
     DF <- read.table(text="[10/Nov/2011:06:25:14", header = FALSE,
                                colClasses = c("logDate"))
     str(DF)
    #'data.frame':  1 obs. of  1 variable:
    # $ V1: POSIXct, format: "2011-11-10 06:25:14"
    

    Should probably give Gabor Grothendieck some credit since he is the one who showed me how to do this 5 years ago:
    https://www.stat.math.ethz.ch/pipermail/r-help/2007-April/130912.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just reading abit about JMS and Apache ActiveMQ. And was wondering what
In my application build using apache camel (mavenized, spring dsl) , i am reading
I am reading an Excel file to populate a database table using Hibernate +
Reading through this question on multi-threaded javascript, I was wondering if there would be
Reading this article on nginx website, I'm interested in using X-Accel-Redirect header in the
We're using HTTPClient to implement a REST API. We're reading the server response using:
I'm reading a file in via apache.commons.FtpClient. This works fine 99.9% of the time
I'm reading XML data from the HttpServletRequest in my servlets doPost() and passing the
Reading through the documentation on Apache Tomcat, when I deploy a webapp it copies
I was reading somewhere that in order to use the org.apache.cassandra classes in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.