如何在R语言中将字符向量转换为命名字符向量列表?
将R语言字符向量转换为命名字符向量列表
需要把以下R语言字符向量转换为命名字符向量列表,转换完成后可轻松将其转为命名数据框列表。
原始字符向量
c( "Colon and Rectal Surgery", "Colon and Rectal Surgery|78|110|82|49|61|79|74.4|96.3|783|1,108|3", "Internal Medicine", "Cardiovascular Disease|497|1,119|729|168|425|719|58.3|98.6|3,862|6,152|7", "Endocrinology, Diabetes, and Metabolism|118|364|233|115|102|218|43.8|93.6|591|1,499|12", "Gastroenterology|320|655|383|157|251|362|65.5 94.5|2,256|3,250|15", "Hematology|53|128|21|5|11|21|52.4 100.0|58|146|0", "Hematology and Oncology|296|741|458|124|238|450|52.0 98.3|1,656|3,511|5", "Infectious Disease|130|314|314|128|124|267|39.5 85.0|674|1,770|35", "Nephrology|97|510|380|146|92|345|24.2 90.8|494|2,707|24", "Oncology|47|168|37|12|9|33|24.3 89.2|56|224|2", "Pulmonary Disease|2|72|21|11|1|20|4.8 95.2|2|118|1", "Pulmonary Disease and Critical Care Medicine|216|616|417|122|190|404|45.6 96.9|1,099|2,963|7", "Rheumatology|89|225|184|102|80|163|43.5|88.6|521|1,162|17", "Medical Genetics", "Medical Genetics|12|23|53|36|8|15|15.1|28.3|44|99|28" )
转换后的命名字符向量列表
list( "Colon and Rectal Surgery" = "Colon and Rectal Surgery|78|110|82|49|61|79|74.4|96.3|783|1,108|3", "Internal Medicine" = c( "Cardiovascular Disease|497|1,119|729|168|425|719|58.3|98.6|3,862|6,152|7", "Endocrinology, Diabetes, and Metabolism|118|364|233|115|102|218|43.8|93.6|591|1,499|12", "Gastroenterology|320|655|383|157|251|362|65.5 94.5|2,256|3,250|15", "Hematology|53|128|21|5|11|21|52.4 100.0|58|146|0", "Hematology and Oncology|296|741|458|124|238|450|52.0 98.3|1,656|3,511|5", "Infectious Disease|130|314|314|128|124|267|39.5 85.0|674|1,770|35", "Nephrology|97|510|380|146|92|345|24.2 90.8|494|2,707|24", "Oncology|47|168|37|12|9|33|24.3 89.2|56|224|2", "Pulmonary Disease|2|72|21|11|1|20|4.8 95.2|2|118|1", "Pulmonary Disease and Critical Care Medicine|216|616|417|122|190|404|45.6|96.9|1,099|2,963|7", "Rheumatology|89|225|184|102|80|163|43.5|88.6|521|1,162|17" ), "Medical Genetics" = "Medical Genetics|12|23|53|36|8|15|15.1|28.3|44|99|28" )
内容的提问来源于stack exchange,提问作者Dylan Russell
相关产品推荐
相关产品推荐

