Hello!
I have a set of 12 dataframes that I want to compile into a list so that I can iterate each dataframe through a function via a loop.
Here is the function:
f <- function(siteyear){
siteyear %>% select(Date, X_00060_00003) %>% rename(Discharge_cfs = X_00060_00003)
}
Here's an example of how I've tried to store that data as a list:
dfs <- as.list(gra15, stj05, stj10)
But the resulting output doesn't give me the full list of dataframes. Maybe a list isn't what I need, but I need to store these dataframes into some sort of item that allows me to pass it through the above function.
Here are some of the dataframes (scaled way down):
gra15 <- structure(list(agency_cd = c("USGS", "USGS", "USGS", "USGS",
"USGS", "USGS"), site_no = c("04119400", "04119400", "04119400",
"04119400", "04119400", "04119400"), Date = structure(c(16436,
16437, 16438, 16439, 16440, 16441), class = "Date"), X_00060_00003 = c(4800,
4570, 4650, 4790, 4610, 3860), X_00060_00003_cd = c("A e", "A",
"A e", "A e", "A e", "A e")), url = "https://waterservices.usgs.gov/nwis/dv/?site=04119400&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2015-01-01&endDT=2015-12-31", siteInfo = structure(list(
station_nm = "GRAND RIVER NEAR EASTMANVILLE, MI", site_no = "04119400",
agency_cd = "USGS", timeZoneOffset = "-05:00", timeZoneAbbreviation = "EST",
dec_lat_va = 43.0241884, dec_lon_va = -86.0264354, srs = "EPSG:4326",
siteTypeCd = "ST", hucCd = "04050006", stateCd = "26", countyCd = "26139",
network = "NWIS"), row.names = c(NA, -1L), class = "data.frame"), variableInfo = structure(list(
variableCode = "00060", variableName = "Streamflow, ft³/s",
variableDescription = "Discharge, cubic feet per second",
valueType = "Derived Value", unit = "ft3/s", options = "Mean",
noDataValue = NA), row.names = c(NA, -1L), class = "data.frame"), disclaimer = "Provisional data are subject to revision. Go to http://waterdata.usgs.gov/nwis/help/?provisional for more information.", statisticInfo = structure(list(
statisticCd = "00003", statisticName = "Mean"), class = "data.frame", row.names = c(NA,
-1L)), queryTime = structure(1631203394.95933, class = c("POSIXct",
"POSIXt")), row.names = c(NA, 6L), class = "data.frame")
>
stj05 <- structure(list(agency_cd = c("USGS", "USGS", "USGS", "USGS",
"USGS", "USGS"), site_no = c("04101500", "04101500", "04101500",
"04101500", "04101500", "04101500"), Date = structure(c(12784,
12785, 12786, 12787, 12788, 12789), class = "Date"), X_00060_00003 = c(4330,
4100, 4480, 5570, 5760, 5520), X_00060_00003_cd = c("A", "A",
"A", "A", "A", "A")), url = "https://waterservices.usgs.gov/nwis/dv/?site=04101500&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2005-01-01&endDT=2005-12-31", siteInfo = structure(list(
station_nm = "ST. JOSEPH RIVER AT NILES, MI", site_no = "04101500",
agency_cd = "USGS", timeZoneOffset = "-05:00", timeZoneAbbreviation = "EST",
dec_lat_va = 41.8292138, dec_lon_va = -86.2597325, srs = "EPSG:4326",
siteTypeCd = "ST", hucCd = "04050001", stateCd = "26", countyCd = "26021",
network = "NWIS"), row.names = c(NA, -1L), class = "data.frame"), variableInfo = structure(list(
variableCode = "00060", variableName = "Streamflow, ft³/s",
variableDescription = "Discharge, cubic feet per second",
valueType = "Derived Value", unit = "ft3/s", options = "Mean",
noDataValue = NA), row.names = c(NA, -1L), class = "data.frame"), disclaimer = "Provisional data are subject to revision. Go to http://waterdata.usgs.gov/nwis/help/?provisional for more information.", statisticInfo = structure(list(
statisticCd = "00003", statisticName = "Mean"), class = "data.frame", row.names = c(NA,
-1L)), queryTime = structure(1631201435.34722, class = c("POSIXct",
"POSIXt")), row.names = c(NA, 6L), class = "data.frame")
stj10 <- structure(list(agency_cd = c("USGS", "USGS", "USGS", "USGS",
"USGS", "USGS"), site_no = c("04101500", "04101500", "04101500",
"04101500", "04101500", "04101500"), Date = structure(c(14610,
14611, 14612, 14613, 14614, 14615), class = "Date"), X_00060_00003 = c(4500,
4270, 3670, 3900, 4000, 4180), X_00060_00003_cd = c("A", "A",
"A", "A", "A", "A")), url = "https://waterservices.usgs.gov/nwis/dv/?site=04101500&format=waterml,1.1&ParameterCd=00060&StatCd=00003&startDT=2010-01-01&endDT=2010-12-31", siteInfo = structure(list(
station_nm = "ST. JOSEPH RIVER AT NILES, MI", site_no = "04101500",
agency_cd = "USGS", timeZoneOffset = "-05:00", timeZoneAbbreviation = "EST",
dec_lat_va = 41.8292138, dec_lon_va = -86.2597325, srs = "EPSG:4326",
siteTypeCd = "ST", hucCd = "04050001", stateCd = "26", countyCd = "26021",
network = "NWIS"), row.names = c(NA, -1L), class = "data.frame"), variableInfo = structure(list(
variableCode = "00060", variableName = "Streamflow, ft³/s",
variableDescription = "Discharge, cubic feet per second",
valueType = "Derived Value", unit = "ft3/s", options = "Mean",
noDataValue = NA), row.names = c(NA, -1L), class = "data.frame"), disclaimer = "Provisional data are subject to revision. Go to http://waterdata.usgs.gov/nwis/help/?provisional for more information.", statisticInfo = structure(list(
statisticCd = "00003", statisticName = "Mean"), class = "data.frame", row.names = c(NA,
-1L)), queryTime = structure(1631201470.81118, class = c("POSIXct",
"POSIXt")), row.names = c(NA, 6L), class = "data.frame")
Any help would be so greatly appreciated! Thanks so much!