subset - Subsetting in R using OR condition with strings -
I have a data frame with 40 columns, the second column, the data in the [[2]] company name is the remaining row data Description of. However, the names of companies vary depending on the year (nothing behind 09 for data, 2010 for 2010)
I would like to be able to minimize those data, which That I can pull together in two years. Here's an example of what I'm trying to do ...
subset (data, data [2] == "company name 09" | "company name", drop = T)
Basically, I'm having difficulty using the subset function or operator.
However, I have tried other options:
subtitle (data, data [2]] == grep ("company name", data [2]]))
Perhaps this is a string function An easy way to use?
Any ideas will be appreciated.
First of all (commentary made in Jonathan) In the context of the second column, The data should use [[2]] or data [2]
. But if you are using a subset, you can use the column name: subset (data, company name == ...)
.
And for you I will do one of these: %>
in the second I use grepl
(Presented with version 2.9) which is for true
Comments
Post a Comment