[R] Subset returning unexpected result
jim holtman
jholtman at gmail.com
Thu Oct 15 18:14:25 CEST 2009
It would be useful to also post the 'str(int1901)' so that we could
see the structure of the dataframe. Is Latitude by chance a 'factor'?
You could also put a subset with the data by doing:
dput(int1901)
On Thu, Oct 15, 2009 at 11:39 AM, Steve Murray <smurray444 at hotmail.com> wrote:
>
> 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
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list