[R] Trouble with simple R list concatenations

Jim Burke j.burke at earthlink.net
Mon Mar 21 02:32:05 CET 2011


PROBLEM How can I concatenate the following lists into ONE LIST WITHOUT 
the unhelpful message "operator is invalid for atomic vectors"?  Combine 
as a data frame?

EXAMPLE

Birth_Date      <- NULL
Birth_Date[1:3] <- c("01/17/1939","01/17/1949", "01/17/1959")
Later_Date      <- NULL
Later_Date[1:3] <- c("01/17/2009", NA, NA)
Names           <- NULL
Names[1:3]      <- c("Martha Smith", "John Doe", "Rufus Nobody")

#this does not work
family          <- c(Birth_Date, Later_Date, Names)
family$Birth_Date
Error in family$Birth_Date : $ operator is invalid for atomic vectors

FUNCTIONALLY DESIRED FROM THE FINAL COMBINED data frame
I would appreciate being able to do the following with the final list or 
data frame.
1. Be able to address names using $
2. Be able to change individual variables like the NA's to a proper date 
perhaps like

family$Later_Date[[3]] <- toString(format(Sys.time(),"%m/%d/%Y"), width=10)

Thanks, your help would is gratefully accepted,
Jim



More information about the R-help mailing list