Take the following code that generates a fractions
vector:
> example<-MASS:: as.fractions(c(0.2,0.4))
> example
[1] 1/5 2/5
如果要用字符串替换这些分数之一,则会出现以下错误:
> 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?
fractions
has a[<-
method: