Dear all,
After spending a few week trying to figure out the problem with the ReadMe
package when run under windows, I have just found the following fix.
The main culprit preventing your Windows OS from properly accessing the
makerfile is due to the 'single quotes' that are added to the file path in
the undergrad script (e.g. 'C:\python27\python.exe' instead of just
C:\python27\python.exe). This also becomes a problem when the script
accesses the control.txt and tablefile.txt files.
This might be fine (or even required) under other OSes, but under Windows
this actually becomes problematic due to the way the OS reads file paths.
Therefore I have devised the following (temporary) fix:
Note 1 This fix assumes that you have installed Python 2.xx or 3.xx and
have properly configured your PATH environmental variable). I have tested
this fix with the most recent R versions
Note 2 I recommend implementing this under Rstudio because it displays line
numbers, but this is also doable under the vanilla Rgui
Note 3 I only write about the minimum amount of fixes you need in order to
properly run the undergrad function (which is necessary if you were to run
the demo(clinton) script), but I have yet to test whether the ReadMe script
needs further modification for windows when deciding to run other datasets
with different operators.
1 start R
2 load the Readme package --> library(ReadMe)
3 type the following command --> fix(undergrad)
4 find line 10-12, which shows the Python2 (makerfile) lines of code:
if (python3 == FALSE) {
call <- paste(system.file("'","makerfile", package = "ReadMe"), *"'"
* sep = "")
}
5 remove the double quotes + singles quotes + the extraenous commas between
the system.file() brackets. This leaves just the following code (note that
R does not care much about the spaces or tabs that you'll delete):
if (python3 == FALSE) {
call <- paste(system.file("makerfile", package = "ReadMe"), sep =
"")
}
6 repeat the same procedure for line 14-16 (this fixes the Python3
makerfile), which results in
else {
call <- paste(system.file("makerfile3-0.py", package = "ReadMe"),
sep = "")
}
7 Do this also for the control-file (lines 43-44) and the table-file (lines
45-46), this should result in the following lines of code:
call <- paste(call, "--control-file", paste(control, sep = ""))
call <- paste(call, "--table-file", paste(table.file, sep = ""))
8 Save your modifications (under Rgui you will be prompted with save when
you close the edit window).
9 Run demo(clinton)
Final note:
This fix for the undergrad function is temporary until you restart R. You
could technically save the fixes on a permanent basis or write an script
that automatically runs at start-up, but I just save the modified script in
a separate text file and copy/paste it whenever I need to run the ReadMe
package. Either way, until the makers of the ReadMe fix the undergrad
function for windows you'll have to modify the undergrad function by
yourself.
With Regards,
Cômeng Tang BSc
Leiden University
East Asian Studies
> ---------- Forwarded message ----------
> From: <readme-request(a)lists.gking.harvard.edu>
> Date: Wed, Oct 2, 2013 at 6:00 PM
> Subject: Readme Digest, Vol 8, Issue 1
> To: readme(a)lists.gking.harvard.edu
>
>
> Send Readme mailing list submissions to
> readme(a)lists.gking.harvard.edu
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.gking.harvard.edu/mailman/listinfo/readme
> or, via email, send a message with subject or body 'help' to
> readme-request(a)lists.gking.harvard.edu
>
> You can reach the person managing the list at
> readme-owner(a)lists.gking.harvard.edu
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Readme digest..."
>
>
> Today's Topics:
>
> 1. Re: Python error on demo(clinton) (Enrico Borghetto)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 1 Oct 2013 16:38:28 +0100
> From: Enrico Borghetto <borghenry(a)gmail.com>
> To: readme(a)lists.gking.harvard.edu
> Subject: Re: [readme] Python error on demo(clinton)
> Message-ID:
> <CAOZTqvLA+GZ=
> b7Dj5215AmPhyKjssgOjSHt1wxfjAk_hj5LDSg(a)mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Dear Daniel,
>
> thank you for your suggestions to solve the error on demo(clinton). I
> checked that:
>
> 1) Python is installed before R and in the path - when I type "python" on
> the command line, it starts running
> 2) My version of Python is 2.7.5
>
> Yet, running the demo in RStudio (0.97.551) and R (3.0.2) I still get the
> error:
>
> > demo(clinton)
>
>
> demo(clinton)
> ---- ~~~~~~~
>
> Type <Return> to start :
>
> > oldwd <- getwd()
>
> > setwd(system.file("demofiles/clintonposts", package="ReadMe"))
>
> > undergrad.results <- undergrad(sep = ',')
> [1] "python
> 'C:/Users/Borghetto/Documents/R/win-library/3.0/ReadMe/makerfile'
> --alphanumeric-only --separator \",\" --control-file 'control.txt'
> --table-file 'tablefile.txt' --threshold 0.01"
> C:\Python27\python.exe: can't open file
> ''C:/Users/Borghetto/Documents/R/win-library/3.0/ReadMe/makerfile'': [Errno
> 22] Invalid argument
> Error in undergrad(sep = ",") : Python module failed. Aborting undergrad.
> In addition: Warning message:
> running command 'python
> 'C:/Users/Borghetto/Documents/R/win-library/3.0/ReadMe/makerfile'
> --alphanumeric-only --separator "," --control-file 'control.txt'
> --table-file 'tablefile.txt' --threshold 0.01' had status 2
>
> Any idea?
>
> Thanks a lot
>
> Enrico
>
> --
> Enrico Borghetto, PhD
> Post-Doctoral Fellow
> Cesnova - Centro de Estudos de Sociologia da Universidade Nova de Lisboa
> NOVA University of Lisbon
> Personal Website <http://enricoborghetto.weebly.com/>
> Italian Policy Agendas <http://italianpolicyagendas.weebly.com/>
> Center for the Observation of Legislatures <http://www.coolresearch.net/>
> Italian Law Making Archive <http://159.149.130.120/ilma/sito/>
>
Dear Daniel,
thank you for your suggestions to solve the error on demo(clinton). I
checked that:
1) Python is installed before R and in the path - when I type "python" on
the command line, it starts running
2) My version of Python is 2.7.5
Yet, running the demo in RStudio (0.97.551) and R (3.0.2) I still get the
error:
> demo(clinton)
demo(clinton)
---- ~~~~~~~
Type <Return> to start :
> oldwd <- getwd()
> setwd(system.file("demofiles/clintonposts", package="ReadMe"))
> undergrad.results <- undergrad(sep = ',')
[1] "python
'C:/Users/Borghetto/Documents/R/win-library/3.0/ReadMe/makerfile'
--alphanumeric-only --separator \",\" --control-file 'control.txt'
--table-file 'tablefile.txt' --threshold 0.01"
C:\Python27\python.exe: can't open file
''C:/Users/Borghetto/Documents/R/win-library/3.0/ReadMe/makerfile'': [Errno
22] Invalid argument
Error in undergrad(sep = ",") : Python module failed. Aborting undergrad.
In addition: Warning message:
running command 'python
'C:/Users/Borghetto/Documents/R/win-library/3.0/ReadMe/makerfile'
--alphanumeric-only --separator "," --control-file 'control.txt'
--table-file 'tablefile.txt' --threshold 0.01' had status 2
Any idea?
Thanks a lot
Enrico
--
Enrico Borghetto, PhD
Post-Doctoral Fellow
Cesnova - Centro de Estudos de Sociologia da Universidade Nova de Lisboa
NOVA University of Lisbon
Personal Website <http://enricoborghetto.weebly.com/>
Italian Policy Agendas <http://italianpolicyagendas.weebly.com/>
Center for the Observation of Legislatures <http://www.coolresearch.net/>
Italian Law Making Archive <http://159.149.130.120/ilma/sito/>