How can I read the files in a directory in sorted order using R?

后端 未结 4 605
忘了有多久
忘了有多久 2020-12-17 05:26

The code given below worked well and read the files in my directory and extracted the values:

X <- c(75:85) ; Y <- c(208:215) 
extract <- vector()
f         


        
4条回答
  •  一生所求
    2020-12-17 06:19

    As I mentioned in the comment above, you can use paste to simplify your code a bit. Try:

    # set the working directory
    setwd("C:New folder (10)")
    
    # construct a vector of file names and loop through
    for (f in paste("Climate_Rad_", 1:365, ".img", sep="")) {
        conne <- file(f, "rb")
        # do rest, assuming it's correct
    }
    

提交回复
热议问题