Re: [R] Subsetting with missing data

2012-08-15 Thread arun
HI, Try this: subset(a,y==0) #    x y #2   2 0 #5   5 0 #10 10 0 #or subset(a,y%in%0) #    x y #2   2 0 #5   5 0 #10 10 0 A.K. - Original Message - From: Robin Jeffries To: r-help@r-project.org Cc: Sent: Wednesday, August 15, 2012 4:06 PM Subject: [R] Subsetting with missing data

Re: [R] Subsetting with missing data

2012-08-15 Thread Ista Zahn
It makes sense if you think it through. Your index vector is a$y==0 [1] FALSE TRUENA FALSE TRUENANA FALSE FALSE TRUE and ?"[" says NAs in indexing: When extracting, a numerical, logical or character 'NA' index picks an unknown element and so returns 'NA' in the corre

Re: [R] Subsetting with missing data

2012-08-15 Thread Rui Barradas
Hello, From the help page for ?`==` Note Do not use |==| and |!=| for tests, such as in |if| expressions, where you must get a single |TRUE| or |FALSE|. Unless you are absolutely sure that nothing unusual can happen, you should use the |identical