经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- > manager <- c(1,2,3,4,5)
- > date <- c("10/24/08","10/28/08","10/1/08","10/12/08","5/1/09")
- > country <- c("US","US","UK","UK","UK")
- > gender <- c("M","F","F","M","F")
- > age <- c(32,45,25,39,99)
- > q1 <- c(5,3,3,3,2)
- > q2 <- c(4,5,5,3,2)
- > q3 <- c(5,2,5,4,1)
- > q4 <- c(5,5,5,NA,2)
- > q5 <- c(5,5,2,NA,1)
- > leadership <- data.frame(manager,date,country,gender,age,q1,q2,q3,q4,q5,stringsAsFactors = FALSE)
- > leadership$age[leadership$age == 99] <- NA
- > within(leadership,{
- + agecat <-NA
- + agecat[age > 75] <- "Elder"
- + agecat[age >= 55 & age <= 75] <- "Middle Aged"
- + agecat[age < 55] <- "Young"})
- manager date country gender age q1 q2 q3 q4 q5 agecat
- 1 1 10/24/08 US M 32 5 4 5 5 5 Young
- 2 2 10/28/08 US F 45 3 5 2 5 5 Young
- 3 3 10/1/08 UK F 25 3 5 5 5 2 Young
- 4 4 10/12/08 UK M 39 3 3 4 NA NA Young
- 5 5 5/1/09 UK F NA 2 2 1 2 1 <NA>
- > leadership
- manager date country gender age q1 q2 q3 q4 q5
- 1 1 10/24/08 US M 32 5 4 5 5 5
- 2 2 10/28/08 US F 45 3 5 2 5 5
- 3 3 10/1/08 UK F 25 3 5 5 5 2
- 4 4 10/12/08 UK M 39 3 3 4 NA NA
- 5 5 5/1/09 UK F NA 2 2 1 2 1
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|