Hi 'What is your name?'

When you read the data into R the first column was interpreted as a factor 
where the levels are the timestamps. If you used read.table() there is the 
stringsAsFactor you can set to FALSE so that the first column will be read in 
as strings instead of a factor.

However you can now do this.

antdist$ts <- as.character(antdist$ts)

antdist$ts <- as.POSIXct(strptime(antdist$ts, format = "%m/%d/%Y %H:%M:%S"))


See ?factor, ?as.POSIXct, ?strptime


Yours sincerely / Med venlig hilsen


Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling

Technology & Service Solutions
T +45 9730 5135
M +45 2547 6050
fr...@vestas.com
http://www.vestas.com

Company reg. name: Vestas Wind Systems A/S
This e-mail is subject to our e-mail disclaimer statement.
Please refer to www.vestas.com/legal/notice
If you have received this e-mail in error please contact the sender. 

> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of elle
> Sent: 1. april 2014 20:35
> To: r-help@r-project.org
> Subject: [R] MULTIPLE LEVELS for a SINGLE VALUE in a dataframe, how do I
> remove these?
> 
> I have a series of dates and times in one column.  They are all in the format
> "%m/%d/%Y %H:%M:%S"; however, they are character values.
> 
> I have a number of problems:
> 1) if I use antdist$ts[1] to just examine the FIRST value of the timestamp
> (ts) column, it shows that there are 144873 Levels, and it should only have
> 1 Level with the first value of "6/1/2013 08:07:39"; how do I delete the
> remaining levels?
> 2) I need to change this column to a factor, so that I can use it in
> functions and graph it, etc.  It's useless in this format.  I think that
> once I can remove the levels, I can use as.Date or as.POSIXct to do this,
> but I need to figure out what's happening in the first part of the question.
> 
> Here's the R code for just looking at the first value of the timestamp
> column:
> > antdist$ts[1]
> [1] 6/1/2013 08:07:39
> 144873 Levels: 6/1/2013 08:07:39 6/1/2013 08:07:41 6/1/2013 08:07:43
> 6/1/2013 08:07:45 ... 8/2/2013 11:47:51
> 
> Here's a photo of what the first few rows of the timestamp column look like
> using View(antdist):
> <http://r.789695.n4.nabble.com/file/n4687977/Capture.jpg>
> 
> Thank you, thank you, thank you for your help!
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/MULTIPLE-
> LEVELS-for-a-SINGLE-VALUE-in-a-dataframe-how-do-I-remove-these-
> tp4687977.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to