-1
我有像下面這樣的數據框,我需要對特定列進行分組並創建按列值列的新列表。R-如何分組特定的列值並創建新的列值列表動態
我的數據幀
Domain Process Name value1 value2
ML First Peter T1 45
ML First Peter FT 34
ML First Peter T1 34
ML First Jhon LL 11
ML First Jhon LL 11
ML Second Peter IO 22
ML Second Peter IO 33
ML Second Peter IO 33
ML four Peter IO 33
我預期的數據幀。
Domain Process Name column listofvalues
ML First Peter value1 list(info1 = "T1", "Count"="2",list(info2 = "FT", "Count"="1"))
ML First Peter value2 list(info1 = "45", "Count"="1",list(info2 ="34", "Count"="2"))
ML First Jhon value1 list(info1 = "LL", "Count"="2")
ML First Jhon value2 list(info1 = "11", "Count"="2")
ML Second Peter value1 list(info1 = "IO", "Count"="3")
ML Second Peter value2 list(info1 = "22", "Count"="1",list(info2 ="33", "Count"="2"))
ML four Peter value1 list(info1 = "IO", "Count"="1")
ML
dput數據。
structure(list(Domain = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L), .Label = "ML", class = "factor"), Process = structure(c(1L,
1L, 1L, 1L, 1L, 3L, 3L, 3L, 2L), .Label = c("First", "four",
"Second"), class = "factor"), Name = structure(c(2L, 2L, 2L,
1L, 1L, 2L, 2L, 2L, 2L), .Label = c("Jhon", "Peter"), class = "factor"),
value1 = structure(c(4L, 1L, 4L, 3L, 3L, 2L, 2L, 2L, 2L), .Label = c("FT",
"IO", "LL", "T1"), class = "factor"), value2 = structure(c(5L,
4L, 4L, 1L, 1L, 2L, 3L, 3L, 3L), .Label = c("11", "22", "33",
"34", "45"), class = "factor")), .Names = c("Domain", "Process",
"Name", "value1", "value2"), row.names = c(NA, -9L), class = "data.frame")
,謝謝你的反應,它的工作如我所料。 –
,我還有一個疑問,請幫助我如何計算分數反而算。 –