[R] glm help
Peter Langfelder
peter.langfelder at gmail.com
Fri Aug 21 07:47:44 CEST 2015
On Thu, Aug 20, 2015 at 10:04 PM, Bert Gunter <bgunter.4567 at 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
More information about the R-help
mailing list