testd <- data.frame(A= c(1,2,3,4), B = c(5,6,7,8), C= c(3,4,5,9) )
I would like to remove rows where data$A * data$B * data$C > 105.
I could solve this for example using ifelse
, create a fourth column and delete afterwards. The problem is that my file is almost taking up all memory and I can't proceed. Is it possible to row by row using apply
function?
rowf <- function(x){
x <- as.data.frame(x)
ans1 <- x$A * x$B * x$C
if(ans1 > 105){
return(NULL)
}
else {
return(x)
}
}
apply(testd,1, rowf)
The above is my try on this, but I cant succeed.