Best way to use R in Ruby

前端 未结 2 1701
感动是毒
感动是毒 2021-01-30 18:35

I want to visualize some of my statistical caluclations in Ruby.

My problem is, that I can\'t find the right gem for that.

rsruby doesn\'t seem to be up-to-date

相关标签:
2条回答
  • 2021-01-30 19:03

    As @Hansi mentioned, RServe is the best way I've found to run R remotely. If you're using Ruby from a web-context especially, RServe can offer some nice benefits.

    Best of all (in my mind), you don't get locked into any one programming framework, as there are RServe clients for a variety of languages including Java and C++. When using web-accessible platforms, you can even keep Rserve running on a separate host and route traffic over TCP/IP for added security.

    0 讨论(0)
  • 2021-01-30 19:09

    I just saw this post and thought I should comment since I use R pretty extensively. If you are coming from an R background the best gem I have found is Rinruby. The reason it is fantastic is because you don't interpret the commands in ruby, you use actual R code. For example:

    require "rinruby"      
    #Set all your variables in Ruby
    n = 10
    beta_0 = 1
    beta_1 = 0.25
    alpha = 0.05
    seed = 23423
    R.x = (1..n).entries
    #Use actual R code to perform the analysis
    R.eval <<EOF
      set.seed(#{seed})
      y <- #{beta_0} + #{beta_1}*x + rnorm(#{n})
      fit <- lm( y ~ x )
      est <- round(coef(fit),3)
      pvalue <- summary(fit)$coefficients[2,4]
    EOF
    

    On the Rinruby website I listed above there are some fantastic examples to get you started. Hope this helped.

    -Sean

    0 讨论(0)
提交回复
热议问题