Hi,
I am using the wonderful Rdaemon-bundle in TextMate.
But now I stumbled over a big problem parsing code to the Rdaemon (by selecting the code and pressing CMD+T or selecting "execute selection").
It is a rather long script and some of the lines at the end of the script do not get parsed correctly. They kind of get completely screwed up leading to error messages.
For example, this line in the original code:
for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(2,1)) }
looks like this after pressing CMD+T:
for(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:egory
Error: unexpected 'in' in "for(i in 1:length(x)) { prfor(i in"
It seems to have something to do with the length of the script.
When I just execute this line, or chunks of code step by step, it works fine. But if I try to run the whole script (with CMD+A, CMD+T) strange things happens at the end of the script (like this screwed up line above).
If I try to make the code smaller (delete lines etc.), it seems like different lines get affected by this strange behavior (at it always happens at the end of the script).
So it seems to have nothing to do with particular lines of codes, but as I said, the length of the script. As if at some point the parsing of code to the Rdaemon doesn't work anymore (perhaps something like buffer-overflow?).
hope someone can help!
thanks.
On 13 Oct 2011, at 20:23, Martin Batholdy wrote:
But now I stumbled over a big problem parsing code to the Rdaemon (by selecting the code and pressing CMD+T or selecting "execute selection").
It is a rather long script and some of the lines at the end of the script do not get parsed correctly. They kind of get completely screwed up leading to error messages.
For example, this line in the original code:
for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(2,1)) }
looks like this after pressing CMD+T:
for(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:egory
Error: unexpected 'in' in "for(i in 1:length(x)) { prfor(i in"
Hi Martin,
before I can try to help you I've a question. You mentioned the bundle Rdaemon and CMD+T. If your TextMate window runs in the Rdaemon mode then you can simply press RETURN to execute the current line. Or do you mean the R bundle? Or do you mean running Rdaemon and having a separate "R" window open? And CMD+T key equivalent is new to me.
If you run a very large script in "R" mode, including the selection of lines of code, and press CMD+R or in Rdaemon mode SHIFT+CMD+R, then the selected text will be passed via STDIN to a script which reads the text line by line. I do not know ad hoc where the maximum size in respect of the underlying BASH/Ruby script is but I've never come across with such an issue. Can you tell us how large in terms of MBytes and lines "rather long script" is? (simply copy your selection to a new file and save it and look in the Finder how large it is)
[I've just run a script with 2500 lines, ok, it took a while, but finished successfully]
Tiny note: CMD+R in "R" mode executes the selection or if no selection is present the entire document, thus there's no need to "Select All" CMD+A in beforehand.
Best, --Hans
Dear Hans,
And CMD+T key equivalent is new to me.
I am sorry – I probably redefined this shortcut by myself.
I work in the Rdaemon mode (is that how you call it in TextMate?).
I start the Rdaemon with CMD+enter and then execute selected lines with the "execute selection" menu item. A small window pops up with a progress bar and the message "sending task to Rdaemon". After this is finished the selection converts to R-output.
I don't have a separate R-window open.
or in Rdaemon mode SHIFT+CMD+R, then the selected text will be passed via STDIN to a script which reads the text line by line
So I think this is how I work with the package.
The script is actually not that large. It is just about 200 lines of code (8kb on disk).
But since I get this strange parsing-behavior always at the end of the script, I thought it has something to do with that.
But perhaps it also has something to do with the amount of data I do calculations on in this script. I am currently working with matrices that occupy more than 1gb of ram.
But I observed this behavior already some time ago in a different script and there I wasn't working with a large data-set. So I thought it has nothing to do with that.
One more hypothesis :) : Perhaps it has something to with repeating statements that are very similar. In the example of the for-loop, there were actually four of these very similar loops after another. And before that I had also this strange behavior in four lines of code which also were very similar (use of the same functions on the same data.frame etc.)
I try to come up with sample-script. Perhaps I can manage to replicate this behavior with generic data.
best, martin
On 13.10.2011, at 22:35, Hans-Jörg Bibiko wrote:
On 13 Oct 2011, at 20:23, Martin Batholdy wrote:
But now I stumbled over a big problem parsing code to the Rdaemon (by selecting the code and pressing CMD+T or selecting "execute selection").
It is a rather long script and some of the lines at the end of the script do not get parsed correctly. They kind of get completely screwed up leading to error messages.
For example, this line in the original code:
for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(2,1)) }
looks like this after pressing CMD+T:
for(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:egory
Error: unexpected 'in' in "for(i in 1:length(x)) { prfor(i in"
Hi Martin,
before I can try to help you I've a question. You mentioned the bundle Rdaemon and CMD+T. If your TextMate window runs in the Rdaemon mode then you can simply press RETURN to execute the current line. Or do you mean the R bundle? Or do you mean running Rdaemon and having a separate "R" window open? And CMD+T key equivalent is new to me.
If you run a very large script in "R" mode, including the selection of lines of code, and press CMD+R or in Rdaemon mode SHIFT+CMD+R, then the selected text will be passed via STDIN to a script which reads the text line by line. I do not know ad hoc where the maximum size in respect of the underlying BASH/Ruby script is but I've never come across with such an issue. Can you tell us how large in terms of MBytes and lines "rather long script" is? (simply copy your selection to a new file and save it and look in the Finder how large it is)
[I've just run a script with 2500 lines, ok, it took a while, but finished successfully]
Tiny note: CMD+R in "R" mode executes the selection or if no selection is present the entire document, thus there's no need to "Select All" CMD+A in beforehand.
Best, --Hans
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 13 Oct 2011, at 23:23, Martin Batholdy wrote:
I start the Rdaemon with CMD+enter and then execute selected lines with the "execute selection" menu item. A small window pops up with a progress bar and the message "sending task to Rdaemon". After this is finished the selection converts to R-output.
I don't have a separate R-window open.
The script is actually not that large. It is just about 200 lines of code (8kb on disk).
But since I get this strange parsing-behavior always at the end of the script, I thought it has something to do with that.
Hi Martin,
ok, I got it [Rdaemon offers flexible workflows ;) ]
The point is that the output of the R console which runs in the background will be parsed by a Perl script to clean the output since it could contain many control characters etc. I guess that's the problem.
Important: Which MacOSX and R version do you running?
and
Please do the following: - start a new Rdaemon session - execute your R code in question - go to the "R Console (Rdaemon)" menu > "Rdaemon Tools" > "Logfiles" > "Open console log file r_out" [short-cut ⌥⌘T] - a new window should appear showing the RAW output of the current R session's output [don't be confused ;)] - check the window's content for any confidential data and if you can send me the content please do this: -- open Finder; go to ~/Library/Application Support/Rdaemon; and send me the file "r_out" [please do not copy/save the content file to another file since editors can "destroy" its content due to possible control characters]
With this I can check the Perl script. Maybe I missed some output sequences to catch.
Best, --Hans
Hi Hans,
sorry for the delayed response.
Ok … I am working on 10.7.2 (so I already upgraded to lion – kind of regret it …)
R version 2.13.1 (2011-07-08).
So this is what I found in the first lines of the r_out-file:
WARNING: unknown option '--TMRdaemon'
ARGUMENT '2' __ignored__
[1] ".RProfile im User Order laedt:" [1] "Programmierung/R Arbeitsverzeichnis/eigene Funktionen/own.functions.R" > source("/Users/bath/Library/Application Support/Rdaemon/daemon/start.r") > sink('/Users/bath/Library/Application Support/Rdaemon/r_tmp');cat(geterrmessage());sink(file=NULL)
(the first two lines are just from a print-expression of the .Rprofile file that is loaded at the beginning of an R-session)
then my script seems to work fine till this point (line 177 in the original script) :
> x <- c(14, 17, 20, 23) > for(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i in 1:length(x)) { prfor(i i_reduced) Error: unexpected 'in' in "for(i in 1:length(x)) { prfor(i in" > full_matrix <- cbind(full_matrix, reduced_datfull_matrix <- cbind(full_matrix, reduced_datfull_matrix <- cbind(fse { final_matrix <- rbind(final_matrix, full_matrix) } Error: unexpected '{' in "full_matrix <- cbind(full_matrix, reduced_datfull_matrix <- cbind(full_matrix, reduced_datfull_matrix <- cbind(fse {"
the original code looks like this:
x <- c(12, 15, 18, 21) for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(3,4,1,2)) } x <- c(13, 16, 19, 22) for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(3,1,2)) } x <- c(14, 17, 20, 23) for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(2,1)) }
(the first two loops work without an error message only the last one is transformed in a strange way.
hope that helps ..?
On 14.10.2011, at 11:20, Hans-Jörg Bibiko wrote:
On 13 Oct 2011, at 23:23, Martin Batholdy wrote:
I start the Rdaemon with CMD+enter and then execute selected lines with the "execute selection" menu item. A small window pops up with a progress bar and the message "sending task to Rdaemon". After this is finished the selection converts to R-output.
I don't have a separate R-window open.
The script is actually not that large. It is just about 200 lines of code (8kb on disk).
But since I get this strange parsing-behavior always at the end of the script, I thought it has something to do with that.
Hi Martin,
ok, I got it [Rdaemon offers flexible workflows ;) ]
The point is that the output of the R console which runs in the background will be parsed by a Perl script to clean the output since it could contain many control characters etc. I guess that's the problem.
Important: Which MacOSX and R version do you running?
and
Please do the following:
- start a new Rdaemon session
- execute your R code in question
- go to the "R Console (Rdaemon)" menu > "Rdaemon Tools" > "Logfiles" > "Open console log file r_out" [short-cut ⌥⌘T]
- a new window should appear showing the RAW output of the current R session's output [don't be confused ;)]
- check the window's content for any confidential data and if you can send me the content please do this:
-- open Finder; go to ~/Library/Application Support/Rdaemon; and send me the file "r_out" [please do not copy/save the content file to another file since editors can "destroy" its content due to possible control characters]
With this I can check the Perl script. Maybe I missed some output sequences to catch.
Best, --Hans
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Ok,
I just observed the following:
When I delete one line of code in my original script, the strange parsing behavior also skips one line and the error now occurs in the next line:
output:
full_matrix <- data.matrix(prt_reduced) full_matrix <- cbind(full_matrix <- cbind(full_m
+ rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr final_matrix <- rbind(final_matrix, full_matrix) } Error: unexpected symbol in: "full_matrix <- cbind(full_matrix <- cbind(full_m rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"
original code:
x <- c(12, 15, 18, 21) for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(3,4,1,2)) } x <- c(13, 16, 19, 22) for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(3,1,2)) } x <- c(14, 17, 20, 23) for(i in 1:length(x)) { prt_reduced[,x[i]] <- reorder(prt_reduced[,x[i]], c(2,1)) } full_matrix <- data.matrix(prt_reduced) full_matrix <- cbind(full_matrix, reduced_data)
I am sorry, but I was not able to come up with sample code that replicates this behavior. I tried, but I have no clue how to trigger this with generic code.
On 14.10.2011, at 11:20, Hans-Jörg Bibiko wrote:
On 13 Oct 2011, at 23:23, Martin Batholdy wrote:
I start the Rdaemon with CMD+enter and then execute selected lines with the "execute selection" menu item. A small window pops up with a progress bar and the message "sending task to Rdaemon". After this is finished the selection converts to R-output.
I don't have a separate R-window open.
The script is actually not that large. It is just about 200 lines of code (8kb on disk).
But since I get this strange parsing-behavior always at the end of the script, I thought it has something to do with that.
Hi Martin,
ok, I got it [Rdaemon offers flexible workflows ;) ]
The point is that the output of the R console which runs in the background will be parsed by a Perl script to clean the output since it could contain many control characters etc. I guess that's the problem.
Important: Which MacOSX and R version do you running?
and
Please do the following:
- start a new Rdaemon session
- execute your R code in question
- go to the "R Console (Rdaemon)" menu > "Rdaemon Tools" > "Logfiles" > "Open console log file r_out" [short-cut ⌥⌘T]
- a new window should appear showing the RAW output of the current R session's output [don't be confused ;)]
- check the window's content for any confidential data and if you can send me the content please do this:
-- open Finder; go to ~/Library/Application Support/Rdaemon; and send me the file "r_out" [please do not copy/save the content file to another file since editors can "destroy" its content due to possible control characters]
With this I can check the Perl script. Maybe I missed some output sequences to catch.
Best, --Hans
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate