quandl / quandl-r

This is Quandl's R Package
https://cran.r-project.org/web/packages/Quandl/
Other
139 stars 55 forks source link

Use input vector names to Quandl() function as output names #50

Closed stevenfazzio closed 8 years ago

stevenfazzio commented 8 years ago

If a named vector of codes gets passed into the Quandl() function, it'd be nice if the output used those vector names.

Current behavior:

codes <- c(Coal  = 'BP/COAL_CONSUM_O_WRLD', 
           Hydro = 'BP/HYDRO_CONSUM_O_WRLD',
           Solar = 'BP/SOLAR_CONSUM_O_WRLD')
res <- Quandl(codes)
str(res)
#> 'data.frame':    50 obs. of  4 variables:
#>  $ Date                          : Date, format: "1965-12-31" "1966-12-31" ...
#>  $ BP.COAL_CONSUM_O_WRLD - Value : num  1395 1410 1387 1410 1455 ...
#>  $ BP.HYDRO_CONSUM_O_WRLD - Value: num  209 223 229 240 254 ...
#>  $ BP.SOLAR_CONSUM_O_WRLD - Value: num  0 0 0 0 0 0 0 0 0 0 ...

Proposed behavior:

codes <- c(Coal  = 'BP/COAL_CONSUM_O_WRLD', 
           Hydro = 'BP/HYDRO_CONSUM_O_WRLD',
           Solar = 'BP/SOLAR_CONSUM_O_WRLD')
res <- Quandl(codes)
str(res)
#> 'data.frame':    50 obs. of  4 variables:
#>  $ Date  : Date, format: "1965-12-31" "1966-12-31" ...
#>  $ Coal  : num  1395 1410 1387 1410 1455 ...
#>  $ Hydro: num  209 223 229 240 254 ...
#>  $ Solar : num  0 0 0 0 0 0 0 0 0 0 ...
ccleung commented 8 years ago

Hi @stevenfazzio, Interesting feature! If you would like to create a pull request with the proposed changes, we can see if it makes sense to merge it into our next release.