how do I get load.project() to use read.csv2 instead of read.table?

121 views
Skip to first unread message

thegermanguy

unread,
Sep 12, 2012, 9:45:23 AM9/12/12
to project...@googlegroups.com
Hi everyone, these are my first steps so please be patient.

Everything works fine with the provided "letters" example. When I try to open my own file though I get:

 Loading data set: clean1
Fehler in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  more columns than column names

I suppose this is because in need read.csv2, because that does import my data without any problem (and there aren't more colums than column names). But how do I change that?

Thanks, Stefan

John Myles White

unread,
Sep 12, 2012, 12:03:08 PM9/12/12
to project...@googlegroups.com
Hi Stefan,

Could you give more details? Is your read.csv2 file a proper CSV file?

 -- John

Stefan Fuchs

unread,
Sep 12, 2012, 12:20:48 PM9/12/12
to project...@googlegroups.com
Hi John,

exported with numbers.app (mac) as csv (UTF-8). Separators are " ; " and decomals are commas. First line are haders. Do you need more details? If I do an import with R-studio it imports without any problem. So I figured if I get ProjectTemplete to do a read.csv2 I'd be fine. jund don't know how...

Best, Stefan

John Myles White

unread,
Sep 14, 2012, 6:27:25 AM9/14/12
to project...@googlegroups.com
ProjectTemplate needs to be changed to add a CSV2 type. PT assumes pretty strict rules and the rule for a CSV file is that the separators are commas.

If you're intrepid, the way to do this is to make a change to the load.project function in the source for PT. In there, this is a list of file extensions that PT recognizes and a set of functions it calls to handle them. You can add a new reader function and then update the table to get your CSV2 file to work.

 -- John

John Myles White

unread,
Sep 16, 2012, 3:35:07 PM9/16/12
to project...@googlegroups.com
Hi Stefan,

Did you get a chance to look into this? I've just pushed a variant of ProjectTemplate to GitHub that has tentative support for a CSV2 format that uses semicolons as separators. Let me know if that works.

Best,

 -- John

On Sep 12, 2012, at 12:20 PM, Stefan Fuchs wrote:

thegermanguy

unread,
Sep 17, 2012, 6:38:19 AM9/17/12
to project...@googlegroups.com
Hi John,

thank you for your effort :-)

Preamble: I'm not a coder. I'm a simple Mac user.

But: I spent my morning finally (and proudly) installing the package from github via the terminal command. It actually did import my .csv file after I changed the extension to .csv2, yet pretty much all of what should be "num" came out as "factors". 

I found a much simpler solution over the weekend. I changed my Mac presets to have decimals encoded as dot instead of comma and now it works fine :-)

I do get a warning though:

In load.project() :
  Your configuration file is missing an entry: recursive_loading

and have no idea what to make of that.

All the best, Stefan

By the way, I'll be joining the R-course on Coursera starting on the 24th, and I sincerely hope that they cover ProjectTemplate, too :-)

John Myles White

unread,
Sep 17, 2012, 7:12:06 AM9/17/12
to project...@googlegroups.com
Hi Stefan,

Could you send me a sample of data like your old file that I could work with to resolve the num/factor problem? It may not be possible to fix the commas vs. periods issue without adding a new configuration option, but that seems reasonable to me.

The warning is because your project was created using a slightly older version of ProjectTemplate. You can get rid of it by adding a line, "recursive_loading: off", to the file "config/global.dcf". Or you can ignore it. Recursive loading is a new trick that will load all of the subdirectories of "data" in addition to the files in "data".

I would love it if the R course covered ProjectTemplate, but I'm not sure they will. People tend to love PT or to have little-to-no interest in it.

 -- John

Felix Schönbrodt

unread,
Oct 4, 2012, 3:15:58 AM10/4/12
to project...@googlegroups.com
+1 for csv2 support, thanks! Works well for me with the dev-version.
Felix

John Myles White

unread,
Oct 11, 2012, 2:50:32 PM10/11/12
to project...@googlegroups.com
Great. Thanks.

 -- John
Reply all
Reply to author
Forward
0 new messages