I am trying to create a basic function that you enter the currency and the function returns a ggvis linegraph, but an issue occurs due to the quotation marks
Current code:
ggcurr<-function(curr="AUD"){
fx<-read.csv("rates.csv")
fx$date<-as.character(fx$date)
fx$date<-as.POSIXct(fx$date)
gginput<-noquote(paste("~",curr,sep=""))
fx%>%ggvis(~date,gginput)%>%
layer_lines()
}
This code just returns a straight line.
I have also attempted as.name() to no avail
Many thanks!
All solved, the parse function worked, thank's for those who helped!
In addition to the solution you found with parse
, this is the sort of thing that the prop
function from ggvis can be used for.
For example, if you wanted to take this simple line graph
mtcars %>% ggvis(~mpg, ~wt) %>% layer_lines()
with the y-variable wt
given as a string like you are doing in your function, it would look like this:
curr = "wt"
mtcars %>% ggvis(~mpg, prop("y", as.name(curr))) %>%
layer_lines()