I have code here: https://github.com/thistleknot/FredAPIR/blob/master/SemanticFilter.R
I iterate through parsedList
a=1
for (i in parsedList)
{
test1 <- fred$series.observations(series_id = parsedList[a], observation_start = "2000-01-01", observation_end = "2018-03-01")
test2 <- fred$series.observations(series_id = parsedList[a+1], observation_start = "2000-01-01", observation_end = "2018-03-01")
test %>>%
select(
date,
value
) %>>%
mutate(
date = as.Date(date),
value = as.numeric(value)
) ->
dt1
if (a>length(parsedList))
{
test2 %>>%
select(
date,
value
) %>>%
mutate(
date = as.Date(date),
value = as.numeric(value)
) ->
dt2
dt2[dt1, on = c('date')]
}
a=a+1
}
what I would like to do is merge (join?) all these parsedList's by date so all dataset's (which currently consists of "date", and "value") are merged by date.
I would like to use the merge function (from data.table?) but would like to iterate through all parsedList and result in one dataset with just date, and a slew of values (from each parsedList dataset).
Note [a] = a counter variable. That is the tricky part here. How do I join all iterations of test which are individual lists of parsedList[a]'s into a single list? Ex... parsedList[1] & parsedList[2] & parsedList[3] and ... so on until the last element of parsedList[length(parsedList)] is processed. So each parsedList[] has it's own date, value pair. So I'd need each value saved, but the date is the joining variable.
Note, this is as much of a logic question as much as a function question.