Description Usage Arguments Value Examples
Many tree parsers (e.g., online, LaTeX, etc.) require square braces in the parse. These functions prepare the parse for use in other plotting venues.
1 2 3 | as_square_brace(x, ...)
as_square_brace_latex(x, ...)
|
x |
A parse vector from |
... |
ignored. |
as_square_brace
- returns a vector appropriate for use in a
many online parse tree generators.
as_square_brace_latex
- returns a cat
vector appropriate for use in a LaTeX document.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | ## Not run:
## pass `as_square_brace` to an online parse tree:
## http://yohasebe.com/rsyntaxtre
parse_ann <- parse_annotator()
x <- parser("Really, I like chocolate because it is good.", parse_ann)
xsquared <- as_square_brace(x)
## get tree from web
if (!require("pacman")) install.packages("pacman"); library(pacman)
p_load_gh("ropensci/RSelenium")
p_load(XML, RSelenium)
# download Selenium Server, if not already present
checkForServer(); Sys.sleep(2)
# Open a remote browser
remDr <- remoteDriver(
remoteServerAddr = "localhost",
port = 4444,
browserName = "firefox"
)
remDr$open()
## Now we pass the url from above and the page is opened
remDr$navigate("http://yohasebe.com/rsyntaxtree/")
webElem <- remDr$findElement("css", "textarea[id='data']")
webElem$sendKeysToElement(list(xsquared)); Sys.sleep(.5)
webElem2 <- remDr$findElement("css", "button[id='draw_png']")
webElem2$clickElement()
## LaTeX Version
## copy .Rmd from parser package
treeloc <- system.file("exta_files/testtree.Rmd", package = "parser")
file.copy(treeloc, getwd())
## look at .Rmd
file.edit("testtree.Rmd")
## render .Rmd file
p_load(rmarkdown)
rmarkdown::render("testtree.Rmd")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.