I am using strsplit in R to add names to boxplot but this gives me an error.
strng <- "one%two%three"
tt <- strsplit(strng,"%",fixed=TRUE)
and then
boxplot(param~grp,data=snp,horizontal=TRUE,names=tt)
this yields
ls = list(c("one", "two", :
'at' and 'labels' lengths differ, 3 != 1
Calls: boxplot ... boxplot.default -> do.call -> bxp -> do.call -> axis
Execution halted
the names argument requires a vector and strsplit returns a list. Are these incompatible?
If I do
boxplot(param~grp,data=snp,horizontal=TRUE,names=c("on","two","three"))
Then it is ok.
Thanks a lot for your help
Use tt[[1]]
or unlist(tt)
instead of tt
boxplot(param~grp,data=snp,horizontal=TRUE,names=tt[[1]])
names
argument is expecting a vector and tt
is a list, so you need to pass a vector not a list.