Take the following code that generates a fractions
vector:
> example<-MASS:: as.fractions(c(0.2,0.4))
> example
[1] 1/5 2/5
If we were to replace one of these fractions with a string, we get the following error:
> example[1]<-"0/1"
Error in floor(x) : non-numeric argument to mathematical function
How does this happen? As far as I was concerned, fractions
vectors aren't S4 objects and shouldn't have any sort of error checking, so how is floor(x)
being ran when I'm trying to replace an entry in such a a vector?