1
R新手在這裏,所以請原諒我的無知。我的數據是這樣的:計算一列中的分類值由另一列分組
JOB_ROLE EXP_IT_NETW
1 Software engineering-related (developer, tester, project manager, architecture) 5<10
3 See below None
4 Student <1
5 Software engineering-related (developer, tester, project manager, architecture) 1<5
6 Blogger 10+
我想通過柱1計算每個值的情況下,第2欄和組數,這樣的結果看起來是這樣的:
JOB_ROLE None <1 1<5 5<10 10+
Software engineer 3 5 10 15 3
Student 10 7 5 1 0
...
任何想法如何做到這一點?我的輸出輸出如下。提前致謝!
structure(list(JOB_ROLE = c("Software engineering-related (developer, tester, project manager, architecture)",
"See below", "Student", "Software engineering-related (developer, tester, project manager, architecture)",
"Blogger", "Systems Support", "Student", "IT/Network Administrator",
"Software engineering-related (developer, tester, project manager, architecture)",
"Student", "Student", "Software engineering-related (developer, tester, project manager, architecture)",
"IT hobbyist", "Student", "Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"IT Manager", "Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"IT/Network Administrator", "IT/Network Administrator", "Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"Student", "Software engineering-related (developer, tester, project manager, architecture)",
"Researcher in CompSci or related field", "Researcher in CompSci or related field",
"IT/Network Administrator", "Student", "Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"Education", "Software engineering-related (developer, tester, project manager, architecture)",
"Software engineering-related (developer, tester, project manager, architecture)",
"IT/Network Administrator", "Software engineering-related (developer, tester, project manager, architecture)",
"IT/Network Administrator", "Student", "IT/Network Administrator",
"Software engineering-related (developer, tester, project manager, architecture)",
"Student", "IT/Network Administrator", "just a layperson who has used computers for over 30 years",
"IT/Network Administrator", "Unemployed", "Student", "IT/Network Administrator"
), EXP_IT_NETW = c("5<10", "None", "<1", "1<5", "10+", "None",
"1<5", "10+", "<1", "None", "1<5", "1<5", "None", "None", "10+",
"None", "1<5", "10+", "None", "1<5", "None", "1<5", "10+", "1<5",
"1<5", "1<5", "None", "None", "1<5", "5<10", "None", "5<10",
"<1", "None", "1<5", "None", "1<5", "1<5", "10+", "1<5", "10+",
"None", "1<5", "5<10", "None", "1<5", "None", "1<5", "None",
"None", "10+")), .Names = c("JOB_ROLE", "EXP_IT_NETW"), class = "data.frame", row.names = c(1L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 25L, 26L, 27L, 28L, 29L, 30L, 32L, 33L,
34L, 35L, 36L, 37L, 39L, 40L, 41L, 42L, 43L, 44L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 55L, 56L, 57L, 59L, 61L, 62L))
當然,答案是如此簡單,它是正確的在我面前一直。謝謝。 – user2145843 2013-03-27 20:26:57
@Arun,使用這個:'as.data.frame(unclass(table(d)))' – 2013-03-27 20:52:04