df <- data.frame(values = c(2.5, 12, 4.8, 56, 78),
samples = c('45fe.K2', '59ji.K2', '59rc.K1', '45hi.K1', '96hu.K1'))
df$group <- NA
df$group <- apply(df,1,function(x)
{ifelse(grepl('K2',df$samples) == TRUE,paste('K2'),paste('K1'))})
Error in `$<-.data.frame`(`*tmp*`, "PANEL", value = c(1L, 2L, 2L, 2L, :
replacement has ... rows, data has ....rows
I am trying to do a boxplot with df but the problem is that whenever I try to do something that includesdf$group the error occurs. What can I do about that? As mentioned in similar posts, I firstly made a new empty column that is filled in the next step. But the error occured nontheless. Can I work around somehow?
That question is related to a previous one, that was concerning about the boxplot Grouped boxplot in R
Aucun commentaire:
Enregistrer un commentaire