[R] inserting into data frame gives "invalid factor level, NAs generated"

2009-08-12 Thread karinlag
I am calculating some values that I am inserting into a data frame. From what I have read, creating the dataframe ahead of time is more efficient, since rbind (so far the only solution I have found to appending to a data frame) is not very fast. What I am doing is the following: # create data fra

Re: [R] inserting into data frame gives "invalid factor level, NAs generated"

2009-08-12 Thread Scott Sherrill-Mix
Your running into the pretty common factor vs character problem in R. By default data.frame turns character vectors into factor (sort of like ENUM in mysql) vectors. Since you only have 1 factor (empty string '') in your starting dataframe, when you go to insert new data R sees a new value and comp