Re: [R] Subsetting a data.frame degenerates at one column?

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Sat, 9 Feb 2008 16:03:32 -0200

Try this also:

input[targets]

On 08/02/2008, Allen S. Rout <asr_at_ufl.edu> wrote:
>
> Greetings.
>
> At the moment, I'm applying R to some AIX 'nmon' output, trying to get
> a handle on some disk performance metrics. In case anyone's
> interested:
>
> http://docs.osg.ufl.edu/tsm/pdf/
>
> some of them are more edifying than others. (ahem)
>
> I'm trying to develop a somewhat general framework for plotting these
> measures, in the hopes that it's of some use to people other than me.
> One obstacle I encounter is that, when I select one column out of a
> data.frame, the result is no longer a data.frame. So, say I've got,
> in data frame 'input'
>
> disk1 disk2 disk3 disk4
> T0000 0 1 0 4
> T0001 0 1 0 5
> T0002 0 1 0 5
> T0003 0 2 0 4
> T0004 0 2 0 3
> T0005 0 1 0 3
> T0006 0 0 0 3
>
> and somewhere I've noted a list
>
> targets <- c('disk2','disk3')
>
> I can say
>
> input[,targets]
> disk2 disk3
> T0000 1 0
> T0001 1 0
> T0002 1 0
> T0003 2 0
> T0004 2 0
> T0005 1 0
> T0006 0 0
>
> but if
>
> targets <- c('disk2')
> input[,targets]
> [1] 1 1 1 2 2 1 0
>
> Ick.
>
> I've been reading through the indexing and data.frame docs, and remain
> unsatisfied so far. Where is my thinking going wrong?
>
>
>
> - Allen S. Rout
>
> ______________________________________________
> 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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
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 Sat 09 Feb 2008 - 18:10:15 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 Sat 09 Feb 2008 - 19:30:12 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