Hi, Excuse me for this simple question. How to convert as.data.frame to as.character? ?data.frame > L3 <- LETTERS[1:3] > L10 <- LETTERS[1:10] > d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, 10, repl=TRUE)) > d x y fac 1 XYZ A A 2 XYZ B A 3 XYZ C A 4 XYZ D A 5 XYZ E B 6 XYZ F C 7 XYZ G A 8 XYZ H C 9 XYZ I B 10 XYZ J A > str(d) `data.frame': 10 obs. of 3 variables: $ x : Factor w/ 1 level "XYZ": 1 1 1 1 1 1 1 1 1 1 $ y : Factor w/ 10 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 $ fac: Factor w/ 3 levels "A","B","C": 1 1 1 1 2 3 1 3 2 1 > d[3,] x y fac 3 XYZ C A > > as.character(d[3,]) [1] "1" "3" "1" > I think as.character the result something like [3] "XYZ" "C" "A" I don't know how to convert it. Any help gratefully received. Thank you very much in advance. Kindly regards, Muhammad Subianto
Is this what you want?> d[] <- lapply(d, as.character) > str(d)`data.frame': 10 obs. of 3 variables: $ x : chr "XYZ" "XYZ" "XYZ" "XYZ" ... $ y : chr "A" "B" "C" "D" ... $ fac: chr "B" "A" "C" "B" ... Andy> From: Muhammad Subianto > > Hi, > Excuse me for this simple question. > How to convert as.data.frame to as.character? > > ?data.frame > > > L3 <- LETTERS[1:3] > > L10 <- LETTERS[1:10] > > d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, > 10, repl=TRUE)) > > d > x y fac > 1 XYZ A A > 2 XYZ B A > 3 XYZ C A > 4 XYZ D A > 5 XYZ E B > 6 XYZ F C > 7 XYZ G A > 8 XYZ H C > 9 XYZ I B > 10 XYZ J A > > str(d) > `data.frame': 10 obs. of 3 variables: > $ x : Factor w/ 1 level "XYZ": 1 1 1 1 1 1 1 1 1 1 > $ y : Factor w/ 10 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 > $ fac: Factor w/ 3 levels "A","B","C": 1 1 1 1 2 3 1 3 2 1 > > d[3,] > x y fac > 3 XYZ C A > > > > as.character(d[3,]) > [1] "1" "3" "1" > > > > I think as.character the result something like > [3] "XYZ" "C" "A" > > I don't know how to convert it. > Any help gratefully received. > Thank you very much in advance. > Kindly regards, > Muhammad Subianto > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html > > >
On 6/10/05, Muhammad Subianto <subianto at gmail.com> wrote:> Hi, > Excuse me for this simple question. > How to convert as.data.frame to as.character? > > ?data.frame > > > L3 <- LETTERS[1:3] > > L10 <- LETTERS[1:10] > > d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, 10, repl=TRUE))d[] <- as.matrix(d)
Dear all, Thank you very much for your help. I would like to thank Andy Liaw and Gabor Grothendieck for their fast help. Regards, Muhammad Subianto On this day 6/10/2005 2:30 PM, Liaw, Andy wrote: > Is this what you want? > > >>d[] <- lapply(d, as.character) >>str(d) > > `data.frame': 10 obs. of 3 variables: > $ x : chr "XYZ" "XYZ" "XYZ" "XYZ" ... > $ y : chr "A" "B" "C" "D" ... > $ fac: chr "B" "A" "C" "B" ... > > Andy On this day 6/10/2005 2:35 PM, Gabor Grothendieck wrote: > On 6/10/05, Muhammad Subianto <subianto at gmail.com> wrote: > >>Hi, >>Excuse me for this simple question. >>How to convert as.data.frame to as.character? >> >> ?data.frame >> >> > L3 <- LETTERS[1:3] >> > L10 <- LETTERS[1:10] >> > d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, 10, repl=TRUE)) > > > > d[] <- as.matrix(d) > On this day 6/10/2005 2:23 PM, Muhammad Subianto wrote:> Hi, > Excuse me for this simple question. > How to convert as.data.frame to as.character? > > ?data.frame > > > L3 <- LETTERS[1:3] > > L10 <- LETTERS[1:10] > > d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, 10, repl=TRUE)) > > d > x y fac > 1 XYZ A A > 2 XYZ B A > 3 XYZ C A > 4 XYZ D A > 5 XYZ E B > 6 XYZ F C > 7 XYZ G A > 8 XYZ H C > 9 XYZ I B > 10 XYZ J A > > str(d) > `data.frame': 10 obs. of 3 variables: > $ x : Factor w/ 1 level "XYZ": 1 1 1 1 1 1 1 1 1 1 > $ y : Factor w/ 10 levels "A","B","C","D",..: 1 2 3 4 5 6 7 8 9 10 > $ fac: Factor w/ 3 levels "A","B","C": 1 1 1 1 2 3 1 3 2 1 > > d[3,] > x y fac > 3 XYZ C A > > > > as.character(d[3,]) > [1] "1" "3" "1" > > > > I think as.character the result something like > [3] "XYZ" "C" "A" > > I don't know how to convert it. > Any help gratefully received. > Thank you very much in advance. > Kindly regards, > Muhammad Subianto > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! R-project.org/posting-guide.html >
How can one discover or list all available built-in objects? On Jun 10, 2005, at 7:23 AM, Muhammad Subianto wrote:>> L3 <- LETTERS[1:3] >> L10 <- LETTERS[1:10]LETTERS is apparently a built-in character vector. ls() and objects () only lists the ones I've created. Is there a function that lists all available built-in objects? For example, "pi" is another built-in, but "e" is not. A means to list them would be nice. Regards, - Robert