Foursquare API에서 일부 데이터를 구문 분석하는 중이며 중첩 된 데이터 프레임이있는 큰 목록 인 다음과 같은 결과의 일부가 있습니다.
List of 1
$ :List of 26
..$ :'data.frame': 1 obs. of 6 variables:
.. ..$ id : chr "4bf58dd8d48988d129951735"
.. ..$ name : chr "Train Station"
.. ..$ pluralName: chr "Train Stations"
.. ..$ shortName : chr "Train Station"
.. ..$ icon :'data.frame': 1 obs. of 2 variables:
.. .. ..$ prefix: chr "https://ss3.4sqi.net/img/categories_v2/travel/trainstation_"
.. .. ..$ suffix: chr ".png"
.. ..$ primary : logi TRUE
..$ :'data.frame': 1 obs. of 6 variables:
.. ..$ id : chr "4bf58dd8d48988d1fe931735"
.. ..$ name : chr "Bus Station"
.. ..$ pluralName: chr "Bus Stations"
.. ..$ shortName : chr "Bus Station"
.. ..$ icon :'data.frame': 1 obs. of 2 variables:
.. .. ..$ prefix: chr "https://ss3.4sqi.net/img/categories_v2/travel/busstation_"
.. .. ..$ suffix: chr ".png"
.. ..$ primary : logi TRUE
..$ :'data.frame': 1 obs. of 6 variables:
특정 요소에 대해 이러한 데이터 프레임을 제거하여 기존 파일에 결합 할 수 있도록 노력하고 있습니다. 궁극적으로 최종 결과가 다음과 같기를 바랍니다.
$id $name
4bf58dd8d48988d129951735 train station
4bf58dd8d48988d1fe931735 bus station
기타
감사!
큰 목록이라고 가정합니다 mylist
. 그런 다음 mylist[[1]]
관련 열을 반복 하고 추출 할 수 있습니다 .
do.call(rbind, lapply(mylist[[1]], `[`, c("id", "name")))
또는 다음에서 rbind.pages
함수를 사용하십시오 jsonlite
.
jsonlite::rbind.pages(mylist[[1]])[c("id", "name")]
둘 다 당신에게 줄 것입니다
# id name
# 1 4bf58dd8d48988d129951735 Train Station
# 2 4bf58dd8d48988d1fe931735 Bus Station
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다