Re: [R] Getting only label column of a data frame

From: jim holtman <jholtman_at_gmail.com>
Date: Sun, 22 Jun 2008 22:21:21 -0400

Is this what you want:

> x

        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

> x[,1]

[1] 14.3 10.2 15.2 59.5
> x[,1,drop=FALSE]

        V1

11145 14.3
3545  10.2
8951  15.2
11097 59.5

>

You probably need the 'drop=FALSE'; see ?'['

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?

______________________________________________
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.
Received on Mon 23 Jun 2008 - 02:23:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 Jun 2008 - 02:31:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive