I have the following code that loads in several .txt files from a folder
namesnotxt = substr(filenames,1,24)
for(i in namesnotxt){
filepath = file.path(" ", paste(i, ".txt", sep=""))
assign(i, read.table(filepath,
skip= 20, #skips the first 20 rows of data because of the txt. file structure
col.names=( c("time","v","a","t1","t2","t3","t4","t5","t6","t7","t8")), #names the data columns
sep=","))}
I want this code to be selective on the date of the files, which is given in the filenames as follows: SD07_TWK_20190822_003004
I know I can get the dates in these filenames with:
date = substr(filenames,10,17)
However I don't know how to build this into the loop as a selection. I have tried with an IF statement in the jist of:
date_start = "20190822"
date_end = "20190823"
if( date >= date_start && date <= date_end){
print(date)}
However, I can't get that to work.
The date-time can also be found in the file itself (on the 14th row), which looks as follows: Maybe this would offer an alternative way of doing this.
Datetime=2019-08-22 00:30:04