0
我有一个下一个任务如何申请规模规则很多列在新的数据集
a = data.frame(a= c(1,2,3,4,5,6)) # dataset
range01 <- function(x){(x-min(a$a))/(max(a$a)-min(a$a))} # rule for scale
b = data.frame(a = 6) # newdaset
lapply(b$a, range01) # we can apply range01 for this dataset because we use min(a$a) in the rule
但我怎么可以把这个当我有很多列在我的数据集?像下面
a = data.frame(a= c(1,2,3,4,5,6))
b = data.frame(b= c(1,2,3,3,2,1))
c = data.frame(c= c(6,2,4,4,5,6))
df = cbind(a,b,c)
df
new = data.frame(a = 1, b = 2, c = 3)
我当然可以制定规则,为每个变量
range01a <- function(x){(x-min(df$a))/(max(df$a)-min(df$a))}
但它很长的路要走。如何使它方便?