Example Data
df <- structure(list(Date = structure(c(15706, 15707, 15708, 15709, 15712, 15713, 15714, 15715, 15716, 15719), class = "Date"), MidPrs_JPY = c(NA, NA, NA, 0.00102, 0.00102, 0.00102, 0.00102, 0.00102, 0.00102, NA), BID_EUR = c(NA, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 1e-04, 2e-04, 2e-04, 2e-04), ASK_EUR = c(NA, -2e-04, -3e-04, -7e-04, -3e-04, -4e-04, -4e-04, -7e-04, -5e-04, -5e-04), BID_GBP = c(NA, 0.0048, 0.0048, 0.0048, 0.0048, 0.0048, 0.0048, 0.0048, 0.0048, 0.0048), ASK_GBP = c(NA, 0.0042, 0.0042, 0.0042, 0.0042, 0.0042, 0.0042, 0.0042, 0.0042, 0.0042), BID_USD = c(0.0034, 0.0034, 0.0034, 0.0034, 0.0034, 0.0034, 0.0034, 0.0034, 0.0034, 0.0034 ), ASK_USD = c(0.003, 0.003, 0.003, 0.003, 0.003, 0.003, 0.003, 0.003, 0.003, 0.003)), row.names = c(NA, 10L), class = "data.frame") namesV <- c("EUR", "GBP", "USD") Question
When playing around with eval(parse(...)) while writing a loop I noticed that one is not able to assign to a statement resulting from eval(parse(...)). This does not make sense to me since one can call a column by using this method but apparently can not assign new values.
What I mean by not being able to assign but call:
eval(parse(text = paste0("RepoCal$BID_", namesV[1]))) Allows me to call the column, however:
eval(parse(text = paste0("Repomid$MidPrs_", namesV[1]))) <- eval(parse(text = paste0("Repomid$MidPrs_", namesV[2]))) results in the Error:
target of assignment expands to non-language object
I am grateful for any tips that would help me to understand the underlying problem or even solve it, thanks!