Skip to content
Prev 19128 / 63421 Next

data.matrix returns mode logical for zero rows (PR#8496)

Full_Name: Jonathan Swinton
Version: 2.2.1
OS: Windows
Submission from: (NULL) (193.132.159.169)


#The first line of description for data.matrix says that it will
#	'Return the matrix obtained by converting all the variables in a
#    data frame to numeric mode and then binding them together as the
#     columns of a matrix.'

#However when called with a data.frame with zero rows, data.matrix returns a
matrix 
#of mode logical rather than numeric. This conflicts with the documentation
#and is not what seems sensible.

# One underlying reason for this is that when a zero-length column of a matrix
of mode logical is 
# asserted to be numeric the matrix is not actually cast to numeric. I wonder if
that too is a bug?
[1] "R version 2.2.1, 2005-12-20"
[1] "numeric"
[1] "numeric"
[1] "logical"
[1] "numeric"
[1] "logical"
[1] "logical"