I am trying o download csv data from the web using postForm, however, the file downloaded seems to be a html document instead of a csv file. These are my code:
############################
library(RCurl)
url <- "https://research.stlouisfed.org/fred2/series/MKTGDPSAA646NWDB/downloaddata"
params <- list(
"native_frequency" = "Annual", units = "lin",
"frquency" = "Annual", "aggregation" = "Average", "obs_start_date" = "1968-01-01",
"obs_end_date" = "2014-01-01", "file_format" = "csv", "download_data_2" = "", format="csv")
result <- postForm( url, .params = params)
writeBin(as.vector(result),"doc2.txt")
A slightly more modern approach is to use the
httr
package: