On Thu, Aug 20, 2015 at 10:04 PM, Bert Gunter <bgunter.4...@gmail.com> wrote:
>> I noticed you made two data-frames, ‘my4s' and ‘my4S'. The `my4S` was built >> with `cbind` which would create a matrix (probably a character matrix) >> rather than a data frame. > > False. There is a data.frame method for cbind that returns a data > frame. Don't know the specifics here, though. > True, but does not apply here, i.e., David is correct. cbind will return a data frame if the first argument is a data frame. In the OP case, the first argument was a vector and hence cbind gives a matrix, of mode "character" if any of the inputs were character. Here's a short demo: > a = data.frame(a1 = 1:10) # First argument a data frame, so the results is also a data frame : > class(cbind(a, b = 11:20)) [1] "data.frame" # First argument is a vector, so the result is a matrix: > class(cbind(a$a1, b = 11:20)) [1] "matrix" > mode(cbind(a$a1, b = 11:20)) [1] "numeric" > mode(cbind(a$a1, b = letters[11:20])) [1] "character" Peter ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.