Re: [R] R equivalent of linux "cut", "paste", and "grep" ?

From: Greg Snow <Greg.Snow_at_imail.org>
Date: Thu, 14 Feb 2008 09:37:14 -0700

Depending on what your final goal is, there may be a better approach, but to do as you state below, here is one set of options:

  1. use read.csv (or read.table) and use the colClasses argument to specify keeping only column 5
  2. use cbind to bind column 5 (now a data.frame) to another data.frame (possibly read in using read.csv), this assumes that the row order matches, merge is a possibility if they don't match.
  3. use the subset command to select the rows, use the %in% operator to compare col 5 to your list of desired values.

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow_at_imail.org
(801) 408-8111
 
 


> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces@r-project.org] On Behalf Of Ng Stanley
> Sent: Thursday, February 14, 2008 1:03 AM
> To: r-help
> Subject: [R] R equivalent of linux "cut", "paste", and "grep" ?
>
> Hi,
>
> What functions should I use in order to perform the following steps:
>
> 1) Load a particular column (e.g., column 5) from a csv file
> 2) Append the column 5 to another csv file
> 3) select those rows that match specific keywords in column 5
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
______________________________________________ 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 Thu 14 Feb 2008 - 16:40:06 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 Thu 14 Feb 2008 - 17:30:14 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