小编chr*_*456的帖子

Find the minimum date between two maximum dates based off unique values in a column

Data example.

date1 = seq(as.Date("2019/01/01"), by = "month", length.out = 29)
date2= seq(as.Date("2019/05/01"), by = "month", length.out = 29)

subproducts1=rep("1",29)
subproducts2=rep("2",29)

b1 <- c(rnorm(29,5))
b2 <- c(rnorm(29,5))

dfone <- data.frame("date"= c(date1,date2),
                "subproduct"= 
                  c(subproducts1,subproducts2),
                "actuals"= c(b1,b2))
Run Code Online (Sandbox Code Playgroud)

Max Date for Subproduct 1 is May 2021 and max date for Subproduct 2 is Sept 2021.

Question: Is there a way to:

  1. Find the max date for both unique subproduct and
  2. Find the minimum date from the two max dates all in one step? …

r data-manipulation dataframe dplyr

4
推荐指数
3
解决办法
95
查看次数

标签 统计

data-manipulation ×1

dataframe ×1

dplyr ×1

r ×1