0

I have dataset in json format. When I pull this data to a variable in R using jsonlite::fromJson, a list is created. This list further contains another list, which in turn contains another list and final list has other objects.

How do I make a dataframe out of this data?

Sample dataset:

{
    "AG2": {
        "-KB89nmaAHtjvIHl6X6I": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 0,
            "score": 20,
            "timeBonus": 95,
            "timestamp": "Mon Feb 22 2016 18:59:17 GMT+0530 (India Standard Time)",
            "totalScore": 20
        },
        "-KB89q8EJ-rYvjzVcIiQ": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 1,
            "score": 39,
            "timeBonus": 93,
            "timestamp": "Mon Feb 22 2016 18:59:27 GMT+0530 (India Standard Time)",
            "totalScore": 59
        },
        "-KB89s7SVjq0YZQ5XrOt": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 2,
            "score": 59,
            "timeBonus": 95,
            "timestamp": "Mon Feb 22 2016 18:59:35 GMT+0530 (India Standard Time)",
            "totalScore": 118
        },
        "-KB89xsifcqbxCDE9Ygt": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 3,
            "score": 78,
            "timeBonus": 93,
            "timestamp": "Mon Feb 22 2016 18:59:59 GMT+0530 (India Standard Time)",
            "totalScore": 196
        },
        "-KB8A-85L2P9nGmii3L_": {
            "attempts": 1,
            "isCorrect": "The output value should be your name",
            "questionIndex": 4,
            "score": 0,
            "timeBonus": 95,
            "timestamp": "Mon Feb 22 2016 19:00:08 GMT+0530 (India Standard Time)",
            "totalScore": 196
        },
        "-KB8A1JTmwee2a5gRkLq": {
            "attempts": 1,
            "isCorrect": true,
            "questionIndex": 4,
            "score": 85,
            "timeBonus": 87,
            "timestamp": "Mon Feb 22 2016 19:00:17 GMT+0530 (India Standard Time)",
            "totalScore": 281
        }
    },
    "AKD": {
        "-KB88bypMqEu3Y2zOEKD": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 0,
            "score": 19,
            "timeBonus": 90,
            "timestamp": "Mon Feb 22 2016 18:54:07 GMT+0530 (India Standard Time)",
            "totalScore": 19
        },
        "-KB88grpZUs3j3J4SNWc": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 1,
            "score": 37,
            "timeBonus": 85,
            "timestamp": "Mon Feb 22 2016 18:54:27 GMT+0530 (India Standard Time)",
            "totalScore": 56
        },
        "-KB88jYngOMf7chyXUch": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 2,
            "score": 58,
            "timeBonus": 91,
            "timestamp": "Mon Feb 22 2016 18:54:38 GMT+0530 (India Standard Time)",
            "totalScore": 114
        },
        "-KB88mtpsbwp6GD4VQ0f": {
            "attempts": 0,
            "isCorrect": true,
            "questionIndex": 3,
            "score": 76,
            "timeBonus": 89,
            "timestamp": "Mon Feb 22 2016 18:54:52 GMT+0530 (India Standard Time)",
            "totalScore": 190
        },
        "-KB88z1nL0Ckhn5A5Lsq": {
            "attempts": 1,
            "isCorrect": "The output value should be your name",
            "questionIndex": 4,
            "score": 0,
            "timeBonus": 60,
            "timestamp": "Mon Feb 22 2016 18:55:41 GMT+0530 (India Standard Time)",
            "totalScore": 190
        }
    }
}

Required dataframe:

User | TimeStamp | Question Index | Attempts | TimeBonus | isCorrect | Score | Total

Thanks.

alistaire
  • 42,459
  • 4
  • 77
  • 117

0 Answers0