R帮助错误

时间:2017-10-05 00:35:07

标签: r

我正在使用R做作业,我在下面有这个代码。向量B基本上是从向量a中的字符串中移除空格。然后,矢量c将使用空格分割B中的字符串。然后我想排序c的列表。但我必须将其转换为简单的原子矢量,以便排序。但是当我这样做时,我得到一个错误,如下所示。

a <- c("Chpater 5 ", "Green Eggs and Ham", "Dr. Seuss ", "That Sam-I-am! ", "p. 25")
a
b<-str_trim (a, side = "both")
b

library (stringr)

c<-str_split (b, pattern = " ")
c
sort (c)
unlist ( str_split (c, pattern = " "))

这是我从上面的最后一段代码得到的结果。

 [1] "c(\"Chpater\"," "\"5\")"         "c(\"Green\","   "\"Eggs\","     
 [5] "\"and\","       "\"Ham\")"       "c(\"Dr.\","     "\"Seuss\")"    
 [9] "c(\"That\","    "\"Sam-I-am!\")" "c(\"p.\","      "\"25\")
sort (c)

但是当我将c转换为简单的原子向量时,我没有得到变量c的排序。以下是我在运行该行时收到的消息

> unlist ( str_split (c, pattern = " "))
Error in stri_split_regex(string, pattern, n = n, simplify = simplify,  : 
 argument `str` should be a character vector (or an object coercible to)
> sort (c)
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) : 
 'x' must be atomic 

1 个答案:

答案 0 :(得分:2)

@XStreamAlias("localSearch")
public class LocalSearchPhaseConfig extends PhaseConfig<LocalSearchPhaseConfig> {
}