ostat2longform not working for two sites?
Closed this issue · 3 comments
Ostat2longform does not seem to work if I only have two sites (it works in code supplement). The error is in the line
res <- cbind(site = rep(dimnames(o[[1]])[[1]], each=ntrait), trait = rep(dimnames(o[[1]])[[2]], times=nsite), res)
Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 2, 0
@yyue-r Again it would be really helpful if you could give me the code that you used that produced this error, so that I can be sure we are looking at the same thing! :-D
It is also in the vignette! I think it's line 177.
OK I found the problem! Basically it is just that the traits
object that was used to create Ostats_example
did not have a column name. So then when you use dimnames
to try to get the trait name, it returns NULL
and then the cbind
gives an error. So what I would do to fix this is to make sure the matrix has a name. In the vignette on line 74, replace dat$log_weight
with dat[,'log_weight']
and you will get the exact same result except that the matrix will have a column name which will fix the error!
I didn't commit this change so I will leave it to you to do that in the vignette. I'll close it for now but let me know if this does not work!