1
votes
fxrates <-rbind(fxrates,c("EODMRS","USD","M",1,1,"17-APR-2019",1))

Warning message: In [<-.factor(*tmp*, ri, value = "USD") :
invalid factor level, NA generated

Guys, Do you know why second cell (with USD) is not generated?

2
Change the factor columns to character and it would be fine i..e i1 <- sapply(fxrates, isfactor); fxrates[i1] <- lapply(fxrates[i1], as.character)akrun

2 Answers

1
votes

We can change the factor columns to character and rbind with a list of values as the types can be different and vector (constructed withc) can store only a single type

i1 <- sapply(fxrates, is.factor)
fxrates[i1] <- lapply(fxrates[i1], as.character)
rbind(fxrates,list("EODMRS","USD","M",1,1,"17-APR-2019",1))
0
votes

How about using add_row in dplyr package?

fxrates <- dplyr::add_row(
    fxrates,
    x1 = "EODMRS", x2 = "USD", x3 = "M", x4 = 1, x5 = 1, x6 = "17-APR-2019", x7 = 1)
)

Those x1...x7 should be replaced with proper column names.