[R] Subsetting between two values (into a range)????

Duncan Murdoch murdoch.duncan at gmail.com
Mon Mar 10 21:02:08 CET 2014


On 14-03-10 10:47 AM, arun wrote:
> Hi,
> If 'dat' is the dataset:
> Try
>
> subset(dat, Start < MapInfo & End > MapInfo)

A bit of advice I think I read in The Elements of Programming Style: 
try to make complex conjunctions look like their mathematical 
equivalents, and they'll be easier to read.  The mathematical way to 
write the test above would be Start < MapInfo < End, so the programmatic 
way to write it should be

Start < MapInfo & MapInfo < End

This makes the character of the interval completely obvious.

Duncan Murdoch

>
> A.K.
>
>
> Dear All,
>
> I want to subset a column (MapInfo in the attached photo) in csv
>   file if its values be ranged between values in two other columns (Start
>   and End in the attached photo) using R 3.0.1. Thank you in advance for
> all nice guides.
>
> M.H. Banabazi
>
> ______________________________________________
> 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.
>




More information about the R-help mailing list