使用R中的嵌套列表

时间:2016-03-16 06:13:07

标签: json r nested nested-lists

我有json格式的数据集。当我使用jsonlite::fromJson将此数据提取到R中的变量时,会创建一个列表。此列表还包含另一个列表,该列表又包含另一个列表,最终列表包含其他对象。

如何从这些数据中创建数据框?

示例数据集:

{
    "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
        }
    }
}

必填数据框:

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

感谢。

0 个答案:

没有答案