Here is my question:
formula = label ~ m1 + m2 + m2m1 + topix + sp500 + Open + High + Low +
Close + Volume + psyco12 + psyco24 + closeB5 + closeB10 +
closeB20 + closeB60 + William5 + William8 + William13 + William21 +
William34 + RSV9 + K + D + KD + MA5 + MA10 + MA20 + MA60 +
MA120 + MA240 + MA5MA20 + DI + EMA12 + EMA26 + DIF + MACD +
OSC + change + RSI6p + RSI6m + RSI6 + RSI12p + RSI12m + RSI12 +
RSI6RSI12 + OBV + JPYUSD + MarCap + MonthVol + MonthVal +
GV
class(formula) is formula
i want to convert it to the following format.
c("m1","m2","m2m1","topix","sp500","Open","High","Low",
"Close","Volume","psyco12","psyco24","closeB5","closeB10",
"closeB20","closeB60","William5","William8","William13","William21",
"William34","RSV9","K","D","KD","MA5","MA10","MA20","MA60",
"MA120","MA240","MA5MA20","DI","EMA12","EMA26","DIF","MACD",
"OSC","change","RSI6p","RSI6m","RSI6","RSI12p","RSI12m","RSI12",
"RSI6RSI12","OBV","JPYUSD","MarCap","MonthVol","MonthVal","GV")
including that c()
How can I make this work?
An option would be reformulate
to convert from vector
of names to formula
f1 <- reformulate(v1, "label")
And for reverse, use the all.vars
v2 <- all.vars(f1)[-1]
dput(v2)
c("m1", "m2", "m2m1", "topix", "sp500", "Open", "High", "Low",
"Close", "Volume", "psyco12", "psyco24", "closeB5", "closeB10",
"closeB20", "closeB60", "William5", "William8", "William13",
"William21", "William34", "RSV9", "K", "D", "KD", "MA5", "MA10",
"MA20", "MA60", "MA120", "MA240", "MA5MA20", "DI", "EMA12", "EMA26",
"DIF", "MACD", "OSC", "change", "RSI6p", "RSI6m", "RSI6", "RSI12p",
"RSI12m", "RSI12", "RSI6RSI12", "OBV", "JPYUSD", "MarCap", "MonthVol",
"MonthVal", "GV")
Or if there are multiple dependent variables,
all.vars(as.list(f1)[[3]])
v1 <- c("m1","m2","m2m1","topix","sp500","Open","High","Low",
"Close","Volume","psyco12","psyco24","closeB5","closeB10",
"closeB20","closeB60","William5","William8","William13","William21",
"William34","RSV9","K","D","KD","MA5","MA10","MA20","MA60",
"MA120","MA240","MA5MA20","DI","EMA12","EMA26","DIF","MACD",
"OSC","change","RSI6p","RSI6m","RSI6","RSI12p","RSI12m","RSI12",
"RSI6RSI12","OBV","JPYUSD","MarCap","MonthVol","MonthVal","GV")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With