R中出错:下标变量的类型quosure/公式错误。它必须是数字或字符
代码:R中出错:下标变量的类型quosure/公式错误。它必须是数字或字符,r,error-handling,dataset,geospatial,data-cleaning,R,Error Handling,Dataset,Geospatial,Data Cleaning,代码: GeoSeparate <- function(Dataset, GeoColumn) { GeoColumn <- enquo(GeoColumn) Dataset %>% separate(GeoColumn, into = c("Section1", "Section2"), sep = "\\(")%>% separate(Section1, into = c("Section3", "Section4"), sep = ","
GeoSeparate <- function(Dataset, GeoColumn) {
GeoColumn <- enquo(GeoColumn)
Dataset %>%
separate(GeoColumn, into = c("Section1", "Section2"), sep = "\\(")%>%
separate(Section1, into = c("Section3", "Section4"), sep = ",")%>%
separate(Section2, into = c("GeoColumn", "Section5"), sep = "\\)")%>%
separate(GeoColumn, into = c("GeoColumnLat", "GeoColumnLon"), sep = ",")%>%
select(-Section3, -Section4, -Section5) #remove sections we don't need
}
GeoSeparate(df3, DeathCityGeo)
错误:
必须使用单个下标提取列。
x下标
var的类型错误
quosure/formula。
ℹ 它必须是数字或字符。
我的函数将格式为“Norwalk,CT\n(41.11805,-73.412906)”的列分隔开,这样纬度和经度就剩下了,它们位于两个单独的列中。它工作了一段时间,但现在我得到了上面描述的错误消息。这可能是因为我更新了我的库,但我不确定。任何帮助都将是惊人的!谢谢。我们需要评估(!!
)
谢谢——我试过了,现在它说“错误:找不到对象‘Deathcity’Geo”。你知道为什么吗?@ajg我无法重现这个问题。你能测试一下这个
f1吗?我不确定。我还在想办法。我已经测试了找不到对象的常见错误,但尚未修复该问题@akrun@ajg列名是否正确,即它应该使用正确的名称,如我在“f1”中所示。刚刚修复了它!我意识到我函数中的第二个“GeoColumn”是在我单独的函数中创建的,因此不应该在{{}}中,但我已经将其更改为NewGeoColumn,这样下次就不会混淆了。谢谢你的帮助@akrun
GeoSeparate <- function(Dataset, GeoColumn) {
GeoColumn <- enquo(GeoColumn)
Dataset %>%
separate(!!GeoColumn, into = c("Section1", "Section2"), sep = "\\(")%>%
separate(Section1, into = c("Section3", "Section4"), sep = ",")%>%
separate(Section2, into = c("GeoColumn", "Section5"), sep = "\\)")%>%
separate(!!GeoColumn, into = c("GeoColumnLat", "GeoColumnLon"), sep = ",")%>%
select(-Section3, -Section4, -Section5) #remove sections we don't need
}
GeoSeparate <- function(Dataset, GeoColumn) {
Dataset %>%
separate({{GeoColumn}}, into = c("Section1", "Section2"), sep = "\\(")%>%
separate(Section1, into = c("Section3", "Section4"), sep = ",")%>%
separate(Section2, into = c("GeoColumn", "Section5"), sep = "\\)")%>%
separate({{GeoColumn}}, into = c("GeoColumnLat", "GeoColumnLon"), sep = ",")%>%
select(-Section3, -Section4, -Section5) #remove sections we don't need
}