JSON practice (1)
JSON is built on two structures: objects and arrays. To help you experiment with these, two JSON strings are included in the sample code. It's up to you to change them appropriately and then call jsonlite's fromJSON() function on them each time.
Bu egzersiz
Intermediate Importing Data in R
kursunun bir parçasıdırEgzersiz talimatları
- Change the assignment of
json1such that the R vector after conversion contains the numbers 1 up to 6, in ascending order. Next, callfromJSON()onjson1. - Adapt the code for
json2such that it's converted to a named list with two elements:a, containing the numbers 1, 2 and 3 andb, containing the numbers 4, 5 and 6. Next, callfromJSON()onjson2.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# jsonlite is already loaded
# Challenge 1
json1 <- '[1, 2, 4, 6]'
# Challenge 2
json2 <- '{"a": [1, 2, 3]}'