Closed fdchevalier closed 11 months ago
Thanks! I really appreciate the excellent example.
The problem is in lines 199-201 of read.cross.csvs.R:
colnames(pheno) <- unlist(pheno[1,])
pheno <- apply(pheno, 2, function(a) { a[!is.na(a) & a==""] <- NA; a })
pheno <- as.data.frame(pheno[-1,], stringsAsFactors=TRUE)
The apply()
function with a single-column data frame messes up the column names.
I am glad the example helped.
So, a simple fix could be storing the column names and setting them after the data frame is created. Something like:
pnames <- unlist(pheno[1,])
pheno <- apply(pheno, 2, function(a) { a[!is.na(a) & a==""] <- NA; a })
pheno <- as.data.frame(pheno[-1,], stringsAsFactors=TRUE)
colnames(pheno) <- pnames
Happy to send a PR your way if you would like.
@fdchevalier I've got it fixed; thanks!
Dear Karl,
First, thank you very much for having made and maintaining this very useful package.
I came across an unexpected behavior when using the
read.cross()
function with a phenotype file that has a single column. Despite the column having a "id" header, this header is not present after creating thecross
object. This is not the case when the phenotype file has 2 columns.Here is a reproducible example:
This prevents
getid()
to work as expected.Here is my environment details:
Please let me know if you need more details.
Fred