When I create a dataframe from number vectors, R seems to truncate the value below the precision that I need in my analysis:
data.frame(x=0.99999996)
returns 1 (*, but see update 1)
I am stuck with fitting spline(x,y) , and two of the x values ββare 1 due to rounding, while y is changing. I could hack this, but I would rather use a standard solution if one is available.
Example
Here is an example dataset
d <- data.frame(x = c(0.668732936336141, 0.95351462456867, 0.994620622127435, 0.999602102672081, 0.999987126195509, 0.999999955814133, 0.999999999999966), y = c(38.3026509783688, 11.5895099585560, 10.0443344234229, 9.86152339768516, 9.84461434575695, 9.81648333804257, 9.83306725758297))
The following solution works, but I would prefer something less subjective:
plot(d$x, d$y, ylim=c(0,50)) lines(spline(d$x, d$y),col='grey')
Update 1
* After posting this question, I understand that this will return 1 , although the data frame still contains the original value, for example.
> dput(data.frame(x=0.99999999996))
returns
structure(list(x = 0.99999999996), .Names = "x", row.names = c(NA, -1L), class = "data.frame")
Update 2
After using dput to send this sample dataset and some pointers from Dirk, I see that the problem is not truncating the x values, but within the numerical errors in the model that I used to calculate y . This justifies dropping a few equivalent data points (as in the red line of the example).