I am new to RStudio. I am trying to import the following text into Rstudio. The file type is .txt. I would like to remove the first 6 rows (all the text).
AAA: true
BBB: false
CCC: 0
DDD: Wavelengths
EEE: 3648
>>>>>Begin Decimal Data<<<<<
623.821 -216.03
623.881 -216.03
623.941 -216.03
Then I would like to create the data.table, separating into two columns: Col A and Col B as follow.
Col A Col B
623.821 -216.03
623.881 -216.03
623.941 -216.03
I have a series of .txt files. So, I would like to combine, and delete the rows and separate the columns. I coded as follow:
files <- dir(".", pattern = ".txt$")
for (i in 1:length(files)) { obj_name <- files %>% str_sub(start = -2) assign(obj_name[i], read_table(files[i], skip = 13)) names(obj_name[i]) <- c("Col_A", "Col_B") }
But it shows the error as follow:
-- Column specification -------------------------------------------------------------
cols(
`>>>>>Begin` = col_double(),
Spectral = col_double(),
`Data<<<<<` = col_character()
)
Warning: 3648 parsing failures.
row col expected actual file
1 -- 3 columns 2 columns 'L1_0401_1758_C.txt'
2 -- 3 columns 2 columns 'L1_0401_1758_C.txt'
3 -- 3 columns 2 columns 'L1_0401_1758_C.txt'
4 -- 3 columns 2 columns 'L1_0401_1758_C.txt'
5 -- 3 columns 2 columns 'L1_0401_1758_C.txt'
... ... ......... ......... ....................
See problems(...) for more details.