Skip to content
Prev 371432 / 398513 Next

remove quotes from matrix

On 19/09/2017 9:47 AM, greg holly wrote:
Matrices in R can have only one type.  If you start with a dataframe and 
any columns contain character data, all entries will be converted to 
character, and the matrix will be displayed with quotes.

When you say all values disappear, it sounds as though you are 
displaying strings containing nothing (or just blanks).  Those will be 
displayed as "" normally, but if the matrix is marked to display without 
quotes, they are displayed as empty strings, so it will appear that 
nothing is displayed.

You can see the structure of the original data using the str() function, 
e.g. str(x) should display types for each column.

If this isn't enough to explain what's going on, please show us more 
detail.  For example, show us the result of

y <- x[1:5, 1:5]
dput(y)

both before and after converting x to a matrix.

Duncan Murdoch