I have data frame with 5 columns.
I want to print the first 20 rows of columns 1 and 2 ignoring all the rows with NA's.
I don't want to change the data frame and remove all NA's
any ideas?
I have data frame with 5 columns.
I want to print the first 20 rows of columns 1 and 2 ignoring all the rows with NA's.
I don't want to change the data frame and remove all NA's
any ideas?
Hi,
How about this:
myData = data.frame(x = sample(c(NA, 1:5), 50, replace = T),
y = sample(c(NA, 1:5), 50, replace = T),
z = sample(c(NA, 1:5), 50, replace = T))
#Ignore row when NA in column 1 or 2
myData[complete.cases(myData[,1:2]),][1:20,1:2]
#Ignore row when NA in any column
myData[complete.cases(myData),][1:20,1:2]
PJ
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.