Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.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
R 从列索引引用的数据框中删除列_R - Fatal编程技术网

R 从列索引引用的数据框中删除列

R 从列索引引用的数据框中删除列,r,R,我有一个名为Tweet\u Dataframe的数据框,它包含3列,即Id、name和Tweet。 tweet\u DataFrame的tweet列中有一些空行。因此,我使用forloop来计算tweet列中的行数,其长度为parantises位于错误的位置if(nchar(df$tweet.text[I])@Pierrelaffortune谢谢,但仍然推特_DataFrame您的代码有一个输入错误。修复输入错误,代码将正常工作。此外,这里绝对不需要循环。如果您添加一个示例数据框,您可以获得更详

我有一个名为
Tweet\u Dataframe
的数据框,它包含3列,即Id、name和Tweet。
tweet\u DataFrame
的tweet列中有一些空行。因此,我使用
forloop
来计算tweet列中的行数,其长度为parantises位于错误的位置
if(nchar(df$tweet.text[I])@Pierrelaffortune谢谢,但仍然推特_DataFrame您的代码有一个输入错误。修复输入错误,代码将正常工作。此外,这里绝对不需要循环。如果您添加一个示例数据框,您可以获得更详细的帮助。获取几行数据框并编辑您的问题,这样就有一行代码,我们可以在其中复制/粘贴to重新创建它。例如,
DF添加了一段数据帧,这是一个twitter数据。
removes_index <- c()

for(i in (1:length(df$tweet.text))){
  if(nchar(df$tweet.text[i]<=5)) 
  removes_index <- c(removes_index,i)  
}
Tweet_DataFrame<- Tweet_DataFrame[-removes_index,]
tweets.id   tweets.name tweets.text
5.51E+17    Luk     Absolutely loving these talk ads on TV. 
5.51 +17    Bree    make sure to tweet that day with the hashtag attached!