I am experimenting with gWidgetsWWW and found a strange error. I created a button with a handler for the knit2html report, which used the assignment operator data.table ": =". The message returned with this error:
The error :: = is defined for use only in j and (currently) only once; those. DT [i, col: = 1L] and DT [, newcol: = sum (colB), by = colA] are fine, but not DT [i, col]: = 1L, not DT [i] $ col: = 1L, not DT [, {newcol1: = 1L; newcol2: = 2L}]. See Help (": ="). Check is.data.table (DT) is set to TRUE.
The report generates, as expected, using knit2html directly, as well as through the Knit HTML RStudio button, so I'm not sure why it fails when the knit2html handler is called by the handler.
Here is the gWidgetsWWW "test_gui.R" window:
library(gWidgetsWWW) library(knitr) w<-gwindow("Test Window") g<-ggroup(horizontal=F,cont=w) b<-gbutton("Report Button",cont=g,handler=function(h,...){ knit2html("test_report.Rmd") localServerOpen("test_report.html") }) visible(w)<-T
Here is an example of an R Markdown Doc that causes an error:
Test Report =========== ```{r test_chunk} library(data.table) df<-data.frame(State=rownames(USArrests),USArrests) data.table(df)[,State:=tolower(State)] ```
I donβt know why, but when I call localServerOpen ("test_gui.R") and click the button, I get an error ...
Any ideas?
r knitr data.table gwidgets
Zach Waite Oct 28 2018-12-12T00: 00Z
source share