[R] Loading Rdata files in a Package

2010-07-25 Thread Andrew Leeser
I have an .Rdata file saved in my "data" folder in a package I created. However, when I use the data() function it doesn't recognize that there any dataset exists within the package. Is there anything specific I need to do such that the data() function will load my dataset? Thanks in advance,

[R] Subsetting Lists

2010-07-12 Thread Andrew Leeser
I am looking for a way to create a vector which contains the second element of every vector in the list. However, not every vector has two components, so I need to generate an NA for those missing. For example, I have created the following list: lst <- list(c("a", "b"), c("c"), c("d", "e"), c("

[R] Trimming in R

2010-07-07 Thread Andrew Leeser
I am looking for a way to trim leading and trailing spaces in a character string in R. For example: "   this is random text    " should become: "this is random text". I have a short function to perform this task as follows: trim <- function(str){    str <- sub("^ +", "", str)