- API数据输出**
arthor_uuid rank score smiles compound identifier
1 c8975496-4cb7-5fa6-a181-4044f1478eef 0 1.000 c1cc2cc(c(nc2c(c1)Cl)c3ccc[n+](c3)[O-])[C@@H](C(F)(F)F)Nc4c5c(cccn5)ncn4 AC000005306130
2 7b5b0d02-9b98-53dc-8366-08cb05f624bb 1 1.000 c1cc2cc(c(nc2c(c1)Cl)c3ccc[n+](c3)[O-])[C@H](C(F)(F)F)Nc4c5c(cccn5)ncn4 AC000005306132
vendor entries
1 GOSTAR, InChI, 3610820, LNLJHGXOFYUARS-NRFANRHFSA-N, false, false, 29-SEP-2022 10:39:33 +01:00, 29-SEP-2022 10:39:33 +01:00, Virtual, Virtual, Commercial, Commercial
2 GOSTAR, InChI, 3610727, LNLJHGXOFYUARS-OAQYLSRUSA-N, false, false, 29-SEP-2022 10:39:33 +01:00, 29-SEP-2022 10:39:33 +01:00, Virtual, Virtual, Commercial, Commercial
我想在一个数据表中显示所有数据-包括"供应商条目"数据子集。显示"[object Object],[object Object]"而不是"供应商条目"数据。
如果在数据表中获取"供应商条目"数据很复杂,我至少想知道如何从供应商条目列中获取"LNLJHGXOFYUARS-NRFANRHFSA-N"和"LNLJHGXOFYUARS-OAQYLSRUSA-N"值。
我试过:
- 第一次尝试**
filtered_data <- as.matrix(unlist(data["vendor entries"]))
结果:
[,1]
vendor entries.vendor name1 "GOSTAR"
vendor entries.vendor name2 "InChI"
vendor entries.vendors identifier1 "3610820"
vendor entries.vendors identifier2 "LNLJHGXOFYUARS-NRFANRHFSA-N"
vendor entries.discontinued1 "false"
vendor entries.discontinued2 "false"
vendor entries.timestamp1 "29-SEP-2022 10:39:33 +01:00"
vendor entries.timestamp2 "29-SEP-2022 10:39:33 +01:00"
vendor entries.source labels1 "Virtual"
vendor entries.source labels2 "Virtual"
vendor entries.compound categories1 "Commercial"
vendor entries.compound categories2 "Commercial"
vendor entries.vendor name1 "GOSTAR"
vendor entries.vendor name2 "InChI"
vendor entries.vendors identifier1 "3610727"
vendor entries.vendors identifier2 "LNLJHGXOFYUARS-OAQYLSRUSA-N"
vendor entries.discontinued1 "false"
vendor entries.discontinued2 "false"
vendor entries.timestamp1 "29-SEP-2022 10:39:33 +01:00"
vendor entries.timestamp2 "29-SEP-2022 10:39:33 +01:00"
vendor entries.source labels1 "Virtual"
vendor entries.source labels2 "Virtual"
vendor entries.compound categories1 "Commercial"
vendor entries.compound categories2 "Commercial"
那么
filtered_data["vendor entries.vendors identifier2"]
但是,只显示了"供应商条目.供应商标识符2"的第一个值。缺少第二个值。是否有方法从"供应商条目.供应商标识符2"行中获取所有值?
- 尝试2**
api_json <- jsonlite::toJSON(structure_data, pretty = TRUE)
结果
[
{
"arthor_uuid": "c8975496-4cb7-5fa6-a181-4044f1478eef",
"rank": 0,
"score": "1.000",
"smiles": "c1cc2cc(c(nc2c(c1)Cl)c3ccc[n+](c3)[O-])[C@@H](C(F)(F)F)Nc4c5c(cccn5)ncn4",
"compound identifier": "AC000005306130",
"vendor entries": [
{
"vendor name": "GOSTAR",
"vendors identifier": "3610820",
"discontinued": "false",
"timestamp": "29-SEP-2022 10:39:33 +01:00",
"source labels": ["Virtual"],
"compound categories": ["Commercial"]
},
{
"vendor name": "InChI",
"vendors identifier": "LNLJHGXOFYUARS-NRFANRHFSA-N",
"discontinued": "false",
"timestamp": "29-SEP-2022 10:39:33 +01:00",
"source labels": ["Virtual"],
"compound categories": ["Commercial"]
}
]
},
{
"arthor_uuid": "7b5b0d02-9b98-53dc-8366-08cb05f624bb",
"rank": 1,
"score": "1.000",
"smiles": "c1cc2cc(c(nc2c(c1)Cl)c3ccc[n+](c3)[O-])[C@H](C(F)(F)F)Nc4c5c(cccn5)ncn4",
"compound identifier": "AC000005306132",
"vendor entries": [
{
"vendor name": "GOSTAR",
"vendors identifier": "3610727",
"discontinued": "false",
"timestamp": "29-SEP-2022 10:39:33 +01:00",
"source labels": ["Virtual"],
"compound categories": ["Commercial"]
},
{
"vendor name": "InChI",
"vendors identifier": "LNLJHGXOFYUARS-OAQYLSRUSA-N",
"discontinued": "false",
"timestamp": "29-SEP-2022 10:39:33 +01:00",
"source labels": ["Virtual"],
"compound categories": ["Commercial"]
}
]
}
]
1条答案
按热度按时间x8diyxa71#
下面是您所追求的示例:
这会将列表元素展开为如下所示:
要了解更多信息,您应该查看R4DS中关于矩形化的新章节:https://r4ds.hadley.nz/rectangling.html