R - 将列表中的多个数据框转换为数字

问题描述 投票:0回答:0

我重新创建了数据结构,因此它可以帮助我更好地理解我的问题。让我们生成一些数据。

a <- c(10,20,30,40)
b <- c('book', 'pen', 'textbook', 'pencil_case')
c <- c(TRUE,FALSE,TRUE,FALSE)
d <- c(2.5, 8, 10, 7)
df1 <- data.frame(as.factor(a),as.factor(b),as.factor(c),as.factor(d))

b <- c(10,20,30,40)
d <- c('book', 'pen', 'textbook', 'pencil_case')
a <- c(TRUE,FALSE,TRUE,FALSE)
c <- c(2.5, 8, 10, 7)
df2 <- data.frame(as.factor(a),as.factor(b),as.factor(c),as.factor(d))

df<-list(df1,df2)

假设我只有

df
。我需要将
df1
df2
中的所有条目从因子/分类数据更改为数字,同时保留列表中两个数据帧的结构。
感谢您的帮助!
此致
凯文

r list nested type-conversion categorical-data
© www.soinside.com 2019 - 2024. All rights reserved.