0
votes

For example, I have a file with the following contents:

x=setwd('./blabla/bla'); system('python ........');
b=1,2,3
...

This is a list of stuff of a problem which I need to keep and process later on.

I need to use read table, but the problem I'm having is that the string loses the quotes and becomes:

setwd(./blabla/bla);

How can I keep the quotes by reading with read.table? If I use quote="", it gives me an error:

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 1 did not have 4 elements

1
It's not clear what happened to the x=. If you do a quick ?read.table in the console, you'll see quote: the set of quoting characters. To disable quoting altogether, use quote = "". See scan for the behaviour on quotes embedded in quotes. Quoting is only considered for columns read as character, which is all of them unless colClasses is specified so using quote="" in the call should work. - hrbrmstr
Are you sure you want to use read.table and no source? I can't reproduce this but you can try read.table(..., quote = "") - Jake Burkhead
This looks more like a job for source. What do you want to do with the file contents after import? - Roland
@hrbrmstr I've used the quote="" argument but i guess the problem I have is that there are multiple instructions with quotes per line. I'm going to eval the contents after import. - Pedro

1 Answers

0
votes

I found the solution, I needed to store the instructions in the following way:

x="setwd('./blabla/bla'); system('python ........');"