Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

R und json-Dateien

1 view
Skip to first unread message

Patrick Rudin

unread,
Mar 21, 2022, 1:54:03 PM3/21/22
to
Ein neugieriger Versuch, ob die Gruppe wirklich tot ist oder ob im
deutschsprachigen Usenet tatsächlich Leute R benutzen...

Gegeben sei diese JSON-File:
https://www.bfs.admin.ch/bfs/de/home/statistiken/politik/abstimmungen/jahr-2022/2022-02-13.assetdetail.21364129.html

Sowas ist eigentlich zur maschinenlesbaren Auswertung gedacht, dennoch
nimmt man dafür offensichtlich hierarchische Formate, damit sie für
menschen gut lesbar sind. Jedenfalls ist das "schlankmachen" (im Sinne
von tidy data) relativ aufwändig.

Es gibt das relativ neue Paket "tidyjson", das beim "Aufklappen" mithilft:
https://github.com/colearendt/tidyjson
https://cran.r-project.org/web/packages/tidyjson/vignettes/introduction-to-tidyjson.html

Wirklich weit komme ich damit aber nicht:

abstimmungen %>% gather_object %>% json_types %>% count (name, type)
# A tibble: 4 x 3
name type n
<chr> <fct> <int>
1 abstimmtag string 1
2 schweiz object 1
3 spatial_reference array 1
4 timestamp string 1

abstimmungen %>% json_structure
# A tibble: 122,014 x 10
..JSON document.id parent.id level index child.id seq name
type length
<chr> <int> <chr> <int> <int> <chr> <lis> <chr>
<fct> <int>
1 "{\"abs… 1 NA 0 1 1 <lis… NA
obje… 4
2 "\"2022… 1 1 1 1 1.1 <lis… absti…
stri… 1
3 "\"2022… 1 1 1 2 1.2 <lis… times…
stri… 1
4 "[{\"sp… 1 1 1 3 1.3 <lis… spati…
array 3
5 "{\"geo… 1 1 1 4 1.4 <lis… schwe…
obje… 4
6 "0" 1 1.4 2 1 1.4.1 <lis… geoLe…
numb… 1
7 "\"Schw… 1 1.4 2 2 1.4.2 <lis… geoLe…
stri… 1
8 "false" 1 1.4 2 3 1.4.3 <lis… nochK…
logi… 1
9 "[{\"vo… 1 1.4 2 4 1.4.4 <lis… vorla…
array 4
10 "{\"spa… 1 1.3 2 1 1.3.1 <lis… NA
obje… 2
# … with 122,004 more rows

Kurzum: Mir ist ziemlich rätselhaft, wie ich da vorgehen könnte.
Irgendwelche Tidyjson-Profis hier?


Grüsse

Patrick
0 new messages