R: Strsplit para agregar nombres a Boxplot aumenta un error
Pregunta
Estoy usando Strsplit en R para agregar nombres a Boxplot, pero esto me da un error.
strng <- "one%two%three"
tt <- strsplit(strng,"%",fixed=TRUE)
y luego
boxplot(param~grp,data=snp,horizontal=TRUE,names=tt)
Esto produce
ls = list(c("one", "two", :
'at' and 'labels' lengths differ, 3 != 1
Calls: boxplot ... boxplot.default -> do.call -> bxp -> do.call -> axis
Execution halted
El argumento de los nombres requiere un vector y Strsplit devuelve una lista.Son estos incompatibles?
si lo hago
boxplot(param~grp,data=snp,horizontal=TRUE,names=c("on","two","three"))
entonces está bien.
muchas gracias por su ayuda
Solución
Utilice tt[[1]]
o unlist(tt)
en lugar de tt
boxplot(param~grp,data=snp,horizontal=TRUE,names=tt[[1]])
GraberacodicEtCode El argumento está esperando un vector y names
es una lista, por lo que debe pasar un vector no una lista.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow