I am trying to write a simple for loop
to read in a number of .csv
files. I have looked at list.files(pattern="data.*csv")
which I do not think solves my problem.
I have a link to the data which looks like the following;
read.csv("C:/Users/user/Desktop/data/Year1/beer/beer.csv")
I have many years worth of data, I am trying to write something which changes Year1
to (for i in 1:15)...
Secondly I have many products and for now I am only interested in importing data for all years for the beer
product, so I am trying to create a separate vector of products i.e. products <- c("beer", "bread", "milk")
, which I can load in at a later stage.
The format of the product folders are all the same so, milk may be C:/Users/user/Desktop/data/Year1/milk/milk.csv
. Also the file names are the same across all years, so milk.csv
in year 1 is also called milk.csv
in year 7 for example.
I can paste what I have currently