Skip to content
Prev 294511 / 398502 Next

select data

This overwrites the data so you might want to create a copy first.

example <- data.frame(V1=c(3, -1), V2=c(-2, 4), V3=c(4, 1))
tf <- ifelse(example<0, TRUE, FALSE)
example[tf] <- NA
apply(example, 1, mean, na.rm=TRUE)

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352