[R] how to factor in the ID of the imported subtable to R table?

YANJUN CHEN ychen344 @end|ng |rom w|@c@edu
Thu May 21 18:24:28 CEST 2020


Dear R community,

I am new to R—did some online tutorials and exercises in R playground. I was wondering if I could seek guidance on the following matter.

I have a set of 403 .csv files. Each.csv file contains the same layouts and distinguished by subject ID and date in the file name. The dataset looks like this:

Sub1-20170305.csv
Sub2-20180214.csv
…
Sub403-20191109.csv

I will use rbind function to combine 403 csv files in a single file (myFile). I will create two new variables (use mutate function) in myFile (subject ID and date). Is there a way to subtract subject ID (shown as “Sub1, 2,,,403”) and date from the name of the csv file and then place them in “subject ID” and “date” in myFile?

Any info on the issue itself or where to look for will be appreciated.

Thanks,

CJ






	[[alternative HTML version deleted]]



More information about the R-help mailing list