Convert Factors in 2 Data Frames of a List into Numeric

梦想的初衷 提交于 2019-12-02 08:13:44

You need to use lapply. do a str on "b"

str(b)

This will let you know you have a list of 2 of 2 data.frames.

So you need to use lapply along with sapply, to preserve the data structure

lapply(b, function(x) sapply(x, function(x) as.numeric(as.character(x))))

You have D/N in your factor, which will be converted to NAs and also the list entries that are blank/empty

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!