Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write pexpect interface to R #839

Closed
mwhansen opened this issue Oct 7, 2007 · 19 comments
Closed

write pexpect interface to R #839

mwhansen opened this issue Oct 7, 2007 · 19 comments

Comments

@mwhansen
Copy link
Contributor

mwhansen commented Oct 7, 2007

CC: @mwhansen @haraldschilly

Component: interfaces

Issue created by migration from https://trac.sagemath.org/ticket/839

@mwhansen mwhansen added this to the sage-2.8.7 milestone Oct 7, 2007
@mwhansen mwhansen self-assigned this Oct 7, 2007
@mwhansen mwhansen modified the milestones: sage-2.8.7, sage-2.9 Oct 12, 2007
@sagetrac-mhampton
Copy link
Mannequin

sagetrac-mhampton mannequin commented Oct 31, 2007

comment:3

This is of huge importance to the wider adoption of sage. Thank you for working on it.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 26, 2008

comment:4

Is this still relevant or doe rpy take care of all of this?

Cheers,

Michael

@williamstein
Copy link
Contributor

comment:5

This is definitely still very relevant. It would, e.g., make it possible to have an R mode in the notebook.

@mwhansen
Copy link
Contributor Author

Attachment: 839-r-pexpect-initial.patch.gz

Attachment: 839-r-notebook.patch.gz

Add notebook support for R

@mwhansen mwhansen changed the title write pexpect interface to R [needs additional work] write pexpect interface to R Mar 2, 2008
@haraldschilly
Copy link
Member

comment:8

old but still relevant: The R language – a short companion .. summarizes much of the specific aspects and ideas behind the R language.

@haraldschilly
Copy link
Member

comment:9

attached bundle for a first "working" version. this is still not stable to use, but:

i've setup a wiki page to show its functionality: http://wiki.sagemath.org/R

still missing:

  • documentation + tests
  • plotting (just started something, but i don't understand how it should be done)
  • latex (see source for comments)

@haraldschilly haraldschilly changed the title [needs additional work] write pexpect interface to R write pexpect interface to R Mar 25, 2008
@haraldschilly
Copy link
Member

Attachment: 839-r-pexpect-schilly-1.hg.gz

based on previous patches, somewhat working version. see comment no. 9

@williamstein
Copy link
Contributor

comment:10

This is AWESOME!!!!

@williamstein
Copy link
Contributor

comment:11

The second thing I try -- use R's install.packages -- leads to problems:

sage: r.inst[tab key]
r.install_packages    r.installed_packages  
sage: r.install_packages('HSAUR')
Error: object "sage3" not found
sage: r.install.packages('HSAUR')
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call last)

/Users/was/edu/2007-2008/sage/<ipython console> in <module>()

<type 'exceptions.AttributeError'>: 'RFunction' object has no attribute 'packages'

This does start to work, but eventually fails (that this fails may be my fault -- maybe HSAUR is not longer at CRAN):

sage: r.eval('install.packages("HSAUR")')
[GUI select mirror]
sage: r.eval('install.packages("HSAUR")')
"--- Please select a CRAN mirror for use in this session ---\n\x1b[1mLoading Tcl/Tk interface ... \x1b[0m\x1b[1mdone\n\x1b[0m\x1b[1malso installing the dependencies \xe2\x80\x98lattice\xe2\x80\x99, \xe2\x80\x98VR\xe2\x80\x99, \xe2\x80\x98scatterplot3d\xe2\x80\x99\n\n\x1b[0m\x1b[1mtrying URL 'http://cran.wustl.edu/bin/macosx/universal/contrib/2.6/lattice_0.17-6.tgz'\n\x1b[0m\x1b[1mContent type 'application/x-tar'\x1b[0m\x1b[1m length 572946 bytes (559 Kb)\n\x1b[0m\x1b[1mopened URL\n\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\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\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m=\x1b[0m\x1b[1m\n\x1b[0m\x1b[1mdownloaded 3.6 Mb\n\n\x1b[0m\nThe downloaded packages are in\n\t/var/folders/lH/lHHJUEtmHlmUGwLs8K2fdE+++TI/-Tmp-//RtmpNYdywT/downloaded_packages\n\x1b[1mWarning message:\n\x1b[0m\x1b[1mdependency \xe2\x80\x98MASS\xe2\x80\x99 is not available "

@haraldschilly
Copy link
Member

comment:12

Replying to @williamstein:

This is AWESOME!!!!

thx for the flowers ;)


some ideas and what i'm trying next: (help welcome)

i think installing packages is rather difficult. at my computer, i even don't see the GUI selector or anything else, just hangs. your output, last line, says: dependency MASS is not available. .. but MASS should be pretty standard ...

i'll add a default mirror in the options, but this alone solves nothing. there is a command line option when calling R itself: R CMD INSTALL ... maybe it's easier to work on that level? separate process and different cmd window...

a good solution could be to avoid installing + local compilation and just ship more packages with R (in standard) and repack additional libraries of packages into optional SPKGs. i think this should be pretty straightforward (R could be easily convinced to search in multiple paths for packages if necessary ...)

i've also not figured out how to plot and why there are missing sage objects. there are certainly many bugs. i'll also try to introduce my custom prompt (appending a command to each line of code) and running R in full silent mode (no prompt, no questions, no nothing, reduced warnings level, ...). restore from last session and searching directories for stored configurations was also enabled --- disabling all this should give much less surprises ;)

also there are bugs in the R-2-Sage converter. e.g. i just had to explain python that NA means None ...

i should also check some details inside the bundled R inside the ./sage -sh environment. possibly there is something wrong with it, too...

@haraldschilly haraldschilly changed the title write pexpect interface to R [but needs more work] write pexpect interface to R Mar 25, 2008
@haraldschilly
Copy link
Member

comment:13

attention: I've updated my work status, but something didn't work with the bundle. Just the one in the middle (click here) is the interesting one. maybe i should not have updated...

@haraldschilly
Copy link
Member

Attachment: 839-r-pexpect-schilly-2.hg.gz

this replaces all patches from above - better working, but still not stable, repaired

@haraldschilly
Copy link
Member

comment:14

Replying to @haraldschilly:

attention: ...

i've repaired it. i think this should work now. (concerning the patch ;)

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-3.0.1, sage-3.0 Apr 18, 2008
@mwhansen
Copy link
Contributor Author

Attachment: 839.hg.gz

@williamstein
Copy link
Contributor

Attachment: sage-839-referee1.patch.gz

@williamstein
Copy link
Contributor

comment:16

REFEREE REPORT:

  • I fixed most of the issues I have with typos in docs, incompleteness of docs, etc., in
    sage-839-referee1.patch which should be looked over by Mike Hansen and Schilly.

  • There are still some bugs and serious issues, but they are not show stoppers. They include:

    • Installing optional packages seems completely broken on OS X. Maybe also on Linux.
    • Functions that don't exist:
sage: r.nonexistfunction(5)
Error: object "sage1" not found

That should give a proper error message. Also, after doing the above, for some reason all the text in the rest of my session is BOLD.

@williamstein williamstein changed the title [but needs more work] write pexpect interface to R [with patch, positive review pending look over of sage-839-referee1.patch] write pexpect interface to R Apr 20, 2008
@mwhansen
Copy link
Contributor Author

Attachment: 839.2.hg.gz

@mwhansen
Copy link
Contributor Author

comment:18

Yay!

Apply 839.2.hg . It has all of the patches and is based against 3.0.alpha6.

@mwhansen mwhansen changed the title [with patch, positive review pending look over of sage-839-referee1.patch] write pexpect interface to R write pexpect interface to R Apr 20, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Apr 20, 2008

comment:19

Merged 839.2.hg in Sage 3.0.rc0

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Apr 20, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants