在这个地理编码示例中,应该在discard函数中使用哪些参数?

在这个地理编码示例中,应该在discard函数中使用哪些参数?,r,geocoding,R,Geocoding,我试图将twitter配置文件的位置地理编码为纬度和经度,并希望使用本教程作为指导 一旦收集了一般用户信息,这里究竟如何使用discard函数?我运行了他们的示例代码,得到了 丢弃时出错(用户信息$location,=,“”):未使用的参数(“”) 之后是一个错误,未找到“已编码”的对象。 缺少哪些参数?我将如何到达获取lat/long的最后一步 #Code from tutorial library(rtweet) library(ggmap) library(tidyverse) rs

我试图将twitter配置文件的位置地理编码为纬度和经度,并希望使用本教程作为指导

一旦收集了一般用户信息,这里究竟如何使用discard函数?我运行了他们的示例代码,得到了 丢弃时出错(用户信息$location,
=
,“”):未使用的参数(“”)

之后是一个错误,未找到“已编码”的对象。 缺少哪些参数?我将如何到达获取lat/long的最后一步

#Code from tutorial
library(rtweet)

library(ggmap)

library(tidyverse)

rstats_us <- search_tweets("#rstats", 3000)

user_info <- lookup_users(unique(rstats_us$user_id))

 discard(user_info$location, `==`, "") %>% 
 ggmap::geocode() -> coded

 coded$location <- discard(user_info$location, `==`, "")

user_info <- left_join(user_info, coded, "location")
你想要:

user_info$location %>% discard(. == "")

discard
正在查找逻辑谓词或测试。有关更多信息,请参阅
?放弃

编辑:

下面是一个简单的例子:

library(purrr)
v <- c("New York", "", "San Francisco", "Chicago", "")
discard(v, ~.x == "")

这是否意味着首次使用discard?当我替换时,我现在得到错误>用户信息$location%%>%discard(.==“”)[1]NA NA NA NA NA NA NA NA NA NA NA NA>%%>%error:在“%%>%”ggmap::geocode()->stopifnot(is.character(location))中的编码错误:缺少参数“location”,没有默认值>是,这是第一次使用discard的语法。否则,不会创建
编码的
对象。我在回答中添加了一个类似的例子。这有用吗?
discard(user_info$location, ~.x == "")
library(purrr)
v <- c("New York", "", "San Francisco", "Chicago", "")
discard(v, ~.x == "")
[1] "New York"      "San Francisco" "Chicago"