我试图提取列表中对象的名称,它们都是sf。所以我不能使用名称。
`subte_estaciones <- st_read("http://bitsandbricks.github.io/data/subte_estaciones.geojson")
Universidades = read.csv("C:/Users/sixto/OneDrive/Documentos/GCBA/Alquiler Social/Universidades.csv")
Universidades <- Universidades %>% st_as_sf(coords = c("long", "lat"), crs = 4326)
trenes = st_read("https://cdn.buenosaires.gob.ar/datosabiertos/datasets/transporte-y-obras-publicas/estaciones-ferrocarril/estaciones-de-ferrocarril.geojson")
object_list = list(subte_estaciones , trenes , Universidades )
names(object_list)
零
我需要一个向量中的对象名称来替换列名。
我几乎什么都试过了,但都无济于事。
对象名称〈- c()
# Use a for loop to iterate through the list and store the names of the objects in the new vector
for(i in 1:length(object_list)) {
object_names[i] <- paste0(deparse(substitute(object_list[[i]])),i)
}
# Print the new vector of object names
object_names
# Create a new vector to store the names of the sf objects
object_names <- c()
# Use a for loop to iterate through the list and store the names of the objects in the new vector
for(i in 1:length(object_list)) {
object_names[i] <- paste0("sf_object_",i)
}
# Print the new vector of object names
object_names
1条答案
按热度按时间syqv5f0l1#
要获取object_list的名称,必须首先命名列表中的对象