Home > Enterprise >  Removing rows that contain "x" in column by a specific date
Removing rows that contain "x" in column by a specific date

Time:01-06

I'm working wither temperature and snow melt. I have some issues with removing specific ID values by e specific date. Here is a part of my Date. Frame:

enter image description here

I have calculated the onset of snowmelt and need to remove all dates before the first date of snowmelt at each location. The mean onset of snowmelt in the three locations is Top - 07.05.2021, Middle- 14.05.2021, and Bottom - 21.05.21

After some R-codes I would like to get this DataFrame: enter image description here

I did running this R-code:

df1 <- climate_2021 %>% group_by(Location) %>%filter(Date >= "2021.05.21" & Location == "Bottom" | Date >= "2021.05.14" & Location == "Middle" | Date >= "2021.05.07" & Location == "Top")

Then I get, an error in the date, comparison (<=) is possible only for atomic and list types.

What can I do to figure this out?

CodePudding user response:

Your code doesn't throw an error for me. But, I can't see how the data from your excel screenshot looks once you've loaded it up in R. It might be helpful if you can post info about climate_2021 -- the output from str(climate_2021) is probably a good start!

CodePudding user response:

I enter the str(climate_2021) in R and get this

enter image description here

  • Related