Does the R plugin work?

The help for the R plugin shows that it should work in that plugin by using v():

The v() function can be used in order to include the contents of the R graphics window inside your worksheet.

Actually plots embedding works fine and the workflow is close to R console. After doing a plot as you say, a new window with the plot opens. For example

t=seq(0,10,0.1)
y=sin(t)
plot(t,y,type="l",xlab="t",ylab="sin(t)")

Then you can build it step-by-step, such as doing

title("sin(t)")
legend("bottomright",legend=c("sin(t)"),lty=1:2,cex=0.8)

After having your graph, you can embed it with

v()

You can close the window programmatically with

dev.off()

Edit: Oh, you found it.

1 Like

@jeroen found it, I did not make the effort of reading the help :slight_smile:

Is this solution valid for Windows as well?

I cannot make R work in TeXmacs: every time I insert a new session the plug-in gets started but stucks with a message of “Busy…” and does nothing more.

Does anybody else find this issue?

Hi @imateos and welcome to the forum.
The R plugin under Windows doesn’t work for me either.
I have looked very quickly at the initialization code for the R plugin and there are :winpath commands, which as far as I understand indicate that who wrote it wanted to make it work under Windows as well.
I will have time to look at the code with more calm next week - I never tried to get a plugin running under Windows so it might take a while before I figure out how-to.
But maybe someone else can be quicker than me.

Giovanni

1 Like

The first thing to check is where the executable is installed and then whether TeXmacs can find it. If these checks pass then there could be a problem with the initialisation code.

The fact that the session appears at all would indicate that the executable is found in the path.

Could you restart TeXmacs, enable “Tools -> Debugging tool”, then enable “Debug -> io” and start a session? Then go to “Debug -> Consoles -> Debugging consoles” to see the debugging output.

I get

Error: cannot start 'tm_r'

By the way, I find it inconvenient that I cannot copy from the debugging console—I will place a feature request in Savannah :wink:

Said this, I do not understand the interaction between the various components, there is R code (texmacs.r) and C code (tm_r.c), I assume tm_r.c is the tm_r that appeats in the console: but is it part of TeXmacs or part of R? And should there be a compiled tm_r code?

Hi
I don`t know if this helps, but i have noticed that tm_r is not on /texmac/plugins/r/bin on github.
I happen to have it in my local copy in widows. However i have tried to compile the file by opening command line, pointing to the plugins/r directory where Cmake is, then launching make and and this is the result:

make
gcc -I…/…/src/System src/tm_r.c -o bin/tm_r -lutil
src/tm_r.c:11:10: fatal error: config.h: No such file or directory
#include “config.h”
^~~~~~~~~~
compilation terminated.
make: *** [Makefile:17: bin/tm_r] Error 1

I guess that something is incomplete in C instalation and does not allow to compile or even the compiled file tm_r is not operative.

My expertise on C is limited, however this is what i have noticed so far

Regards

Pedro

Thanks for looking into this @Pdiazs.

To compile tm_r with cmake, you create a build directory in the main TeXmacs source directory, then do cmake .. from that subdirectory and “make tm_r”. Cmake configures a make target for tm_r in the build directory, not in the source directory. Any Makefiles in the source directory are likely from the autotools build system.

In my system the compiled binary tm_r then gets installed in /usr/share/TeXmacs/plugins/r/bin/tm_r. It should be compiled and installed on Windows, too. If it isn’t, we need to look into why.

I have not succeeded in executing your instructions (perhaps I did not understand them) so I adapted them in a way that I thought sensible:

  • I created the build directory in the /plugins/r` directory
  • I run cmake .. -G "MinGW Makefiles" using PowerShell (btw with two dots only, I think there you have one dot too many) to tell cmake that it has to configure the build for MinGW; this generates a Makefile in the build directory, that has a rule for tm_r
  • I run make tm_r in the build directory

When I do that, I expect minGW to generate an executable file or stop with errors, but neither happens. I get instead

Microsoft Windows [Version 10.0.19041.985]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

And no other output.

After that, I cannot find a tm_r executable anywhere.

By the way, I do not understand how the linker can find config.h (first included header, line 11)

The CMakeLists.txt file in the plugins/r directory makes use of variables set up by the top level CMakeLists.txt. If you call Cmake on the subdirectory, it will not work. You need to go to the directory of the topmost CMakeLists.txt (this one ), create a build subdirectory, go into it and call cmake .. from there.

Anyway, the first thing to figure out is whether there is a compiled binary in the distributed TeXmacs package. If you install TeXmacs from texmacs.org, does it install tm_r?

Thanks for the explanation. Then I have to figure out how to use QT under MinGW (point where cmake stops at the moment).
Will write when I make progress.
G.

It does not seems so (I’ve verified in my virtual machine). Maybe there is a bug in the installer.

2 Likes

Neither in my TeXmacs installation (I checked under C:\Program Files (x86)\TeXmacs\plugins\r\bin)

1 Like

Then probably the next step is to submit a bug report on Savannah? Or for this case is something else better (e.g. talking to the person who compiles for Windows)?

Perhaps @pjoyez knows more about this? (see https://github.com/slowphil/mingw-w64-texmacs)

I think it would be best to submit a bug report in any case, such that we don’t loose track of this issue.

2 Likes

https://savannah.gnu.org/bugs/index.php?60899

2 Likes

There is a file tm_r texmacs/plugins/r/bin, (it is compiled, not readable)

I do not know if this helps

regards