Quantcast

ROWNAMES error message

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

ROWNAMES error message

mark salsburg
I am getting an error message, which I do not know the source to.

I have a matrix SAMPLES that has preexisting rownames that I would like to
change.
GENE_NAMES contains these rownames.


> rownames(SAMPLES) = GENE_NAMES
Error in "dimnames<-.data.frame"(`*tmp*`, value = list(list(V1 = c(3843,  :
        invalid 'dimnames' given for data frame
> dim(SAMPLES)
[1] 12626    20
> dim(GENE_NAMES)
[1] 12626     1
> is.data.frame(SAMPLES)
[1] TRUE
> is.data.frame(GENE_NAMES)
[1] TRUE

I have tried converting GENE_NAMES to a factor, R will not allow me because
its says "x must be atomic"

ANY IDEAS??

Thank you

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ROWNAMES error message

Liaw, Andy
The object to be assigned as rownames need to be a vector, not a data frame.
Try something like:

rownames(SAMPLES) <- GENE_NAMES[[1]]

Also, don't confuse a data frame from a matrix:  They are very different.

Andy

From: mark salsburg

>
> I am getting an error message, which I do not know the source to.
>
> I have a matrix SAMPLES that has preexisting rownames that I
> would like to change. GENE_NAMES contains these rownames.
>
>
> > rownames(SAMPLES) = GENE_NAMES
> Error in "dimnames<-.data.frame"(`*tmp*`, value =
> list(list(V1 = c(3843,  :
>         invalid 'dimnames' given for data frame
> > dim(SAMPLES)
> [1] 12626    20
> > dim(GENE_NAMES)
> [1] 12626     1
> > is.data.frame(SAMPLES)
> [1] TRUE
> > is.data.frame(GENE_NAMES)
> [1] TRUE
>
> I have tried converting GENE_NAMES to a factor, R will not
> allow me because its says "x must be atomic"
>
> ANY IDEAS??
>
> Thank you
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ROWNAMES error message

Marc Schwartz (via MN)
In reply to this post by mark salsburg
On Tue, 2006-03-21 at 14:26 -0500, mark salsburg wrote:
> I am getting an error message, which I do not know the source to.
>
> I have a matrix SAMPLES that has preexisting rownames that I would like to
> change.

SAMPLES is not a matrix, it is a data frame, as your output shows below.

> GENE_NAMES contains these rownames.
>
>
> > rownames(SAMPLES) = GENE_NAMES
> Error in "dimnames<-.data.frame"(`*tmp*`, value = list(list(V1 = c(3843,  :
>         invalid 'dimnames' given for data frame
> > dim(SAMPLES)
> [1] 12626    20
> > dim(GENE_NAMES)
> [1] 12626     1
> > is.data.frame(SAMPLES)
> [1] TRUE
> > is.data.frame(GENE_NAMES)
> [1] TRUE
>
> I have tried converting GENE_NAMES to a factor, R will not allow me because
> its says "x must be atomic"
>
> ANY IDEAS??

GENE_NAMES is presumably a data frame with a single column. You need to
properly access the single column by name or index and use that as the
RHS of the assignment. So something like one the following should work:

  rownames(SAMPLES) <- GENE_NAMES$V1

or

  rownames(SAMPLES) <- GENE_NAMES[, 1]

Use:

  str(GENE_NAMES)

which will display the structure of GENE_NAMES.

'atomic' means that the data in question is one of the primary data
types defined for R. See ?is.atomic for more information.

HTH,

Marc Schwartz

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: ROWNAMES error message

Sean Davis
In reply to this post by mark salsburg



On 3/21/06 2:26 PM, "mark salsburg" <[hidden email]> wrote:

> I am getting an error message, which I do not know the source to.
>
> I have a matrix SAMPLES that has preexisting rownames that I would like to
> change.
> GENE_NAMES contains these rownames.
>
>
>> rownames(SAMPLES) = GENE_NAMES
> Error in "dimnames<-.data.frame"(`*tmp*`, value = list(list(V1 = c(3843,  :
>         invalid 'dimnames' given for data frame
>> dim(SAMPLES)
> [1] 12626    20
>> dim(GENE_NAMES)
> [1] 12626     1
>> is.data.frame(SAMPLES)
> [1] TRUE
>> is.data.frame(GENE_NAMES)
> [1] TRUE
>
> I have tried converting GENE_NAMES to a factor, R will not allow me because
> its says "x must be atomic"
>
> ANY IDEAS??

 rownames() is looking for a vector.  You are asking it to assign a
data.frame.  Try

 rownames(SAMPLES) <- GENE_NAMES[,1]

Sean

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...