I am trying to read in a data set using the convert.inp() within package RMark.
My data set contains individual ID numbers, recapture histories (i.e. 0101..00101...), site, species, age, sex, weight, and parasite burden. I formatted the data in a .inp with the site as the group - immediately following the recapture history - and with the species as the group in a second .inp file. Both files have /* */
comments for column headers and for the unique ID number. The Site as group file reads in fine with 213 observations of 22 variables. The Species as group file produces the following error:
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line 2 did not have 37 elements
If I remove the /* */
column header comments, the file will read in but is only 211 observations of 13 variables.
Why am I getting this error in the first place? And why do I have fewer observations in the second file by simply removing the column header?
Here is the code that I have tried:
File 1 Site as group:
SiteGroup <- convert.inp("SiteGroup.inp", group.df = data.frame(Site= c("Albany Pine Bush", "SChroon Lake")), covariates = c("Peromyscus", "Tamias striatus", "Myodes gapperi", "Blarina brevicauda", "Sorex cinereus", "Tamiasciurus hudsonicus", "Glacomys volans", "Glacomys sabrinus", "Napeaozapus insignis", "Mustela frenata", "Sorex hoyi", "Male", "Female", "Juvenile", "Adult", "Weight (g)", "dWeight (g)", "Length (cm)", "Avg Tick Burden"), use.comments = TRUE)
*gives Warning NAs introduced by coersion - I am missing weight for 1 individual
File 2 species as group with column header:
SpeciesGroup <- convert.inp("SpeciesGroup.inp", group.df = data.frame(Species = c("Peromyscus", "Tamias striatus", "Myodes gapperi", "Blarina brevicauda", "Sorex cinereus", "Tamiasciurus hudsonicus", "Glacomys volans", "Glacomys sabrinus", "Napeaozapus insignis", "Mustela frenata", "Sorex hoyi")), covariates = c("Albany Pine Bush", "Schroon Lake", "Male", "Female", "Juvenile", "Adult", "Weight (g)", "dWeight (g)", "Length (cm)", "Avg Tick Burden"), use.comments = TRUE)
File 2 output:
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line 2 did not have 37 elements
After exporting the converted dataframe as .csv, I was able to compare each line from the species group file to the source file and found that 2 two individual had 0 in all the fields for species code.