INPUTTING AND PROCESSING MULTIPLE FILE IN LOOP IN R LANGUAGE

Asked 2 years ago, Updated 2 years ago, 39 views

I'm sorry to ask you so many rudimentary questions.
Thank you very much for your help with the following questions.
Remove missing columns (or convert to 0)

Currently, based on various instructions, we are performing the following output: csv creation → input to R → Mann-whitney calculation → csv output.

Currently, I am satisfied, but since there are many csv files to enter, it is troublesome to enter the name in each sample, so I tried the following.

By the way, is it possible to automate this further?I think I can do it if I write it in For sentence.However, the name of the csv file you enter is not regular, so I'm having trouble.If the file name is 1, 2, 3..., I think I can do it with the For statement...

For example, if the file name is A4fg, Brtg, Huji, CVYh...

I'd like to write a code that says that I'm going to put the code like in the beginning and do it one by one.Of course, it would be helpful if you could print it as the file name_result.csv.

Thank you for your guidance.

r

2022-09-30 21:26

1 Answers

Hope this helps!

#setwd("<absolute path of directory having all csv files>")
setwd("<absolute path to directory containing all affected CSV files>")
# Enumerate all CSV files in the above directory
# list all csv files in above directory
files<-list.files(pattern="\\.csv$")

for (fin1:length(files)) {
  i<-gsub("(.*).csv", "\\1", files[f])
  # <your code>
  <Your Code>
}


2022-09-30 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.