У меня есть три подобные таблицы, в которых есть ключ и поле, описывающее случайные данные этого конкретного ключа:
> json1
key field
1 hg8oxoi4 "components":{"a": "21","b": "12","c": "34"}
2 gic3bv14 "components":{"a": "78","b": "66","c": "54"}
3 yo47wglq "components":{"a": "6","b": "12","c": "12"}
4 vibidd0l "components":{"a": "45","b": "5","c": "1"}
> json2
key field
1 hg8oxoi4 "last_recall": {"date": "012118","size": "43"}
2 vibidd0l "last_recall": {"date": "101618","size": "12"}
> json3
key field
1 hg8oxoi4 "other_fields":{"people": "11"}
2 gic3bv14 "other_fields":{"people": "10"}
3 yo47wglq "other_fields":{"people": "4"}
Каков наилучший способ объединить все три таблицы в одну, убедившись, что все ключи сопоставлены друг с другом и учтены различия в том, какие ключи имеют данные, а какие нет? В идеале каждое поле должно быть добавлено к другому, чтобы столбец поля новой таблицы представлял собой объект json с другими данными.
Редактировать: вот ожидаемый результат.
> json4
key
1 hg8oxoi4
2 gic3bv14
3 yo47wglq
4 vibidd0l
field
1 {"components":{"a": "21","b": "12","c": "34"},"last_recall": {"date": "012118","size": "43"},"other_fields":{"people": "11"}}
2 {"components":{"a": "78","b": "66","c": "54"},"other_fields":{"people": "10"}}
3 {"components":{"a": "6","b": "12","c": "12"},"other_fields":{"people": "4"}}
4 {"components":{"a": "45","b": "5","c": "1"},"last_recall": {"date": "101618","size": "12"}}
РЕДАКТИРОВАТЬ 2: dput json1 и json2
> dput(json1)
structure(list(key = c("hg8oxoi4", "gic3bv14", "yo47wglq", "vibidd0l"
), field = c("\"components\":{\"a\": \"21\",\"b\": \"12\",\"c\": \"34\"}",
"\"components\":{\"a\": \"78\",\"b\": \"66\",\"c\": \"54\"}",
"\"components\":{\"a\": \"6\",\"b\": \"12\",\"c\": \"12\"}",
"\"components\":{\"a\": \"45\",\"b\": \"5\",\"c\": \"1\"}")), .Names = c("key",
"field"), row.names = c(NA, -4L), class = "data.frame")
> dput(json2)
structure(list(key = c("hg8oxoi4", "vibidd0l"), field = c("\"last_recall\": {\"date\": \"012118\",\"size\": \"43\"}",
"\"last_recall\": {\"date\": \"101618\",\"size\": \"12\"}")), .Names = c("key",
"field"), row.names = c(NA, -2L), class = "data.frame")