While observing your error, I think the message might have something to do with the statement unlist(as.numeric(y)):
You can simply try the following code, but this will also throw an error message:
as.numeric(list(c("1", "2"), "3")) # error: 'list' object cannot be coerced to type 'double'
But if you run:
as.numeric(list("1", "2"))
This will work.
In last what you can do is save it by switching the commands. First, try to unlist, then type-cast second:
as.numeric(unlist(list(c("1", "2"), "3"))) # works: c(1, 2, 3)
If you are a beginner and want to know more about R the do check out the R programming tutorial.