Skip to content

Creating subset using selected columns

3 messages · suparna mitra, Rui Barradas, Rainer Schuermann

#
Hello,

You could try something like the following.
The example below assumes your data.frame is named 'dat'


cnums <- grep("Peak\\.Area", colnames(dat))
subdat <- dat[cnums]

See ?regexp for the regular expressions used by ?grep.

Hope this helps,

Rui Barradas

Em 16-06-2013 08:20, Suparna Mitra escreveu:
#
Supposed your data.frame is called x, try
x[ which( substr( colnames( x ), 1, 4 ) == "Peak" ) ]
On Sunday 16 June 2013 15:20:37 Suparna Mitra wrote: