I have a text file in the following format: elt1\telt2\t...
with 1,000,000 elements.
Most of these elements are integers, but some of them are of the form number_number or chainOfCharacters. For example: 1\t2\t2_3\t4_44\t2\t'sap'\t34\t'stack'
should output: 1 2 2_3 4_44 2 'sap' 34 'stack'
.I tried to load this data in R using data <- read.table(file(fileName),row.names=0,sep='\t')
but it is taking for ever. Is it possible to speed this up?
You should use scan
instead:
scan(fileName, character(), quote = "")
# Read 8 items
# [1] "1" "2" "2_3" "4_44" "2" "'sap'" "34" "'stack'"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With