[R] Subsetting out missing values for a certain variable
Jorge I Velez
jorgeivanvelez at gmail.com
Thu Jun 6 02:37:41 CEST 2013
Daniel,
You need "==" instead of "=".
HTH,
Jorge.-
Sent from my phone. Please excuse my brevity and misspelling.
On Jun 6, 2013, at 10:36 AM, Daniel Tucker <dtucker9 at u.rochester.edu> wrote:
> Also tried this but results werent any different
>
> subset1<- subset(dframe, glb_ind="Y" | sample==1 | !is.na(glb_ind))
> subset2<-subset(dframe, cwar_ind="Y" |sample==2 | !is.na(cwar_ind))
> subset3<-subset(dframe, reg_ind="Y" | sample==3 | !is.na(reg_ind))
>
>
> On Wed, Jun 5, 2013 at 9:33 AM, Daniel Tucker
> <daniel.tucker at rochester.edu>wrote:
>
>> I am trying to create a new datafarme using the subset function given 2
>> conditions
>>
>> subset1<- subset(dframe, glb_ind="Y" | sample==1)
>> subset2<-subset(dframe, cwar_ind="Y" | sample==2)
>> subset3<-subset(dframe, reg_ind="Y" | sample==3)
>>
>> However, my first conditions (glb_ind,cwar_ind, and reg_ind) all have
>> missing values (they are either Y, N, or no value. In subsetting my data, I
>> am looking to not only get rid of the "N" in the new dataframes, but also
>> the NA's. I don't want to na.omit the entire data frame; I only want to get
>> rid of missing values (and non Y values) for a certain variable (glb_ind,
>> cwar_ind, reg_ind) for each subset. Is there anyway I can do this?
>>
>> Thanks,
>> Dan
>
> [[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.
More information about the R-help
mailing list