Skip to content
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

Sorry to disturb you (problems to run "plotModel" under RStudio "Source as Local Job") #783

Open
NMarkgraf opened this issue Feb 28, 2021 · 2 comments

Comments

@NMarkgraf
Copy link

Hi!

I run into trouble when I generate a R markdown via a R script using the RStudio feature "Source as a Local Job".

I got the following to peaces of code:

render.R:

library(rmarkdown)

rmarkdown::render(
    input = "test.Rmd",
    encoding = "UTF-8",
    clean = FALSE
)

test.Rmd:

---
title: "test"
author: "Norman Markgraf"
date: "2/28/2021"
output: html_document
---

` ``{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(mosaic)
` ``

## May be a bug

` ``{r}
tips <- reshape2::tips

linmod <- lm(tip ~ total_bill + smoker + sex, data = tips)

plotModel(linmod)
` ``

(Spaces inserted for better display here!)

Running render.R als source works perfect. But if I try to run it as a "source as local job" it will stop with the following error:

Quitting from lines 16-21 (test.Rmd)
Fehler in eval(x$call$data, environment(x$call$formula)) :
Objekt 'tips' nicht gefunden
Ruft auf: sourceWithProgress ... plotModel.default -> plotModel -> parseModel -> eval -> eval
Ausführung angehalten

Does anybody have a clue why this error occurs? - Is it a mosaic or a Rstudio issue? - Any help would by welcome.

Thanks ins advance

Yours
Norman

@NMarkgraf NMarkgraf changed the title Sorry to disturb you (problems with plotModel unter RStudio Source as local job) Sorry to disturb you (problems to run "plotModel" under RStudio "Source as Local Job") Feb 28, 2021
@nicholasjhorton
Copy link
Contributor

It's somewhat obvious from @NMarkgraf's note that this isn't a problem when the code is run as a reprex:

suppressPackageStartupMessages(library(mosaic))
tips <- reshape2::tips
linmod <- lm(tip ~ total_bill + smoker + sex, data = tips)
plotModel(linmod)

Created on 2021-02-28 by the reprex package (v1.0.0)

@rpruim
Copy link
Contributor

rpruim commented Mar 1, 2021

I haven't had time to investigate, but two thoughts come to mind.

  1. @dtkaplan, might this be related to findZeros doesn't look in right environment for expr, at least on {learnr} #781 ?

  2. I discovered last week a very odd interaction between {mosaic}, {dagitty}, and {knitr}. The following knits fine, but
    commenting out the second line leads to "object of type closure is not subsettable".

library(dagitty)
dagitty("dag{}")     # error if this line is removed.
library(mosaic)
dagitty("dag{A -> B -> C}")

I've also seen some inconsistencies between console and knitting documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants