[R] Exclude data using logical
David Winsemius
dwinsemius at comcast.net
Thu Mar 25 02:01:52 CET 2010
On Mar 24, 2010, at 7:46 PM, pgseye wrote:
>
> Hi,
>
> I'm wanting to exclude data more than 2 sd's from the mean before
> proceeding
> with further analyses. I've created new logical variables (a and b)
> and
> written them to the existing dataframe. I want to be able to subset
> the TRUE
> observations based on another 2 factor variable. I'm assuming this is
> possible, but I don't know what I'm doing wrong, as I get results that
> obviously aren't correct.
>
> Many thanks,
>
> Paul
>
> twin.wide$a<-twin.wide$RCCT<600 & twin.wide$RCCT>480
> twin.wide$b<-twin.wide$LCCT<600 & twin.wide$LCCT>480
>
> selVarsCCT <- with(twin.wide,c('a','b')) # not sure what that would
> do. That 'a', 'b' vector would not be interpreted.
I do not think you want to select those columns since they do not have
the original data, but rather the markers you just created.
>
> MZCCT <- subset(twin.wide,Zygosity=='MZ',selVarsCCT)
> DZCCT <- subset(twin.wide,Zygosity=='DZ',selVarsCCT)
Assuming you want elements of twin.wide that meet both the conditions
that a and b are within the range yu slected then try:
MZCCT <- subset(twin.wide, Zygosity=='MZ'& a & b)
# will select all column vales in the qualifying rows.
# add a select= parameter if you only want certain rows
--
David.
> --
> View this message in context: http://n4.nabble.com/Exclude-data-using-logical-tp1689992p1689992.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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