Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread Richard M. Heiberger
In addition to what the others have told you, it looks like you might be confusing matrices with data.frames. Please see ?data.frame I think what you are looking for is > b <- c('a','b','c') > c <- c("ee","tt","rr") > k <- cbind(a,b,c) > K <- data.frame(a, b, c) > K a b c 1 1 a ee 2 2 b tt 3

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread Jeff Newmiller
Hard to say, not sure what you want to do. But the columns are not denoted by [a], [b] or [c]. You should learn to use the str function to understand what various expressions really are, and return to the "Introduction to R" document that comes with the software. There is a distinct difference b

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread arun
Hi, Try:   k[,"a"] #[1] "1" "2" "3"  k[,"b"] #[1] "a" "b" "c"  k[,"c"] #[1] "ee" "tt" "rr" A.K. On Tuesday, October 22, 2013 11:37 PM, Vivek Singh wrote: Hi All, I have create a matrix using cbind() function as follows: > a=c(1,2,3) > b=c('a','b','c') > c=c("ee","tt","rr") > k=cbi

[R] cbind() function : Not able to display columns

2013-10-22 Thread Vivek Singh
Hi All, I have create a matrix using cbind() function as follows: > a=c(1,2,3) > b=c('a','b','c') > c=c("ee","tt","rr") > k=cbind(a,b,c) Problem: when we print the matrix k, > k a b c [1,] "1" "a" "ee" [2,] "2" "b" "tt" [3,] "3" "c" "rr" we can see that rows are represented

Re: [R] cbind function

2007-11-13 Thread Jens Oehlschlägel
And here is a second solution, that differs in what happens if the variables have differing lengths: > var1 <- 1:4 > var2 <- 1:3 > sapply(ls(patt="^var[0-9]"), get) $var1 [1] 1 2 3 4 $var2 [1] 1 2 3 > do.call("cbind", lapply(ls(patt="^var[0-9]"), get)) [,1] [,2] [1,]11 [2,]2

Re: [R] cbind function

2007-11-13 Thread Henrique Dallazuanna
Try this: sapply(ls(patt="^var[0-9]"), get) On 13/11/2007, livia <[EMAIL PROTECTED]> wrote: > > Hello everyone, > > I would like to use the "cbind" function to construct a dataset, combining > some variable I defined before. > The codes are something like > > var1 <- ... > var2 <- ... > var2 <- .

[R] cbind function

2007-11-13 Thread livia
Hello everyone, I would like to use the "cbind" function to construct a dataset, combining some variable I defined before. The codes are something like var1 <- ... var2 <- ... var2 <- ... ... data <- cbind(var1,var2,var3...) The problem is I would like some flexibity in the data, i.e. the numbe