The path of least resistance.
- edit
sample.dat with a plain text editor to remove
1a
PTV
1.00 mm resolution
631 bins
Thu May 20 17:53:57 2021
Min. Bin Dose (cGy), Bin Volume (cc)
and replace last line with
dose,vol
for more convenient variable names. They can be replaced with more descriptive names for presentation purposes.
- In
R
readr::read_csv("sample.dat")
── Column specification ────────────────────────────────────────────────────────
cols(
dose = col_character(),
vol = col_character()
)
Warning: 30 parsing failures.
row col expected actual file
632 -- 2 columns 1 columns 'sample.dat'
633 -- 2 columns 1 columns 'sample.dat'
634 -- 2 columns 1 columns 'sample.dat'
635 -- 2 columns 1 columns 'sample.dat'
636 -- 2 columns 1 columns 'sample.dat'
... ... ......... ......... ............
See problems(...) for more details.
# A tibble: 4,453 x 2
dose vol
<chr> <chr>
1 0 0.0000
2 10 0.0000
3 20 0.0000
4 30 0.0000
5 40 0.0000
6 50 0.0000
7 60 0.0000
8 70 0.0000
9 80 0.0000
10 90 0.0000
# … with 4,443 more rows
Note that 30 rows have problems due to extraneous header rows repeated periodically. Assign the imported object to dat and then remove these problem rows with
dat[!is.na(dat[,2]),]