Question

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?

Was it helpful?

Solution

You should use scan instead:

scan(fileName, character(), quote = "")
# Read 8 items
# [1] "1"     "2"     "2_3"     "4_44"    "2"     "'sap'"   "34"    "'stack'"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top