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


Cannot reproduce the error (and you are asked in the Posting Guide to include the code that creates the error rather than posting code that does not).

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 <- data.frame(x=x, a=1)  # creates another column in "a".
levels(xd$x) <- gsub("/", "-", levels(xd$x))
> xd
            x a
1  2000-01-01 1
2  2001-02-01 1
3  2000-03-01 1
4  2000-04-01 1
5  2000-05-01 1
6  2000-06-01 1
7  2000-07-01 1
8  2000-08-01 1
9  2000-09-01 1
10 2000-10-01 1

> sessionInfo()
R version 2.10.1 RC (2009-12-09 r50695)
x86_64-apple-darwin9.8.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines stats graphics grDevices utils datasets methods base

other attached packages:
[1] adapt_1.0-4 Hmisc_3.7-0 survival_2.35-7 mapdata_2.1-1 maps_2.1-0

loaded via a namespace (and not attached):
[1] cluster_1.12.1 grid_2.10.1    lattice_0.18-3 tools_2.10.1



--
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@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

______________________________________________
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