Opened 13 years ago

Closed 13 years ago

#839 closed enhancement (fixed)

[with patch, positive review] write pexpect interface to R

Reported by: mhansen Owned by: mhansen
Priority: minor Milestone: sage-3.0
Component: interfaces Keywords:
Cc: mhansen, schilly Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description


Attachments (7)

839-r-pexpect-initial.patch (22.7 KB) - added by mhansen 13 years ago.
839-r-notebook.patch (949 bytes) - added by mhansen 13 years ago.
Add notebook support for R
839-r-pexpect-schilly-1.hg (17.2 KB) - added by schilly 13 years ago.
based on previous patches, somewhat working version. see comment no. 9
839-r-pexpect-schilly-2.hg (13.7 KB) - added by schilly 13 years ago.
this replaces all patches from above - better working, but still not stable, repaired
839.hg (37.5 KB) - added by mhansen 13 years ago.
sage-839-referee1.patch (44.9 KB) - added by was 13 years ago.
839.2.hg (42.5 KB) - added by mhansen 13 years ago.

Download all attachments as: .zip

Change History (26)

comment:1 Changed 13 years ago by mhansen

  • Status changed from new to assigned

comment:2 Changed 13 years ago by mhansen

  • Milestone changed from sage-2.8.7 to sage-2.9

comment:3 Changed 13 years ago by mhampton

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

comment:4 Changed 13 years ago by mabshoff

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

Cheers,

Michael

comment:5 Changed 13 years ago by was

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

comment:6 Changed 13 years ago by mhansen

  • Cc mhansen@… added

Changed 13 years ago by mhansen

Changed 13 years ago by mhansen

Add notebook support for R

comment:7 Changed 13 years ago by mhansen

  • Summary changed from write pexpect interface to R to [with patch, needs additional work] write pexpect interface to R

comment:8 Changed 13 years ago by schilly

  • Cc schilly added

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

comment:9 Changed 13 years ago by schilly

  • Summary changed from [with patch, needs additional work] write pexpect interface to R to [with patch, needs review] write pexpect interface to R
  • Type changed from defect to enhancement

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)

Changed 13 years ago by schilly

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

comment:10 follow-up: Changed 13 years ago by was

This is AWESOME!!!!

comment:11 Changed 13 years ago by was

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=\x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1b[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\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 "

comment:12 in reply to: ↑ 10 Changed 13 years ago by schilly

  • Summary changed from [with patch, needs review] write pexpect interface to R to [with patch, but needs more work] write pexpect interface to R

Replying to was:

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<number> 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...

comment:13 follow-up: Changed 13 years ago by schilly

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...

Changed 13 years ago by schilly

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

comment:14 in reply to: ↑ 13 Changed 13 years ago by schilly

Replying to schilly:

attention: ...

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

comment:15 Changed 13 years ago by mabshoff

  • Cc mhansen added; mhansen@… removed
  • Milestone changed from sage-3.0.1 to sage-3.0

Changed 13 years ago by mhansen

Changed 13 years ago by was

comment:16 Changed 13 years ago by was

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.

comment:17 Changed 13 years ago by was

  • Summary changed from [with patch, but needs more work] write pexpect interface to R to [with patch, positive review pending look over of sage-839-referee1.patch] write pexpect interface to R

Changed 13 years ago by mhansen

comment:18 Changed 13 years ago by mhansen

  • Summary changed from [with patch, positive review pending look over of sage-839-referee1.patch] write pexpect interface to R to [with patch, positive review] write pexpect interface to R

Yay!

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

comment:19 Changed 13 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from assigned to closed

Merged 839.2.hg in Sage 3.0.rc0

Note: See TracTickets for help on using tickets.