I am new to the programming world and need help with loading a file to R and creating a matrix with it. I can import individual files and create and individual matrix out of it. How do I do this for multiple files? I have 21 files that each contain 100 rows and 100 columns and I need to import each file and put everything in a single array.
相关问题
- Extract matrix elements using a vector of column i
- R - Quantstart: Testing Strategy on Multiple Equit
- Using predict with svyglm
- Reshape matrix by rows
- Extract P-Values from Dunnett Test into a Table by
相关文章
- How to convert summary output to a data frame?
- Numpy matrix of coordinates
- How to plot smoother curves in R
- Paste all possible diagonals of an n*n matrix or d
- ess-rdired: I get this error “no ESS process is as
- How to read local csv file in client side javascri
- How to use doMC under Windows or alternative paral
- dyLimit for limited time in Dygraphs
list.files
to list my files by pattern.lapply
to loop through the list of files and create a list data.frame withread.csv
rbindlist
to bind all in a big matrix.It's not exactly clear what structure you want. You can choose between a 2100x100 matrix or a 2100x100 dataframe or a 100x 100x 21 array or a list with 21 entries each of which was 100 x 100. (In R an array is the term one would use for a regular 3 dimensional structure with columns all of that same type. (and then of course there is agstudy's suggestion that you use a data.table.)
In a sense agstudy's code already gives you the 21 item list of dataframes each of dimension: 100x100:
To get 100 x 100 x 21 array continue with this:
To get the 2100 x 100 dataframe, continue instead with:
To get the 2100 x 100 matrix continue from the last line with: