[R] Getting only label column of a data frame

jim holtman jholtman at gmail.com
Mon Jun 23 04:22:54 CEST 2008


Wait.  The first column is really the rowname.  So you want this:

> row.names(x)
[1] "11145" "3545"  "8951"  "11097"


On Sun, Jun 22, 2008 at 10:16 PM, Gundala Viswanath <gundalav at gmail.com> wrote:
> Hi,
>
> How can I extract the label only from a given data frame.
>
> Fore example from this data frame.
>
>> print(dataf)
>          V1      V2      V3      V4      V5      V6      V7      V8      V9
> 11145    14.3    17.1    31.2    41.7    45.8    49.8    68.6    70.6    72.9
> 3545     10.2    15.6    20.9    23.2    31.4    31.7    36.2    48.4    51.9
> 8951     15.2    17.5    20.0    21.4    32.4    49.7    51.3    58.3    58.9
> 11097    59.5    65.9   117.5   118.0   118.9   122.5   126.3   156.5   157.0
>
> I want to get the label (first) column only:
>
> 11145
> 3545
> 8951
> 11097
>
> Is there a quick way to achieve that?
> I tried this but fail:
>
> mylable <- dataf[,1]
>
> Please advice.
>
> - Gundala Viswanath
> Jakarta - Indonesia
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list