Greetings I'm attempting to insert missing data on the smallest size class of cave cricket instars into a data frame. The data involve censusing photoplots (plots) of roosting cave crickets in which we discern in four instars or size classes. I need to insert data on size class one into a data frame that already has data on size classes two through four. The data can be merged by their cave name, year, month, region (near or far from cave entrance), plot #, and Individual (IndID). For example: (Embedded image moved to file: pic14606.jpg) As one example, I have data for size class (SC) one I can insert after IndID #4 in the data above. However, when I attempt to merge these two data frames using the following commands: "Hs.full.anal<-merge(Hs.short.missgval,SC1_0608, byx=c(Cave,Year,Month,Region,Plot,IndID), byy=c(Cave,Year,Month,Region,Plot,IndID))" I get the following message: "WARNING: Warning in `[<-.factor`(`*tmp*`, ri, value = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, : invalid factor level, NAs generated" Can anyone tell me what this means and how I might fix it? Cheers Kurt *************************************************************** Kurt Lewis Helf, Ph.D. Ecologist EEO Counselor National Park Service Cumberland Piedmont Network P.O. Box 8 Mammoth Cave, KY 42259 Ph: 270-758-2163 Lab: 270-758-2151 Fax: 270-758-2609 **************************************************************** Science, in constantly seeking real explanations, reveals the true majesty of our world in all its complexity. -Richard Dawkins The scientific tradition is distinguished from the pre-scientific tradition in having two layers. Like the latter it passes on its theories but it also passes on a critical attitude towards them. The theories are passed on not as dogmas but rather with the challenge to discuss them and improve upon them. -Karl Popper ...consider yourself a guest in the home of other creatures as significant as yourself. -Wayside at Wilderness Threshold in McKittrick Canyon, Guadalupe Mountains National Park, TX Cumberland Piedmont Network (CUPN) Homepage: http://tiny.cc/e7cdx CUPN Forest Pest Monitoring Website: http://bit.ly/9rhUZQ CUPN Cave Cricket Monitoring Website: http://tiny.cc/ntcql CUPN Cave Aquatic Biota Monitoring Website: http://tiny.cc/n2z1o
On Wed, Nov 10, 2010 at 1:38 PM, <Kurt_Helf at nps.gov> wrote:> > Greetings > ? ? I'm attempting to insert missing data on the smallest size class of > cave cricket instars into a data frame. The data involve censusing > photoplots (plots) of roosting cave crickets in which we discern in four > instars or size classes. ?I need to insert data on size class one into a > data frame that already has data on size classes two through four. ?The > data can be merged by their cave name, year, month, region (near or far > from cave entrance), plot #, and Individual (IndID). ?For example: > (Embedded image moved to file: pic14606.jpg) > > As one example, I have data for size class (SC) one I can insert after > IndID #4 in the data above. ?However, when I attempt to merge these two > data frames using the following commands: > "Hs.full.anal<-merge(Hs.short.missgval,SC1_0608, > ? ? ?byx=c(Cave,Year,Month,Region,Plot,IndID), > ? ? ?byy=c(Cave,Year,Month,Region,Plot,IndID))" > I get the following message: > "WARNING: Warning in `[<-.factor`(`*tmp*`, ri, value = c(1L, 1L, 1L, 1L, > 1L, 1L, 1L, ?: > ?invalid factor level, NAs generated"Hard to say with the level of detail you provided, but chances are that your data are converted (internally) to factors. If not too inconvenient, I would quit the R session without saving anything, restart and type options(stringsAsFactors=FALSE) before running anything. This prevents storing of character vectors as factors. If you already have a data frame that stores factors, you can try something along the lines of newFrame = apply(frame, 2, as.character) Hope this helps, Peter