作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
screenshot of data
大家好,
我发现很难解释我的问题,但我们开始吧:
我有一个拥有约 200 人工作经验的数据集。每个人的行数与他们工作过的职位一样多。我基本上需要做的是,以某种方式计算:
> dput(head(Dataset))
structure(list(DirectorName = c("Alan Baldwin", "Alan Baldwin",
"Alan Baldwin", "Alan Baldwin", "Alan Baldwin", "Alan Baldwin"
), CompanyName = c("Argosy International Inc", "Argosy International Inc",
"CopperGlass Optical Solutions Inc", "INTEGRAL SYSTEMS INC (De-listed 07/2011)",
"INTEGRAL SYSTEMS INC (De-listed 07/2011)", "INTEGRAL SYSTEMS INC (De-listed 07/2011)"
), BrdPosition = c("No", "No", "No", "Yes", "Yes", "Yes"), RoleName = c("Consultant",
"President/COO", "CEO", "Director - SD", "Independent Director",
"Interim CEO"), DirectorID = c(510403, 510403, 510403, 510403,
510403, 510403), CompanyID = c(1096955, 1096955, 733243, 16206,
16206, 16206), DateStartRole = structure(c(1149120000, 1114905600,
962409600, 1228867200, 1165363200, 1180483200), tzone = "UTC", class = c("POSIXct",
"POSIXt")), DateEndRole = structure(c(1165363200, 1146441600,
988675200, 1311724800, 1180483200, 1194912000), tzone = "UTC", class = c("POSIXct",
"POSIXt")), Sector = c(NA, NA, NA, "Software & Computer Services",
"Software & Computer Services", "Software & Computer Services"
)), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
))
最佳答案
使用 dplyr
你可以到达那里:
library(dplyr)
df %>%
group_by(DirectorID) %>%
summarize( nCompanies = NROW(unique(CompanyID)),
nSectors = NROW(unique(Sector)),
CEOexperience = any(grepl("CEO", RoleName)))
这不包括在给定日期之前只有 CEO 经验的要求,我认为我们需要更多信息才能将其纳入。
关于r - 在 R 或 Excel 中计算多行中不同定性值的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66886388/
我是一名优秀的程序员,十分优秀!