问题
Hi I've had a look at a lot of other qns/answers and haven't been able to resolve coercing from list form to numeric form. If it is of use, the list is originally drawn from a factor (and is 1x33 rows).
My list is defined by:
tmpseqsf[[1]]
which provides:
TradeValue
1 72914431
2 25325
3 20139
4 ...
So based on other advice (Stackoverflow, etc) I use:
tmpx <-as.numeric(tmpseqsf[[1]])
but I get the error:
Error: (list) object cannot be coerced to type 'double'
And just confirming nothing has happened:
is.numeric(tmpseqsf[[1]])
[1] FALSE
Is there something I am completely missing?
回答1:
If the values are of type factor, then you should convert them by as.numeric(as.character(unlist(tmpseqsf[[1]])))
来源:https://stackoverflow.com/questions/43599347/convert-from-list-to-numeric