Giter Club home page Giter Club logo

Comments (11)

gaborcsardi avatar gaborcsardi commented on July 21, 2024

I think functions are cleaner. I also wanted to avoid doing NSE, although your quote way does that. Still, imo a function is simpler for people than a quote.

It is still not optimal, because we need to reset their environment manually, so you cannot pass a closure for example.

from callr.

gaborcsardi avatar gaborcsardi commented on July 21, 2024

I don't mind handling expressions, do you want to submit a PR? I think we can just put the expressions into a function, and then everything just works.

from callr.

gaborcsardi avatar gaborcsardi commented on July 21, 2024

I think it is cleaner to use functions, with the environment reset.

from callr.

kforner avatar kforner commented on July 21, 2024

I don't understand why ? Could you please give me an example ?
My current work-around is:

#' execute some R code via the R executable 
#' 
#' @param code 	a language object. 
#' @param ... 	for callr::r 
#' 
#' @return the code evaluation  
#' @export 
run_r_code <- function(code, ...) {
   fun <- function() {}  
   body(fun) <- code   
   callr::r(fun, ...)
}

from callr.

gaborcsardi avatar gaborcsardi commented on July 21, 2024

How do you pass an "argument" to code?

from callr.

kforner avatar kforner commented on July 21, 2024

I can't. And I just understand now why you use functions. I had to use bquote on my expressions to pass my local vars. Makes perfect sense.

The point was to run simple commands such as run_r_code(quote(Sys.getwd())
It can be improved with : body(fun) <- substitute(code)
to be: run_r_code(Sys.getwd()).
I agree that this is only syntactic sugar, for me it felt more natural than giving a function.

from callr.

gaborcsardi avatar gaborcsardi commented on July 21, 2024

I think it can be done with expressions, but it is just way simpler with a function, and function arguments. And it is not so much more to write function() expr than expr.

from callr.

kforner avatar kforner commented on July 21, 2024

Definitely. As I said I missed the args passing problem. And anyway I can use my wrapper so everybody is happy ;)

Thanks again for callr. Did you know that you can tremendously speed up R CMD check using r_cmd() by setting repos to "" ? It skips the utils::available.packages network download...

from callr.

gaborcsardi avatar gaborcsardi commented on July 21, 2024

Thanks again for callr. Did you know that you can tremendously speed up R CMD check using r_cmd() by setting repos to "" ? It skips the utils::available.packages network download...

That's a good idea.

Btw. I want to "fix" the available.packages caching problem, so that it is kept across sessions and updates properly: r-lib/crancache#14

from callr.

kforner avatar kforner commented on July 21, 2024

Btw. I want to "fix" the available.packages caching problem, so that it is kept across sessions and updates properly: r-lib/crancache#14

Very interesting indeed !
I was not aware of this r_hub project. Is it going well ? Who is driving it ?

from callr.

gaborcsardi avatar gaborcsardi commented on July 21, 2024

from callr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.