Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dataframe colsplit提供NAs而不是有效的valies_Dataframe - Fatal编程技术网

Dataframe colsplit提供NAs而不是有效的valies

Dataframe colsplit提供NAs而不是有效的valies,dataframe,Dataframe,我使用colsplit将一个包含短语的字符列拆分为组成单词,每个单词对应一列。但是,对于下面的示例,它给出的是NAs而不是有效的单词 > p <- data.frame(Phrase = c("the last time i", "given the situation i")) > p Phrase 1 the last time i 2 given the situation i > colsplit(p$Phrase,

我使用colsplit将一个包含短语的字符列拆分为组成单词,每个单词对应一列。但是,对于下面的示例,它给出的是NAs而不是有效的单词

> p <- data.frame(Phrase = c("the last time i", "given the situation i"))
> p
                 Phrase
1       the last time i
2 given the situation i
> colsplit(p$Phrase, " ", names = c("w1", "w2", "w3", "w4"))
     w1   w2        w3 w4
1   the last      time NA
2 given  the situation NA
> 
>p
短语
上次我
2鉴于目前的情况,我
>colsplit(p$Phrase,“,name=c(“w1”、“w2”、“w3”、“w4”))
w1 w2 w3 w4
1最后一次
2鉴于目前的情况
> 

我不明白为什么“w4”列没有原始数据框中短语中的“I”。是否需要使用“”以外的其他内容拆分字符串?或者,colsplit中是否有任何选项需要我使用才能正常工作?谢谢。

我将上述短语改为“上次”和“鉴于情况”,并尝试使用colsplit。它工作正常,在最后一列中给出了“It”,没有NAs。我还试着用单个字母“a”替换“it”,以防最后一个单词是单个字母时出现问题。但在结尾加上“a”也可以。所以,我不知道这里发生了什么。