Opened 11 years ago
Last modified 8 years ago
#11436 new defect
Fix R reading files
Reported by: | kcrisman | Owned by: | was |
---|---|---|---|
Priority: | major | Milestone: | sage-6.4 |
Component: | interfaces | Keywords: | r-project |
Cc: | jhpalmieri, jason, was | Merged in: | |
Authors: | Karl-Dieter Crisman | Reviewers: | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
The current way we configure the R Pexpect interface is to have a 1024 character cutoff to trying to read from a file.
Problem: this doesn't actually seem to work.
sage: s = 'matrix(c(1, 1, 1, 1,' + ' '*987 + '2,2,2,2), ncol=4)' sage: len(s) 1024 sage: r.eval(s) ' [,1] [,2] [,3] [,4]\n[1,] 1 1 2 2\n[2,] 1 1 2 2' sage: s = 'matrix(c(1, 1, 1, 1,' + ' '*988 + '2,2,2,2), ncol=4)' sage: len(s) 1025 sage: r.eval(s) ''
jhpalmieri helped track this down. See this sage-support thread for more details.
Helpful links:
It seems like everything is creating files as should be, and using the verbose option to source shows that at least something's being computed, but the result is not showing up in Sage, possibly due to misuse of "source", or "file".
Attachments (1)
Change History (10)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
Yes, and this fixes the original problem too.
The only issue is that
""" Reads filename into the R interpreter by calling R's source function on a read-only file connection. EXAMPLES: sage: filename = tmp_filename() sage: f = open(filename, 'w') sage: f.write('a <- 2+2\n') sage: f.close() sage: r.read(filename) sage: r.get('a') '[1] 4' """
So the idea is perhaps that we do NOT see the output from such an evaluation. The problem is that then one has to know that one should assign the big computation to a name via variable <- command
, and that is not obvious.
What is the best solution here? To change the reading of lines or to make the documentation REALLY clear? My preference would be to have long commands still output, just like short commands; it seems unfair to have them suddenly do this.
comment:3 Changed 11 years ago by
Possible patch uploaded. Probably needs more documentation, but it fixed my problem locally so I'm going to bed. Suggestions welcome.
comment:4 Changed 10 years ago by
- Keywords r-project added
comment:5 Changed 10 years ago by
See this sage-devel thread for what I believe is this same problem.
comment:6 Changed 9 years ago by
- Milestone changed from sage-5.11 to sage-5.12
comment:7 Changed 9 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:8 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:9 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
In fact, the file part of what we use doesn't even seem to be necessary. The option we need is
print.eval=TRUE
.