[R] cbind in data.frame

From: Yuan Jian <jayuan2008_at_yahoo.com>
Date: Sun, 24 Aug 2008 22:56:43 -0700 (PDT)


hi,
when I used cbind to combine columns, some contents of columns has been replaced by number. in the script below, column should be aaa,bbb,ccc but I was given 1,2,3. but when I change the column to vector, it gave me correct contents. can you please tell me why?
 
> d<-read.table("aaa.txt")
> d
   V1  V2
1 aaa 123
2 bbb 345
3 ccc 986
> cbind(d[,1],d[,2])

     [,1] [,2]

[1,]    1  123
[2,]    2  345
[3,]    3  986

> cbind(as.vector(d[,1]),d[,2])

     [,1]  [,2]
[1,] "aaa" "123"
[2,] "bbb" "345"
[3,] "ccc" "986"

>
      
	[[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. Received on Mon 25 Aug 2008 - 06:02:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Aug 2008 - 07:34:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive