All,
I am trying to leverage some finance functions that exist in R . The functions require dates to be passed as character . Can anybody guide me on how to pass the dates in a format acceptable to R from JMP .
@ih ( Special Mention)
# Working R Code
library(tvm)
CF1 <- c(-100,20,40,25,8,15)
d1 <- as.Date(c("2016-01-01","2016-04-01","2016-10-01","2017-02-01","2017-03-01","2017-06-01"))
Res <- vector()
Res <- sapply(1:length(d1), function(i) {xnpv(i,CF1[i:length(CF1)],d1[i:length(d1)])})I would like to do the exact same thing - except the inputs will need be passed from JMP to R .
The cash flow (CF1) is a straight vector and have no problem in passing, however the dates are the tricky part.
XNPV function in R if I am not requires dates to be formatted as character shown above.
Even though, I format the dates as character in JMP , but when I pass them to R I dont think they are being passed correctly.
R Send(DatesInJMP)
d1 <- as.Date(DatesInJMP)
R Get(d1)
- This throws an error - "as.Date.default(DatesInJMP)" - do not know how to convert to class "Date"