-
Notifications
You must be signed in to change notification settings - Fork 0
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
Is there a way to return to R from lua_shell() while keeping the lua state intact? #3
Comments
Hello! If you just hit return on an empty line, the Lua shell should return you to R leaving the Lua state intact (as it operates on the default state, unless you pass in an alternative state). I didn't realise I hadn't documented this, sorry! Let me know if that isn't working for you. Thanks, Nick |
Hi, Nick, yes, thanks, hitting return works, perfectly! Being able to go in and out of the lua shell is very handy :-) Two follow up questions:
It doesn't look like one can do that right now in luajr; instead it looks like one always needs to do instead:
Is that correct or is there another more efficient way to reference Lua values in R session?
Create R List in R:
Create R List in Lua via a Lua table and pass to R:
Create list object in lua using luajr module:
But don't quite understand how to set up a key, value list like "test" in the above examples. The documentation indicates one uses ListName(attr,x), but I can't figure out how to make that work. Thus, the bottom line question is what would be the advantage of creating R objects inside LuaJit, and if there is an advantage, it would be helpful if you could provide an example of how to create a key, value list in Lua and answer as to whether that list created in Lua could be referenced directly from R. Thanks again, Sincerely, Mike |
|
Thanks, Nick, I think I understand better now (part of the problem was leaving off the ()). It looks like then by defining objects as R objects using the luajr module in lua, one is assured that when they get passed to R via the "lua('return obj')" function that one is getting the specific type of R object that one wants from lua rather than having the lua('return obj') function determine the best R object to convert the lua object it is passed to. It also still seems that the answer to #1 still holds true: even though one has created a R list in lua as per your example ("test = luajr.list(); test.x = 1") R won't know about the variable "test" until still passed to R via a "test = lua('return test')" function call. I think I now have enough information I need to use luajr successfully 😊 |
Hi, thanks for making a great R-lua bridge! There aren't many in existence... :-)
Your lua_shell function is really helpful, as it is easier just to open the lua_shell to do some lua programming while in R instead of passing everything in a lua() call. However, it doesn't seem that one can then easily get back to R from the shell; it would be helpful if I could do some programming in the lua_shell and then return to R and then perhaps return the variables or selected functions from luajit that I programmed when in the lua_shell. Is that possible or might that be possible in a future version of luajr? The only way for now that I could figure out to get out of lua_shell is by the standard lua os.exit() method which then unfortunately returns me to the bash command line and closes my R session.
The text was updated successfully, but these errors were encountered: