[R] remove quotes from matrix
bgunter.4567 at gmail.com
Tue Sep 19 17:20:20 CEST 2017
Your claims are false -- or at least confused.
> d <- data.frame(a = I(letters[1:3]), b = 1:3)
## the I() is to prevent automatic conversion to factor
1 a 1
2 b 2
3 c 3
> dm <- as.matrix(d)
[1,] "a" "1"
[2,] "b" "2"
[3,] "c" "3"
 "a" "b"
## Note that there are no rownames, as d had none.
> dm <- noquote(dm)
[1,] a 1
[2,] b 2
[3,] c 3
We still need a reprex to resolve the confusion.
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Tue, Sep 19, 2017 at 7:49 AM, greg holly <mak.hholly at gmail.com> wrote:
> Hi Duncan and Bert;
> I do appreciate for your replies. I just figured out that after x1=
> noquotes(x) commend my 733*22 matrix returns into n*1 vector. Is there way
> to keep this as matrix with the dimension of 733*22?
> On Tue, Sep 19, 2017 at 10:04 AM, Duncan Murdoch <murdoch.duncan at gmail.com
> > 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
> >> 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]
> > dput(y)
> > both before and after converting x to a matrix.
> > Duncan Murdoch
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/
> and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
More information about the R-help