【发布时间】:2022-01-11 19:17:01
【问题描述】:
R 新手。 我想通过几个 data.frames 运行 SVM 并自动化该过程。 我在一个列表中得到了 data.frames,但不知道如何循环它们以将所有可能的可能性都放入我的函数中。简而言之,我想摆脱代码末尾的复制和粘贴。 此外,有没有办法根据 myfunction 的传入数据来标记我的情节?
df1<-iris
df2<-iris
df2$Petal.Width = df2$Petal.Width+2
df3<-iris
df3$Petal.Width = df3$Petal.Width-2
df4<-iris
df4$Petal.Width = df4$Petal.Width-5
Werte <- list(df1,df2,df3,df4)
new_function <- function(V1, V2){
m2<-data.frame(V1$Petal.Width, V2$Petal.Width)
plot(m2)
}
new_function(V1=Werte[[1]],V2=Werte[[2]])
new_function(V1=Werte[[1]],V2=Werte[[3]])
new_function(V1=Werte[[1]],V2=Werte[[4]])
new_function(V1=Werte[[2]],V2=Werte[[3]])
new_function(V1=Werte[[2]],V2=Werte[[4]])
new_function(V1=Werte[[3]],V2=Werte[[4]])
【问题讨论】: