从列表转换为数字 [英] Convert from list to numeric

查看:98
本文介绍了从列表转换为数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了很多其他的qns/answers,但还无法解决从列表形式到数字形式的强制转换.如果有用,该列表最初是从一个因子中得出的(是1x33行).

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]]

其中提供:

       TradeValue
1    72914431
2       25325
3       20139
4       ...

因此,根据其他建议(Stackoverflow等),我使用:

So based on other advice (Stackoverflow, etc) I use:

tmpx <-as.numeric(tmpseqsf[[1]])

但是我得到了错误:

Error: (list) object cannot be coerced to type 'double'

并确认没有任何反应:

is.numeric(tmpseqsf[[1]])
[1] FALSE

有什么我完全想念的吗?

Is there something I am completely missing?

推荐答案

如果值属于类型因子,则应通过as.numeric(as.character(unlist(tmpseqsf[[1]])))

If the values are of type factor, then you should convert them by as.numeric(as.character(unlist(tmpseqsf[[1]])))

这篇关于从列表转换为数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆