[R] Replace / with - in date

David Winsemius dwinsemius at comcast.net
Fri Apr 16 03:09:34 CEST 2010


On Apr 15, 2010, at 7:20 PM, prem_R wrote:

>
>> x <- c("2000/01/01",
> "2001
> / 
> 02 
> / 
> 01 
> ","2000 
> / 
> 03 
> / 
> 01 
> ","2000 
> / 
> 04 
> / 
> 01 
> ","2000 
> / 
> 05 
> /01","2000/06/01","2000/07/01","2000/08/01","2000/09/01","2000/10/01")
>> xd <- as.data.frame(x)
>> levels(xd$x) <- gsub("/", "-", levels(xd$x))
>> fix(xd)
>
> This works fine .but with one more variable say xsd in the data  
> frame i'm
> getting the following error
>
>
> Error in levels(sa$date1) <- gsub("/", "-", levels(sa$date)) :
>  attempt to set an attribute on NULL

Are there two columns date1 and  date in "sa"? Have you made a typo?
>
> -- 
> View this message in context: http://n4.nabble.com/Replace-with-in-date-tp1911391p1934428.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list