I have created a data frame and I want to convert it into a matrix and I can only convert the first column but I can not convert the logical column as true and false instead of it I am getting the 1 and 0 which I know it is correct but I want True and False ?

x<-data.frame(foo=1:4,bar=c(T,T,F,F))

data.matrix(x)

foo bar

[1,] 1 1

[2,] 2 1

[3,] 3 0

[4,] 4 0

# How to use data.matrix in R

**sid100158**#1

**anon**#2

@sid100158 Please remember that a matrix object can contain only objects of the same atomic type: itâ€™s a generalisation of a vector; or to put in another, a vector is a special case of a matrix.