multiple columns - Eliminating rows with 0 values in R -



multiple columns - Eliminating rows with 0 values in R -

i have subsetted 2 columns want info set below:

hum <- weight.egg[,c("h_weight", "h_egg_number")]

i want remove rows (for both columns) contain 0 value. if 1 row in 1 of columns contains 0, want eliminate corresponding value in other column set well.

e.g. h_weight = 0.22 , h_egg_number = 0 <-- want eliminate whole row study

can help?

you can try

hum[!rowsums(!hum),] # h_weight h_egg_number #1 1.37095845 3 #3 0.36312841 3 #4 0.63286260 3 #6 -0.10612452 2 #7 1.51152200 1 #8 -0.09465904 3 #9 2.01842371 1 #10 -0.06271410 3

or suggested @david arenburg

hum[rowsums(hum == 0) < 1, ] data set.seed(42) hum <- data.frame(h_weight=rnorm(10), h_egg_number=sample(0:3,10,replace=true))

r multiple-columns

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -