R:strsplit向boxplot添加名称会引发错误

R:strsplit向boxplot添加名称会引发错误,r,boxplot,strsplit,R,Boxplot,Strsplit,我在R中使用strsplit向boxplot添加名称,但这给了我一个错误 strng <- "one%two%three" tt <- strsplit(strng,"%",fixed=TRUE) 这就产生了 ls = list(c("one", "two", : 'at' and 'labels' lengths differ, 3 != 1 Calls: boxplot ... boxplot.default -> do.call -> bxp -> d

我在R中使用strsplit向boxplot添加名称,但这给了我一个错误

strng <- "one%two%three"
tt <- strsplit(strng,"%",fixed=TRUE)
这就产生了

ls = list(c("one", "two",  :
  'at' and 'labels' lengths differ, 3 != 1
Calls: boxplot ... boxplot.default -> do.call -> bxp -> do.call -> axis
Execution halted
names参数需要一个向量,strsplit返回一个列表。这些是不相容的吗

如果我这样做

boxplot(param~grp,data=snp,horizontal=TRUE,names=c("on","two","three"))
那就好了


非常感谢您的帮助

使用
tt[[1]]
unlist(tt)
而不是
tt

boxplot(param~grp,data=snp,horizontal=TRUE,names=tt[[1]])
names
参数需要一个向量,而
tt
是一个列表,因此需要传递一个向量而不是列表

boxplot(param~grp,data=snp,horizontal=TRUE,names=tt[[1]])