Here's what the OP says worked for them, even though it is not reproducible:
fredTable <-
structure(list(Symbol = structure(c(3L, 1L, 4L, 2L, 5L),
.Label = c("CASACBM027SBOG", "FRPACBW027SBOG", "TLAACBM027SBOG", "TOTBKCR",
"USNIM"), class = "factor"), Name = structure(1:5, .Label = c("bankAssets",
"bankCash", "bankCredWk", "bankFFRRPWk", "bankIntMargQtr"), class = "factor"),
Category = structure(c(1L, 1L, 1L, 1L, 1L), .Label = "Banks", class = "factor"),
Country = structure(c(1L, 1L, 1L, 1L, 1L), .Label = "USA", class = "factor"),
Lead = structure(c(1L, 1L, 3L, 3L, 2L), .Label = c("Monthly", "Quarterly",
"Weekly"), class = "factor"), Freq = structure(c(2L, 1L, 3L, 3L, 4L),
.Label = c("1947-01-01", "1973-01-01", "1973-01-03", "1984-01-01"),
class = "factor"), Start = structure(c(1L, 1L, 1L, 1L, 1L), .Label = "Current",
class = "factor"), End = c(TRUE, TRUE, TRUE, TRUE, FALSE), SeasAdj = c(FALSE,
FALSE, FALSE, FALSE, TRUE), Percent = structure(c(1L, 1L, 1L, 1L, 1L),
.Label = "Fed", class = "factor"), Source = structure(c(1L, 1L, 1L, 1L, 1L),
.Label = "Res", class = "factor"), Series = structure(c(1L, 1L, 1L, 1L, 2L),
.Label = c("Level", "Ratio"), class = "factor")), .Names = c("Symbol", "Name",
"Category", "Country", "Lead", "Freq", "Start", "End", "SeasAdj", "Percent",
"Source", "Series"), class = "data.frame",
row.names = c("1", "2", "3", "4", "5"))
fredNamesOrig <- fredTable$Name # original downloaded FRED object names
fredObjOrig <- mget(fredNamesOrig) # list of original FRED objects
fredNamesTrans <- fredNamesOrig # pre-allocate list of transformed objects
# Strip off period string ("Day", "Qtr")
for(i in 1:length(fredNamesOrig)){
if(grepl("Day",fredNamesOrig[i]))
fredNamesTrans[i] <- sub("Day","",fredNamesOrig[i])
else if(grepl("Qtr",fredNamesOrig[i]))
fredNamesTrans[i] <- sub("Qtr","",fredNamesOrig[i])
}
# Assign transformed series back to appropriately names series:
for(i in 1:length(fredObjOrig)){
colnames(fredObjOrig[[i]]) <- fredNamesTrans[i]
assign(fredNamesTrans[i],fredObjOrig[[i]])
}
lst <- mget(Names);lapply(names(lst), function(x) {x1 <- lst[[x]]; colnames(x1) <- x; x1 })
– akrunmget
is fairly high level R, even is it seems obvious to us. – IRTFM