with this part of your code
#define vector
fs<-c(f,g)
names(fs)<-c("F", "G")
you have created a list (try class (fs)or str (fs))
therefore, indexing of the last row should be changed to:
fs[[tag]](x)
just play around with the indexes to get an idea of โโthe structure. (e.g., see fs, fs[1], fs[[1]]etc.)