Putitnf multiple different .csv files into loops

i am still r studio, i will appreciate if someone give me an idea. I have multiple different files. Extention of files is .csv. I need to use these different files to use for another .r file that is f95_gwas() and i need to put value as Y f95_gwas(Y) because in this program I need Y value. I dont have any problem with just handle one Y file but i did not find a way to use differnt files put into loop. I tried to put into list then put into loop but didnt work
'''r
setwd("~/lastversion_gwas_analysis/F_95/Over_Coocurrence/")
temp = list.files(pattern="*.csv") #each data frame in a separate object so i have thousand of .csv file now
for (i in 1:length(temp)) assign(temp[i], read.csv(temp[i]))
source("gwas.r")
source("emma.r")
source("plots_gwas.r")
source('~/lastversion_gwas_analysis/f95_gwas.r')
Y<- AT5G66980_AT4G10370.csv # when i try to use just one .csv file for other program it is working

Y[,1]<-as.numeric(Y[,1])
Y[,2]<-as.numeric(Y[,2])
f95_gwas(Y) #in this command gwas is running

i try to put into list

library(tidyverse)
library(fs)
source("gwas.r")
source("emma.r")
source("plots_gwas.r")
source('~/lastversion_gwas_analysis/f95_gwas.r')
setwd("~/lastversion_gwas_analysis/F_95/trial/")
file_paths<-fs::dir_ls("~/lastversion_gwas_analysis/F_95/trial/")
file_paths
##for loop
Y <- list()

for(i in seq_along(file_paths)){
Y[[i]]<-read_csv(
file=file_paths[[i]]
)
}
Y<-set_names(Y, file_paths)
f95_gwas(Y) #in this command gwas has to be run but it is not
'''

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.