0

I have data frames in Excel, that I'd like to run models on and return predictions and summary stats. Currently, I export the data to R, run a linear model and return the coefficients using XLConnect. While this works for linear models, it does not work well for more complicated models, like generalized additive models as the coefficients are not fully usable. I was wondering if there was a better way to do the operation above.

Example of what I do now, that is non-optimal:

library(XLConnect)
dat <- data.frame(rsp = rnorm(100, 0, 1), 
                  pred1 = rnorm(100, 0, 1), 
                  pred2 = rnorm(100, 0, 1))
model <- lm(rsp ~ pred1 + pred2, data = dat)
writeWorksheetToFile("model1.xlsx", 
                 data = summary(dat), 
                 sheet = "summary", 
                 header = TRUE,
                 clearSheets = TRUE)
John Coleman
  • 51,337
  • 7
  • 54
  • 119
IJH
  • 167
  • 1
  • 11
  • 3
    See [RExcel](http://rcom.univie.ac.at/download.html); but your question is off-topic for this website. – nrussell Jul 12 '16 at 16:03
  • Why is it off-topic? – IJH Jul 12 '16 at 16:16
  • 2
    [From here](http://stackoverflow.com/help/on-topic), *"Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it"*. – nrussell Jul 12 '16 at 16:18
  • 1
    @nrussell IJH was simply asking for a better way -- that better way might be to use some other library or off-site resource, or it might not. The question itself is open-ended and clearly on topic on Stack Overflow. Also, if `RExcel` or a better use of `xlconnect` is the answer, it seems on-topic given the existence of corresponding tags. – John Coleman Jul 12 '16 at 16:35
  • @John Coleman Prior to your edit OP asked *"I was wondering if there was a package or library that connects the two in the manner above."* which sounds an awful lot like a request for a software recommendation, IMO. This may or may not still be the case since your rewording, although I feel that the question may be considered "too broad" regardless. And the fact that an `RExcel` tag exists does not imply that *any* question possibly related to RExcel is on topic for this website. – nrussell Jul 12 '16 at 16:49
  • 1
    @nrussell I just edited the tags. Someone else (perhaps OP) edited out the part that explicitly asked for a package or library. – John Coleman Jul 12 '16 at 16:55
  • 1
    @John Coleman my mistake, I didn't notice that OP had reworded it. However, my first two comments were made prior to their edit. – nrussell Jul 12 '16 at 17:00

1 Answers1

1

There are a couple of alternatives. Im currently using BERT - Basic Excel R Toolkit (https://bert-toolkit.com/)

i guess this solution or other 3rd party alternatives might help you with your goal.

Alexandre Ludolf
  • 196
  • 1
  • 10