Closed mjskay closed 4 years ago
[x] create a custom code chunk type multiverse
[x] read code from multiverse
and execute it using inside
[x] Get multiverse object from options$multiverse (which gives a character) #18
[x] add keyboard shortcut
[x] print output of code in multiverse code block --- should behave similar to regular R code block
output for other types:
[x] ggplot
[x] any other types
Parsing expressions:
Not sure how to write unit tests for this. Any suggestions?
Ah, hrm. Dunno. There might be some ways of doing it by calling knitr functions directly? You could look at how the rmarkdown package does it?
Also, if you haven't already, this might be a case where seeing if it is even possible first is a good idea before writing tests... I have a feeling doing this in a seemless way inside rstudio might actually be hard or even impossible currently (at least, having the custom code chunk type work like r code with autocomplete and all that). Unless you've already figured that out?
Not sure I get the autocomplete part --- what do you mean?
like, having rstudio actually treat the code chunk as if it is an R code chunk when you are editing the code, so that it does nice things like lets you use autocomplete, does syntax highlighting, and formats outputted tables as interactive widgets and the like.
I am not sure about the formatting of tables, but it does still autocomplete and highlights the syntax by default
huh cool. can you get it to run R code inside Rstudio if you write a bare-bones chunk type that's called "multidy" ?
Yeah. I think I committed this to the dev branch. It's in the Rmd file. Like, if I have a code chunk called multidy and run some code into it, it will run it inside the multiverse
I get this error trying to load the multidy package on dev
:
Loading multidy
Error in eval(exprs[i], envir) (from eng_multidy.R#1) : object 'knit_engines' not found
if I load knitr it works but it doesn't display the output of the code chunk, it displays a number?
e.g. I would expect this to output the data frame from the current universe:
```{multidy, multiverse = M} df ```
but it outputs this:
101
I also get weird issues with multiline code chunks:
```{multidy, multiverse = M} x = 5 x + 1 ```
Error in parse(text = x) : <text>:1:6: unexpected symbol
1: x = 5x
^
After #2 is done, we can look into creating a custom code chunk type for markdown. Perhaps something like this:
Which would be compiled into something like this:
Then we could even create an addin + keyboard shortcut for RStudio to create these code chunks (much like there is a keyboard shortcut for creating R code chunks). Would want to make sure that autocomplete still works for these.