[R] How to extract row values?

Peter Ehlers ehlers at ucalgary.ca
Thu Aug 20 18:08:09 CEST 2009


John Kane wrote:
> What you have is a one-dimensional vector.  
Is that true?

> 
> I think that you are up against an R default.  You are going to get some names no matter what you do.  You can always change them using the names() command, e.g.  names(xx) <- c("a","b", "c") to replace the v1 v2 v3
You could try
unname(unlist(dat[n, ]))

Peter Ehlers

> 
> --- On Thu, 8/20/09, Henrik Kallberg <Henrik.Kallberg at ki.se> wrote:
> 
>> From: Henrik Kallberg <Henrik.Kallberg at ki.se>
>> Subject: [R] How to extract row values?
>> To: r-help at r-project.org
>> Received: Thursday, August 20, 2009, 7:55 AM
>> Dear All!
>> I'm trying to extract one specific row from a data frame
>> without columnnames being included. I only want a
>> 1-dimensional vector that consists of the specific data on
>> this row. Here's an example:
>> existing data:
>> column names: v1v2v3
>> Row 1         
>>    ab cd ef
>> Row 2         
>>    gh ij kl
>> Row 3         
>>    mn op qr
>> This is what I want to extract:
>> ab cd ef 
>> I do not want: v1v2v3
>>                
>>      ab cd ef
>> Thank you in advance
>> Henrik
>>
>> -----Inline Attachment Follows-----
>>
>> ______________________________________________
>> R-help at r-project.org
>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained,
>> reproducible code.
>>
> 
> 
>       __________________________________________________________________
> Looking for the perfect gift? Give the gift of Flickr! 
> 
> http://www.flickr.com/gift/
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
>




More information about the R-help mailing list