An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120720/9a7b05bd/attachment.pl>
convert date to a factor
5 messages · R. Michael Weylandt, Yolande Tra, arun
d$date <- factor(d$date) Best, Michael
On Fri, Jul 20, 2012 at 9:44 AM, Yolande Tra <yolande.tra at gmail.com> wrote:
Hello, I would like to convert date as a factor to represent time in a repeated measure situation in the following code. How would I do that?
d <- read.csv(file.path(dataDir,"data.csv"), as.is=T,stringsAsFactors =
FALSE)
d[1:2,]
id date a b c y
1 1 8/6/2008 Red 15 B 22
2 1 8/6/2008 Green 15 B 22
Thank you,
Y
[[alternative HTML version deleted]]
______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120720/47238d9b/attachment.pl>
Hi, Try this: dat1<-read.table(text=" ?????? id??? date??????? a??????? b????? c??????? y 1????? 1 8/6/2008??? Red??? 15??? B????????? 22 2????? 1 8/6/2008? Green? 15??? B????????? 22 ",sep="",header=TRUE) ?dat1$date<-with(dat1,as.factor(date)) ?dat1 ? id???? date???? a? b c? y 1? 1 8/6/2008?? Red 15 B 22 2? 1 8/6/2008 Green 15 B 22 ?is.factor(dat1$date) [1] TRUE A.K. ----- Original Message ----- From: Yolande Tra <yolande.tra at gmail.com> To: r-help at r-project.org Cc: Sent: Friday, July 20, 2012 10:44 AM Subject: [R] convert date to a factor Hello, I would like to convert date as a factor to represent time in a repeated measure situation in the following code. How would I do that?
? d <- read.csv(file.path(dataDir,"data.csv"), as.is=T,stringsAsFactors =
FALSE)
d[1:2,]
? ? ? ? id? ? date? ? ? ? a? ? ? ? b? ? ? c? ? ? ? y 1? ? ? 1 8/6/2008? ? Red? ? 15? ? B? ? ? ? ? 22 2? ? ? 1 8/6/2008? Green? 15? ? B? ? ? ? ? 22 Thank you, Y ??? [[alternative HTML version deleted]] ______________________________________________ R-help at 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120720/41542a54/attachment.pl>