Hi I have the following code with me which I am writing in R to create a dataframe
library(lubridate)
library(tibble)
library(aimsir17)
library(dplyr)
library(ggplot2)
my_obs <- subset(observations,
station %in% c("DUBLIN AIRPORT","MACE HEAD","SherkinIsland","BELMULLET"))
now after creating my_obs dataframe i want to manipulate it using functions to access only specific by passing 4 parameter like following-
get_daily_summary <- function(dayNo, stat, attribute, f){
}
The function can access my_obs from the global workspace
• It takes in 4 params
– dayNo (1-365)
– stat ("DUBLIN AIRPORT","MACE HEAD","SherkinIsland","BELMULLET")
– attribute (”rain”, “temp”, “msl”, “wdsp”)
– f (a function) – (min, max, mean, sum)
• This function “collapses” 24 daily observations for a given station on a
particular day number to one summary value calculated by f.
but I am not sure how what to write under those curly brackets to access specific fields of data-frame as I am very new to R. Can somebody please tell me how to write functions to access specific fields mentioned above.