@RestController
public class ABC {
private static final Logger logger = LoggerFactory.getLogger(ABC.class);
private static volatile byte[] abc = null;
static volatile boolean xyz = "true"
// Multithreaded program where multiple threads read and write
both 'abc' and 'xyz'
但是我想保留a <- c(rep("A", 3), rep("B", 3), rep("C",2))
b <- c(1,1,2,4,1,1,2,2)
df <- data.frame(a,b)
,b
和"A"
的最高"B"
值。
所以我的新df只有3行。谢谢!!!
答案 0 :(得分:1)
使用dplyr
很简单:我们仅将a
和summarize
的值按max
分组(对于每个组):b
的{{1}}值:
library(dplyr)
df %>%
group_by(a) %>%
summarize(b = max(b))
a b
<fct> <dbl>
1 A 2
2 B 4
3 C 2
答案 1 :(得分:0)
按a分组,最多取b
df%>%
group_by(a)%>%
summarise(max(b))