[R] I can't get seq to behave how I think it should

POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS FOUNDATION TRUST) c@|um@po|w@rt @end|ng |rom nh@@net
Thu Jan 17 14:33:45 CET 2019


I am using seq with the expression seq(1.4, 2.1, by=0.001) to create a sequence of references from 1.4 to 2.1 in 0.001 increments.  They appear to be created correctly.  They have a related pair of data which for the purposes of this we will call val.  I'm interested in the content on the row with seq = 1.8. But I can't seem to get it returned.  I can get other values but not 1.8!  yet looking at row 401 there is nothing to indicate an issue

> a = 1.4
> b = 2.1
> seq = seq(a, b, by=0.001)
> val = ceiling(seq * 50)
> s=data.frame(seq, val)
> s$val[seq==1.799]
[1] 90
> s$val[s$seq==1.8]
numeric(0)
> s$val[seq==1.8]
numeric(0)
> s$val[s$seq==1.800]
numeric(0)
> s$val[s$seq==1.801]
[1] 91
> head(s[s$seq>1.798,])
      seq val
400 1.799  90
401 1.800  90
402 1.801  91
403 1.802  91
404 1.803  91
405 1.804  91


Can anyone explain what's going on here and how I would correctly find the content of row 401 by using an expression to equal the seq column?





********************************************************************************************************************

This message may contain confidential information. If yo...{{dropped:19}}



More information about the R-help mailing list