使用函数 google_places 时,位置参数是坐标对向量。但是,在我编写的这个函数中,返回了一个错误:
Error in validateGeocodeLocation(location) :
location must be a vector of a pair of latitude and longitude coordinates
这是在我的功能之外工作的简单命令。我使用 c(39, -105)。
search <- google_places(search_string = "Urgent care center", key = key, location = c(39, -105), radius = 50000)
这是我编写的将返回错误的函数:
full_search <- function(search_string,
key, location, radius){
call_1 <- google_places(search_string,
key,
location,
radius)
thin1 <- thin_df(call_1)
return(thin1)}
full_search("Urgent care center", key, c(39, -105), 50000)
在这里,thin_df 是我编写的一个函数,它运行平稳并返回所需的数据帧:
thin_df(search)
name lat lon
1 UCHealth Urgent Care - Garden of the Gods 38.89643 -104.8416
2 UCHealth Urgent Care - Circle Square 38.79420 -104.7879
3 Penrose Community Urgent Care 38.87440 -104.7936
4 UCHealth Urgent Care - Powers 38.89424 -104.7211
5 Emergicare Austin Bluffs 38.89066 -104.7548
6 UCHealth Urgent Care - Voyager Parkway 39.02628 -104.8166
7 QwikCare MD Urgent Care 38.89746 -104.8274
8 Woodmen Medical Park 38.94013 -104.7504
9 Centura Health Urgent Care Fountain 38.71720 -104.7009
10 AFC Urgent Care Castle Rock 39.41698 -104.8799
11 Powers Pointe Urgent Care 38.89393 -104.7234
12 UCHealth Urgent Care - Castle Rock 39.40604 -104.8559
13 QwikCareMD Urgent Care Center 38.91051 -104.7207
14 Centura Health Urgent Care Broadmoor 38.79425 -104.8042
15 Optum Urgent Care 38.87492 -104.7956
16 Wik Care Md Urgent Care Center 38.76717 -104.8158
17 Colorado Urgent Care Associates PC 38.87430 -104.7937
18 Urgent CareX 38.85588 -104.7937
19 Falcon Urgent Care 38.93956 -104.6041
20 Optum Urgent Care 39.06502 -104.8481
如果错误引用了 location 参数,为什么会发生这种情况,该参数在函数之外没有变化?
谢谢!