Skip to content
Prev 181928 / 398513 Next

R's documentation

On May 30, 2009, at 2:01 AM, Zeljko Vrba wrote:

            
Actually the help page also says:
"If the two arguments are atomic vectors of different types, one is  
coerced to the type of the other, the (decreasing) order of precedence  
being character, complex, numeric, integer, logical and raw."

But the recurring puzzle of "what factors really are" is at work here:

 > x <- factor(8)
 > typeof(x)
[1] "integer"
 > as.integer(x)
[1] 1
 > x == 8
[1] TRUE
 > is.numeric(x)
[1] FALSE

 > typeof(x)
[1] "integer"
 > is.integer(x)
[1] FALSE

 > mode(x)
[1] "numeric"
 > is.numeric(x)
[1] FALSE
Actually objects have classes (which determine what functions can be  
applied), while functions have methods:
?class
?methods
I remember similar problems in getting to the point where I could use  
dataframes. In frustration I decided to construct a PowerPoint  
(actually a OO.o Presentation) that assembled the various accessor and  
constructor functions for the components of dataframes.
The usual advice is to get a book. In years gone by Venables and  
Ripley's MASS was the standard, but more recently Dalgaard and others  
have offered their best efforts at an "intro to R". My library  
includes MASS ed 2, Sarkar's Lattice, Spector's Data Manipulation with  
R, Harrell's RMS, Wood's "GAMs: An Intro with R".