[R] Subset returning unexpected result

Steve Murray smurray444 at hotmail.com
Thu Oct 15 17:39:43 CEST 2009


Dear all,

I am attempting to subset a data frame based on a range of latitude values. I want to extract the values of 'interception' where latitude ranges between 50 and 60. I am doing this using the following code, yet it doesn't return the results I expected:


> test <- subset(int1901, Latitude>=50 & Latitude <60, select=c(Latitude, Interception))


> head(test)
   Latitude Interception
2      6.25   0.04725863
3      6.75  67.02455139
82    50.75  51.74784088
83    51.25  57.04327774
84    51.75  51.51020432
85    52.25  53.30662537


As you can see, latitude values outside the 50 to 60 range have been retained (e.g. the top two rows of 'test'). Why is this, and how can I ensure that I subset the data as initially intended?

Many thanks for any help offered,

Steve

 		 	   		  




More information about the R-help mailing list