How should I deal with “package ‘xxx’ is not available (for R version x.y.z)” warning?

I tried to install a package, using install.packages(“foobarbaz”) but received the warning Warning message: package ‘foobarbaz’ is not available (for R version x.y.z) Why doesn’t R think that the package is available? See also these questions referring to specific instances of this problem: My package doesn’t work for R 2.15.2 package ‘Rbbg’ is not available … Read more

How to convert a factor to integer\numeric without loss of information?

When I convert a factor to a numeric or integer, I get the underlying level codes, not the values as numbers. f <- factor(sample(runif(5), 20, replace = TRUE)) ## [1] 0.0248644019011408 0.0248644019011408 0.179684827337041 ## [4] 0.0284090070053935 0.363644931698218 0.363644931698218 ## [7] 0.179684827337041 0.249704354675487 0.249704354675487 ## [10] 0.0248644019011408 0.249704354675487 0.0284090070053935 ## [13] 0.179684827337041 0.0248644019011408 0.179684827337041 ## [16] … Read more

Grouping functions (tapply, by, aggregate) and the *apply family

Whenever I want to do something “map”py in R, I usually try to use a function in the apply family. However, I’ve never quite understood the differences between them — how {sapply, lapply, etc.} apply the function to the input/grouped input, what the output will look like, or even what the input can be — … Read more