Deleting Rows in R -


this question has answer here:

i'm trying delete rows in dataframe when average of vector > individual number in vector. reason seems pick , choose ones deletes. appreciated thank you, here code.

k<-c(hw2$age) j<-mean(k) (i in hw2$age)   if (j>i){     hw2 <- hw2[-i, ]   } 

don't need vectorise. instead use below

sample data

x <- data.frame("a"= runif(10), "b" = runif(10)) 

calculate mean

xmean <- mean(x[,"a"]) 

exclude rows

y <- x[x$a < xmean,] 

this obvious way of excluding unwanted rows


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -