[R] remove quotes from matrix

Duncan Murdoch murdoch.duncan at gmail.com
Tue Sep 19 16:04:47 CEST 2017

On 19/09/2017 9:47 AM, greg holly wrote:
> Hi all;
> I have data at 734*22 dimensions with rows and columns names are
> non-numeric.When I convert this data into matrix then all values show up
> with quotes. Then when I use
> x1= noquotes(x) to remove the quotes from the matrix then non-numeric row
> names remain all other values in matrix disappear.
> Your help is greatly appreciated.

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]

both before and after converting x to a matrix.

Duncan Murdoch

More information about the R-help mailing list