[R] glm help

Bert Gunter bgunter.4567 at gmail.com
Fri Aug 21 16:32:22 CEST 2015


Inline.

-- Bert
Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Thu, Aug 20, 2015 at 10:47 PM, Peter Langfelder
<peter.langfelder at gmail.com> wrote:
> 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,

False again.

class(cbind(a=1:5,b=data.frame(a=letters[1:5],b=3:7)))

[1] "data.frame"

##First argument a vector, but data frame is returned. Please consult
?cbind -- especially the data frame section -- for details.

Again, I don't know the specifics here, and you and David may still
well be right for what the OP did. I am only trying to correct what
appear to me to be incorrect statements about the data.frame method of
cbind (or rbind). Apologies if I have misinterpreted.

Cheers,
Bert



> 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