% sepa-6ren">
gpt4 book ai didi

r - R : The subscript var has the wrong type quosure/formula. It must be numeric or character中的错误

转载 作者:行者123 更新时间:2023-12-03 07:52:16 24 4
gpt4 key购买 nike

代码:

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)

错误:
Must extract column with a single subscript.
x The subscript
var has the wrong type quosure/公式 .
ℹ It must be numeric or character.

我的函数分隔了一个格式为“Norwalk,CT \ n(41.11805,-73.412906)”的列,以便保留所有的纬度和经度,并且它们分别位于两个单独的列中。它工作了一段时间,但现在我收到了上述错误消息。可能是因为我更新了库,但不确定。任何帮助都将是惊人的!谢谢。

最佳答案

我们需要评估(!!)

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
}

或另一个选项是 curly-curly( {{}})
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
}

关于r - R : The subscript var has the wrong type quosure/formula. It must be numeric or character中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62161362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com