ron-r
4/23/2014 - 8:54 AM

subsetting or creating a data frame on two columns and values :http://www.ats.ucla.edu/stat/r/faq/subset_R.htm

subsetting or creating a data frame on two columns and values :http://www.ats.ucla.edu/stat/r/faq/subset_R.htm

subsetting a data frame on two columns and values

#easy step:
dat1<-dat[dat$target>0,]

here is the subset command : "which"

loc_dataD7<-loc_data[which(loc_data$IsChurn_Day0==0),]

# and with two conditions:

loc_dataD7<-loc_data[which(loc_data$IsChurn_Day7==1 & loc_data$IsChurn_Day0==0),]

http://www.ats.ucla.edu/stat/r/faq/subset_R.htm

####remove data greater than 95th percentile in data frame
> quantile(d$Point, 0.95)
 95% 
5800 

> d[d$Point < quantile(d$Point, 0.95), ]
  Group Point
2     B  5000
3     C  1000
4     D   100
5     F    70

dat1<-dat[dat$TtlDepositAmountTillDay180< quantile(dat$TtlDepositAmountTillDay180,0.97),]