I have over 200 CSV files. Each file has 150+ columns and 1000s of rows. Each file is named by product name. Each file provides dataset with a flag for different items for various categories in different columns. One of the columns is total usage for each item across the category. Below is sample of the dataset:
Values A B C
1 Y
2 Y
3 Y Y
4 Y
I had asked a question yesterday, and I received help regarding how to get the following results.
Count Sum
A 2 4
B 1 2
C 2 7
Basically I want the Count Column to give me the number of "y" for A, B, and C, and the Sum column to give me sum from the Usage column for each time there is a "Y" in Columns A, B, and C
Now I have question on Step 2 - I have brought all the files into a folder. What I would like to do is use the above results, apply it in each of the file, and then have the answer grouped by file and category. For example
File 1 Count A Sum A Count B Sum B Count C Sum C
File 2 Count A Sum A Count B Sum B Count C Sum C and so on.
How can I do this in R? I have searched the forum, and found loop to be helpful, but I am not sure how I can combine the results into one.