I'm trying to use EViews with R.
My program begins in EViews and asks the user for some information:
- series to forecast in R, called %fcst_series
- start year for forecast, called !start_year
- start month for forecast, called !start_month
- frequency of data, called !frequency
My code then tries to feed these variables into the R code starting with:
xon
fcst_series <- ts({%fcst_series}, start = c({!start_year},{!start_month}), frequency = {!frequency})
However, R doesn't like {%fcst_series} formatting. It appears to reject the "{}" and the "%"...
I can't figure out what the right way is to transfer this information to R.
Any ideas would be greatly appreciated!
Many thanks,
KC
Passing Variable to "R"
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13329
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Passing Variable to "R"
Presumably you've already used XPUT to transfer the data across, and the issue is referencing that variable in R?
Follow us on Twitter @IHSEViews
Re: Passing Variable to "R"
Correct...
I had no issue moving the data to R... Just how to get the variables across into R.
I had no issue moving the data to R... Just how to get the variables across into R.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13329
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Passing Variable to "R"
If you have something like:
that will be passed into R as:
which will cause the error because R is not expecting the quotes. So you'd need to use R to remove the quotes.
Perhaps an easier way is to do this:
Code: Select all
%fcast_series = "X"
xput {%fcast_series}
xon
fcst_series<-ts({%fcst_series})
xoff
that will be passed into R as:
Code: Select all
fcast_series<-ts("x")
which will cause the error because R is not expecting the quotes. So you'd need to use R to remove the quotes.
Perhaps an easier way is to do this:
Code: Select all
%fcast_series = "X"
xput(name=foo) {%fcast_series}
xon
fcst_series<-ts(foo)
xoff
Follow us on Twitter @IHSEViews
Re: Passing Variable to "R"
I appreciate that. But what about passing a parameter like "frequency", for example?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13329
- Joined: Tue Sep 16, 2008 5:38 pm
Who is online
Users browsing this forum: No registered users and 7 guests