R extracting non-missing data -


this question has answer here:

i have dataframe:

a<-c(1,2,3) b<-c("cara","carb",na) data<-data.frame(a,b)  data         b   1 1 cara   2 2 carb   3 3   na 

now want remove row missing data (na).

but not work:

data<-data[data[,2]!=na,] 

my thinking here @ second column [,2] , don't have na. extract remaining data. able tell me went wrong here?

wouldn't

na.omit(data) 

do? seems cleanest , fastest way me.

by way, code not work because cannot !=na

use is.na() instead (but na.omit() better):

data[!is.na(data[,2]),] 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -