Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
408 views
in Technique[技术] by (71.8m points)

conditional statements - Conditionally predicting daily amount of observations from individual dates (depending on rainfall) in R

I have a data frame like this called "fulldata" with over 12000 observations:

    Station_id       Date          Prec_daily

       44         2019-04-30        0.5
      172         2019-05-21        0.0
       82         2019-04-30        2.3
       44         2019-05-07        4.7
      250         2019-05-21        0.0
       45         2019-05-02        NA
      890         2019-04-30        0.5
       82         2019-05-14        5.2
      250         2019-05-07        NA

(Station_id = integer, Date = POSIXct, Prec_daily = numeric)

Station_id's stand for different weather stations across a country. The variable precipitation_daily shows the daily amount of rainfall on the given date at the given station. The dates are days on which a voluntary nature observation was submitted to a platform by a participant of the project. My goal is being able to make a prediction like "When I have precipitation of 1.5 in one day, there will be an estimated amount of XX observations that day (across the country)."

How can I do this in R? I think I need a new data frame or variable that calculates the average amount of total observations across the country for every amount of rainfall in a day.

I really struggle with that right now. So far my analysis contains a histogram of the df above and the mean of the Prec_daily variable. I also managed to make a new data frame in which the total frequency for every amount of rainfall is counted. For that I used the following code.

    PrecClean <- fulldata$Prec_daily[!is.na(fulldata$Prec_daily)]
    hist(PrecClean, xlim = c(0,10), ylim = c(0, 11000))
    box()
    mean(PrecClean)

    Precfreq <- count(fulldata, vars = "Prec_daily")

But that doesn't help me determining the estimated DAILY amount of observations for each precipitation level...

Thanks a lot in advance for any advice!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...