Leggi da un tubo anziché da un file e lascia che il tubo gestisca le trasformazioni di cui è possibile, che può essere semplice come grep -v '^$'
per saltare le linee vuote.
Il pipe()
La funzione è descritta in help(connections)
.
Ecco un esempio:
R> read.fwf("/tmp/raw.txt", width=rep(2,10), skip=1)
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1 x y z w a s d f g h
2 1 2 3 4 5
3 1 2 3 4 5 6 7 8 9 10
4 1 2
R> read.fwf(pipe("grep -v '^$' /tmp/raw.txt"), width=c(rep(2,10)))
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10
1 x y z w a s d f g h
2 1 2 3 4 5
3 1 2 3 4 5 6 7 8 9 10
4 1 2
R>