├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── NAMESPACE ├── R ├── dagtex.R ├── draw_dag.R ├── edges.R ├── nodes.R ├── utils-pipe.R ├── utils.R └── zzz.R ├── README.Rmd ├── README.md ├── README_cache ├── latex │ ├── __packages │ ├── tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.RData │ ├── tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.rdb │ └── tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.rdx ├── tex_temp.tex ├── tex_tempDoc.tex └── texput.log ├── dagtex.Rproj └── man ├── add_edges.Rd ├── add_nodes.Rd ├── dagtex.Rd ├── figures ├── README-example-1.png ├── README-example-2.png ├── README-tikz-ex-1.pdf └── README-tikz-ex-1.png ├── get_latex_code.Rd ├── hello.Rd ├── insert_latex.Rd ├── pipe.Rd ├── plot_dagtex.Rd ├── print.dagtex.Rd └── tikz_picture.Rd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^README\.Rmd$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | README.pdf 6 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: dagtex 2 | Type: Package 3 | Title: What the Package Does (Title Case) 4 | Version: 0.1.0 5 | Author: Who wrote it 6 | Maintainer: The package maintainer 7 | Description: More about what it does (maybe more than one line) 8 | Use four spaces when indenting paragraphs within the Description. 9 | License: What license is it under? 10 | Encoding: UTF-8 11 | LazyData: true 12 | Imports: 13 | texPreview (>= 1.3.0), 14 | magrittr, 15 | purrr, 16 | rmarkdown (>= 1.11.3) 17 | Roxygen: list(markdown = TRUE) 18 | RoxygenNote: 6.1.1 19 | Remotes: 20 | metrumresearchgroup/texPreview, 21 | rstudio/rmarkdown 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(plot,dagtex) 4 | S3method(print,dagtex) 5 | export("%>%") 6 | export(add_curved_edge) 7 | export(add_edge) 8 | export(add_node) 9 | export(add_swig_node) 10 | export(annotate_edge) 11 | export(dagtex) 12 | export(get_latex_code) 13 | export(insert_latex) 14 | export(plot_dagtex) 15 | export(tikz_picture) 16 | importFrom(magrittr,"%>%") 17 | -------------------------------------------------------------------------------- /R/dagtex.R: -------------------------------------------------------------------------------- 1 | #' Create a new DAG 2 | #' 3 | #' @return 4 | #' @export 5 | #' 6 | #' @examples 7 | dagtex <- function(...) { 8 | structure( 9 | list( 10 | nodes = list(), 11 | edges = list(), 12 | latex = list(), 13 | texPreview_options = list(...) 14 | ), 15 | class = "dagtex" 16 | ) 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /R/draw_dag.R: -------------------------------------------------------------------------------- 1 | #' Plot DAGs 2 | #' 3 | #' @param .dag 4 | #' @param density 5 | #' @param ... 6 | #' 7 | #' @return 8 | #' @export 9 | #' 10 | #' @examples 11 | plot_dagtex <- function(.dag, density = 320, ...) { 12 | 13 | latex_code <- get_latex_code(.dag, add_header = FALSE) 14 | 15 | if (knitr::is_latex_output()) return(knitr::asis_output(latex_code)) 16 | 17 | is_knit_image <- isTRUE(getOption("knitr.in.progress")) 18 | 19 | tikz_opts <- '\\usetikzlibrary{positioning, calc, shapes.geometric, 20 | shapes.multipart, shapes, arrows.meta, arrows, decorations.markings, 21 | external, trees}' 22 | 23 | pkg_opts <- texPreview::build_usepackage(pkg = 'tikz', uselibrary = tikz_opts) 24 | 25 | if (is_knit_image) { 26 | return( 27 | texPreview::tex_preview( 28 | latex_code, 29 | usrPackages = pkg_opts, 30 | density = density, 31 | resizebox = FALSE, 32 | returnType = "html", 33 | ...) 34 | ) 35 | } 36 | 37 | texPreview::tex_preview( 38 | latex_code, 39 | usrPackages = pkg_opts, 40 | density = density, 41 | ...) 42 | } 43 | 44 | #' Explicitly draw DAG 45 | #' 46 | #' @param x 47 | #' 48 | #' @param ... 49 | #' 50 | #' @export 51 | #' @method print dagtex 52 | print.dagtex <- function(x, ...) { 53 | nodes_and_edges <- x[c("nodes", "edges")] 54 | is_empty_dag <- all(purrr::map_lgl(nodes_and_edges, purrr::is_empty)) 55 | 56 | if (is_empty_dag) { 57 | cat("An empty DAG") 58 | return(invisible(x)) 59 | } 60 | 61 | # wrap in print for print.magick-image when obj is HTML 62 | print(plot_dagtex(x, ...), info = FALSE) 63 | } 64 | 65 | #' @export 66 | #' @method plot dagtex 67 | plot.dagtex <- print.dagtex 68 | 69 | #' Insert LaTeX 70 | #' 71 | #' @param .dag 72 | #' @param ... 73 | #' 74 | #' @return 75 | #' @export 76 | #' 77 | #' @examples 78 | insert_latex <- function(.dag, ...) { 79 | .dag$latex <- c(.dag$latex, ...) 80 | 81 | .dag 82 | } 83 | 84 | #' Create tikz picture 85 | #' 86 | #' @param ... 87 | #' @param scale 88 | #' @param scale_x 89 | #' @param scale_y 90 | #' 91 | #' @return 92 | #' @export 93 | #' 94 | #' @examples 95 | tikz_picture <- function(..., scale = NULL, scale_x = NULL, scale_y = NULL) { 96 | # TODO: should just be options? 97 | dag_scale <- paste0( 98 | "[", 99 | ifelse(is.null(scale), "", paste0("scale=", scale)), 100 | ifelse(is.null(scale_x), "", paste0("xscale=", scale_x)), 101 | ifelse(is.null(scale_y), "", paste0("yscale=", scale_y)), 102 | "]" 103 | ) 104 | 105 | if (dag_scale == "[]") dag_scale <- NULL 106 | 107 | begin_tikzpicture <- paste0("\\begin{tikzpicture}", dag_scale) 108 | 109 | 110 | paste( 111 | c( 112 | begin_tikzpicture, 113 | "\\tikzset{>=latex}", 114 | "\\tikzstyle{Arrow} = [->, thick, preaction = {decorate}]", 115 | "\\tikzstyle{DoubleArrow} = [<->, thick, preaction = {decorate}]", 116 | ..., 117 | "\\end{tikzpicture}" 118 | ), 119 | collapse = "\n" 120 | ) 121 | } 122 | 123 | #' Get LaTeX code 124 | #' 125 | #' @param .dag 126 | #' @param add_header 127 | #' 128 | #' @return 129 | #' @export 130 | #' 131 | #' @examples 132 | get_latex_code <- function(.dag, add_header = TRUE) { 133 | 134 | latex_code <- tikz_picture(latexify_dag(.dag)) 135 | 136 | if (add_header) { 137 | tikz_opts <- '\\usetikzlibrary{positioning, calc, shapes.geometric, 138 | shapes.multipart, shapes, arrows.meta, arrows, decorations.markings, 139 | external, trees}' 140 | 141 | pkg_opts <- texPreview::build_usepackage(pkg = 'tikz', uselibrary = tikz_opts) 142 | latex_code <- paste(c(pkg_opts, latex_code), collapse = "\n") 143 | } 144 | 145 | structure(latex_code, class = "latex_code") 146 | } 147 | 148 | print.latex_code <- function(x, ...) { 149 | cat(x, ...) 150 | } 151 | 152 | latexify_dag <- function(.dag) { 153 | if (any_swig_nodes(.dag)) {} 154 | nodes_latex <- purrr::map_chr(.dag$nodes, latexify_node) 155 | edges_latex <- purrr::map_chr(.dag$edges, latexify_edge) 156 | nodes_and_edges <- c(nodes_latex, edges_latex) 157 | 158 | paste(nodes_and_edges, collapse = "\n") 159 | } 160 | 161 | latexify_node <- function(.node) { 162 | if (.node$is_swig) return(latexify_swig(.node)) 163 | 164 | node_options <- compile_node_options(.node) 165 | node_id <- paste0("(", .node$id, ") ") 166 | node_text <- paste0("{", .node$name, "}") 167 | 168 | 169 | paste0( 170 | "\\node", 171 | node_options, 172 | node_id, 173 | node_text, 174 | ";" 175 | ) 176 | } 177 | 178 | compile_node_options <- function(.node) { 179 | shape <- ifelse( 180 | .node$shape != "", 181 | paste0(.node$shape, ", draw"), 182 | "" 183 | ) 184 | 185 | compiled_options <- paste0(shape, .node$position, .node$options, collapse = ", ") 186 | 187 | node_options <- paste0("[", compiled_options, "] ") 188 | if (node_options == "[] ") node_options <- NULL 189 | node_options 190 | } 191 | 192 | latexify_swig <- function(.node) { 193 | 194 | node_options <- paste0("[", .node$options, "]") 195 | if (node_options == "[]") node_options <- "" 196 | node_id <- paste0("(", .node$id, ")") 197 | node_text <- paste0("{", .node$name, "}") 198 | 199 | 200 | paste( 201 | "\\node", 202 | node_options, 203 | node_id, 204 | node_text, 205 | ";" 206 | ) 207 | } 208 | 209 | latexify_edge <- function(.edge) { 210 | 211 | edge_from <- paste0(" (", .edge$from, ") ") 212 | edge_to <- paste0("(", .edge$to, ")") 213 | edge_options <- compile_edge_options(.edge) 214 | 215 | if (.edge$is_curved) { 216 | line_code <- "to " 217 | line_curve <- ifelse( 218 | .edge$curve == "up", 219 | "[out=25, in=160] ", 220 | "[out=-25, in=-160] " 221 | ) 222 | } else { 223 | line_code <- "-- " 224 | line_curve <- NULL 225 | } 226 | 227 | 228 | paste0( 229 | "\\draw", 230 | edge_options, 231 | edge_from, 232 | line_code, 233 | line_curve %||% "", 234 | .edge$annotate %||% "", 235 | edge_to, 236 | ";" 237 | ) 238 | } 239 | 240 | compile_edge_options <- function(.edge) { 241 | linetype <- ifelse( 242 | .edge$linetype != "solid", 243 | .edge$linetype, 244 | "" 245 | ) 246 | 247 | arrow_type <- ifelse(.edge$is_double_arrow, "DoubleArrow", "Arrow") 248 | 249 | compiled_options <- paste0(arrow_type, linetype, .edge$options, collapse = ", ") 250 | 251 | edge_options <- paste0("[", compiled_options, "]") 252 | edge_options 253 | } 254 | -------------------------------------------------------------------------------- /R/edges.R: -------------------------------------------------------------------------------- 1 | #' Add edges 2 | #' 3 | #' @param .dag 4 | #' @param .from 5 | #' @param .to 6 | #' @param start_position 7 | #' @param end_position 8 | #' @param .options 9 | #' @param is_curved 10 | #' @param curve 11 | #' @param is_double_arrow 12 | #' @param linetype 13 | #' @param annotate 14 | #' @param ... 15 | #' 16 | #' @return 17 | #' @export 18 | #' 19 | #' @examples 20 | #' 21 | #' @rdname add_edges 22 | add_edge <- function(.dag, .from, .to, start_position = NULL, end_position = NULL, 23 | .options = NULL, is_curved = FALSE, curve = "up", 24 | is_double_arrow = FALSE, linetype = "solid", 25 | annotate = NULL, ...) { 26 | 27 | id <- count_edges(.dag) + 1 28 | 29 | if (is.character(.from)) .from <- get_id(.dag, .from) 30 | if (is.character(.to)) .to <- get_id(.dag, .to) 31 | 32 | add_edge_to_dag( 33 | .dag = .dag, 34 | .id = id, 35 | .from = .from, 36 | .to = .to, 37 | start_position = start_position, 38 | end_position = end_position, 39 | .options = .options, 40 | is_curved = is_curved, 41 | curve = curve, 42 | is_double_arrow = is_double_arrow, 43 | linetype = linetype, 44 | annotate = annotate 45 | ) 46 | } 47 | 48 | #' @export 49 | #' @rdname add_nodes 50 | add_curved_edge <- function(.dag, .from, .to, start_position = NULL, end_position = NULL, 51 | .options = NULL, curve = "up", 52 | is_double_arrow = FALSE, linetype = "solid", 53 | annotate = NULL, ...) { 54 | add_edge(.dag = .dag, .from = .from, .to = .to, start_position = start_position, 55 | end_position = end_position, .options = .options, is_curved = TRUE, 56 | curve = curve, is_double_arrow = is_double_arrow, linetype = linetype, 57 | annotate = annotate, ...) 58 | } 59 | 60 | add_edge_to_dag <- function(.dag, .id, .from, .to, start_position = NULL, 61 | end_position = NULL, .options = NULL, is_curved = FALSE, 62 | curve = "up", is_double_arrow = FALSE, linetype = "solid", 63 | annotate = NULL) { 64 | 65 | .from <- process_position(.from, start_position) 66 | .to <- process_position(.to, end_position) 67 | 68 | 69 | edge <- structure( 70 | list( 71 | id = .id, 72 | from = .from, 73 | to = .to, 74 | is_curved = is_curved, 75 | curve = curve, 76 | options = .options, 77 | linetype = linetype, 78 | is_double_arrow = is_double_arrow, 79 | annotate = annotate 80 | ), 81 | class = "dagtex_edge" 82 | ) 83 | 84 | 85 | .dag$edges[[.id]] <- edge 86 | 87 | .dag 88 | } 89 | 90 | 91 | #' @export 92 | #' @rdname add_nodes 93 | annotate_edge <- function(text, placement = "midway", position = "above") { 94 | paste0("node[", placement, ", ", position, "]{", text, "}") 95 | } 96 | 97 | count_edges <- function(.dag) length(.dag$edges) 98 | 99 | process_position <- function(target, position) { 100 | ifelse( 101 | !is.null(position), 102 | paste0(target, ".", position), 103 | target 104 | ) 105 | } 106 | 107 | get_id <- function(.dag, .var) { 108 | node_names <- purrr::map_chr(.dag$nodes, "name") 109 | node_ids <- purrr::map_dbl(.dag$nodes, "id") 110 | node_index <- which(node_names == .var) 111 | node_ids[node_index] 112 | } 113 | -------------------------------------------------------------------------------- /R/nodes.R: -------------------------------------------------------------------------------- 1 | #' Add nodes 2 | #' 3 | #' @param .dag 4 | #' @param .name 5 | #' @param .options 6 | #' @param x 7 | #' @param y 8 | #' @param right_of 9 | #' @param left_of 10 | #' @param above 11 | #' @param below 12 | #' @param shape 13 | #' @param is_swig 14 | #' @param ... 15 | #' 16 | #' @return 17 | #' @export 18 | #' 19 | #' @examples 20 | #' 21 | #' @rdname add_nodes 22 | add_node <- function(.dag, .name, .options = NULL, x = NULL, y = NULL, 23 | right_of = NULL, left_of = NULL, 24 | above = NULL, below = NULL, shape = NULL, is_swig = FALSE, 25 | ...) { 26 | 27 | id <- count_nodes(.dag) + 1 28 | 29 | coords <- get_node_coords( 30 | x = x, 31 | y = y 32 | ) 33 | 34 | position <- get_node_position( 35 | .dag, 36 | id, 37 | coords, 38 | right_of = right_of, 39 | left_of = left_of, 40 | above = above, 41 | below = below 42 | ) 43 | 44 | add_node_to_dag( 45 | .dag = .dag, 46 | .name = .name, 47 | .id = id, 48 | .coords = coords, 49 | .position = position, 50 | .options = .options, 51 | shape = shape, 52 | is_swig = is_swig 53 | ) 54 | } 55 | 56 | 57 | #' @export 58 | #' @rdname add_nodes 59 | add_swig_node <- function(.dag, .left, .right, .options = NULL, x = NULL, y = NULL, 60 | right_of = NULL, left_of = NULL, 61 | above = NULL, below = NULL, shape = NULL, ...) { 62 | add_node(.dag, .name = c(.left, .right), .options = .options, x = x, y = y, 63 | right_of = right_of, left_of = left_of, 64 | above = above, below = below, shape = shape, is_swig = TRUE, ...) 65 | } 66 | 67 | any_swig_nodes <- function(.dag) { 68 | any(purrr::map_lgl(.dag$nodes, ~.x$is_swig)) 69 | } 70 | 71 | add_node_to_dag <- function(.dag, .name, .id, .coords, .position, .options, shape = NULL, is_swig = FALSE) { 72 | node <- structure( 73 | list( 74 | name = .name, 75 | id = .id, 76 | coords = .coords, 77 | position = .position, 78 | shape = shape, 79 | is_swig = is_swig, 80 | options = .options 81 | ), 82 | class = "dagtex_node" 83 | ) 84 | 85 | .dag$nodes[[.id]] <- node 86 | 87 | .dag 88 | } 89 | 90 | get_node_position <- function(.dag, .id, coords, right_of = NULL, 91 | left_of = NULL, above = NULL, below = NULL) { 92 | # don't set position if coordinates are given or if this is the first node 93 | if (!is.null(coords) | .id == 1) return(NULL) 94 | 95 | positions <- c(right_of %||% NA, left_of %||% NA, above %||% NA, below %||% NA) 96 | positions_not_na <- purrr::map_lgl(positions, ~!is.na(.x)) 97 | 98 | if (any(positions_not_na)) { 99 | location <- c("right", "left", "above", "below")[positions_not_na] 100 | 101 | next_to <- positions[positions_not_na] %>% 102 | unique() %>% 103 | purrr::map_dbl(~ifelse(is.character(.x), get_id(.dag, .x), .x)) 104 | 105 | position <- paste( 106 | location, 107 | "=of", 108 | next_to 109 | ) 110 | return(position) 111 | } 112 | 113 | # by default, place to the right of previous node 114 | next_to <- .id - 1 115 | position <- paste("right =of", next_to) 116 | 117 | position 118 | } 119 | 120 | get_node_coords <- function(x = NULL, y = NULL) { 121 | if (!is.null(x) & !is.null(x)) return(paste0("(", x, ",", y, ")")) 122 | 123 | NULL 124 | } 125 | 126 | count_nodes <- function(.dag) length(.dag$nodes) 127 | 128 | last_node <- function() { 129 | function(.dag) { 130 | previous_node <- count_nodes(.dag) - 1 131 | 132 | if (previous_node == 0) { 133 | warning("No previous node: returning `NA`") 134 | return(NA) 135 | } 136 | 137 | previous_node 138 | } 139 | } 140 | 141 | -------------------------------------------------------------------------------- /R/utils-pipe.R: -------------------------------------------------------------------------------- 1 | #' Pipe operator 2 | #' 3 | #' See \code{magrittr::\link[magrittr]{\%>\%}} for details. 4 | #' 5 | #' @name %>% 6 | #' @rdname pipe 7 | #' @keywords internal 8 | #' @export 9 | #' @importFrom magrittr %>% 10 | #' @usage lhs \%>\% rhs 11 | NULL 12 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | `%||%` <- purrr::`%||%` 2 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname = find.package("dagtex"), pkgname = "dagtex") { 2 | load_packages <- getOption("dagtex.load_tikz", default = TRUE) 3 | if (load_packages) { 4 | knitr::knit_meta_add( 5 | list( 6 | rmarkdown::latex_dependency_tikz( 7 | c("positioning", 8 | "calc", 9 | "shapes.geometric", 10 | "shapes.multipart", 11 | "shapes", 12 | "arrows.meta", 13 | "arrows", 14 | "decorations.markings", 15 | "external", 16 | "trees") 17 | ) 18 | ) 19 | ) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r setup, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/README-", 12 | out.width = "35%" 13 | ) 14 | ``` 15 | 16 | # dagtex 17 | 18 | The goal of dagtex is to to create tikz DAGs from R. Under very early development and a bit of neglect. 19 | 20 | ## Installation 21 | 22 | You can install the development version of dagtex from GitHub with: 23 | 24 | ``` r 25 | # install.packages("remotes") 26 | remotes::install_github("malcolmbarrett/dagtex") 27 | ``` 28 | 29 | ## Example 30 | 31 | This is a basic example which shows you how to solve a common problem: 32 | 33 | ```{r example} 34 | library(dagtex) 35 | 36 | dagtex() %>% 37 | add_node("x") %>% 38 | add_node("y") %>% 39 | add_edge("x", "y", is_curved = TRUE) 40 | 41 | dagtex() %>% 42 | add_node("u1") %>% 43 | add_node("l") %>% 44 | add_node("a") %>% 45 | add_node("y") %>% 46 | add_node("u2", below = "u1") %>% 47 | add_node("u3", below = "l") %>% 48 | add_edge("u1", "l") %>% 49 | add_edge("l", "a") %>% 50 | add_edge("u1", "y", is_curved = TRUE, annotate = annotate_edge("wow")) %>% 51 | add_edge("l", "y", is_curved = TRUE) %>% 52 | add_edge("u2", "l", start_position = "north", end_position = "south") %>% 53 | add_edge("u2", "a", start_position = "north", end_position = "south") %>% 54 | add_edge("u3", "a", start_position = "north", end_position = "south") %>% 55 | add_edge("u3", "y", start_position = "north", end_position = "south") 56 | ``` 57 | 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # dagtex 5 | 6 | The goal of dagtex is to to create tikz DAGs from R. Under very early 7 | development and a bit of neglect. 8 | 9 | ## Installation 10 | 11 | You can install the development version of dagtex from GitHub with: 12 | 13 | ``` r 14 | # install.packages("remotes") 15 | remotes::install_github("malcolmbarrett/dagtex") 16 | ``` 17 | 18 | ## Example 19 | 20 | This is a basic example which shows you how to solve a common problem: 21 | 22 | ``` r 23 | library(dagtex) 24 | 25 | dagtex() %>% 26 | add_node("x") %>% 27 | add_node("y") %>% 28 | add_edge("x", "y", is_curved = TRUE) 29 | ``` 30 | 31 | 32 | 33 | ``` r 34 | 35 | dagtex() %>% 36 | add_node("u1") %>% 37 | add_node("l") %>% 38 | add_node("a") %>% 39 | add_node("y") %>% 40 | add_node("u2", below = "u1") %>% 41 | add_node("u3", below = "l") %>% 42 | add_edge("u1", "l") %>% 43 | add_edge("l", "a") %>% 44 | add_edge("u1", "y", is_curved = TRUE, annotate = annotate_edge("wow")) %>% 45 | add_edge("l", "y", is_curved = TRUE) %>% 46 | add_edge("u2", "l", start_position = "north", end_position = "south") %>% 47 | add_edge("u2", "a", start_position = "north", end_position = "south") %>% 48 | add_edge("u3", "a", start_position = "north", end_position = "south") %>% 49 | add_edge("u3", "y", start_position = "north", end_position = "south") 50 | ``` 51 | 52 | 53 | -------------------------------------------------------------------------------- /README_cache/latex/__packages: -------------------------------------------------------------------------------- 1 | base 2 | methods 3 | datasets 4 | utils 5 | grDevices 6 | graphics 7 | stats 8 | dagtex 9 | dplyr 10 | -------------------------------------------------------------------------------- /README_cache/latex/tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/README_cache/latex/tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.RData -------------------------------------------------------------------------------- /README_cache/latex/tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.rdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/README_cache/latex/tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.rdb -------------------------------------------------------------------------------- /README_cache/latex/tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.rdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/README_cache/latex/tikz-ex_005cb6b4f3b992b2c44dc8adf4a781de.rdx -------------------------------------------------------------------------------- /README_cache/tex_temp.tex: -------------------------------------------------------------------------------- 1 | \begin{tikzpicture} 2 | \tikzset{>=latex} 3 | \tikzstyle{Arrow} = [->, thick, preaction = {decorate}] 4 | \tikzstyle{DoubleArrow} = [<->, thick, preaction = {decorate}] 5 | \node(1) {x}; 6 | \node[right =of 1] (2) {y}; 7 | \draw[Arrow] (1) to [out=25, in=160] (2); 8 | \end{tikzpicture} 9 | -------------------------------------------------------------------------------- /README_cache/tex_tempDoc.tex: -------------------------------------------------------------------------------- 1 | \documentclass[varwidth, border={ 10 5 10 5 }]{standalone} 2 | \usepackage[usenames,dvispnames,svgnames,table]{xcolor} 3 | \usepackage{multirow} 4 | \usepackage{helvet} 5 | \usepackage{amsmath} 6 | \usepackage{rotating} 7 | \usepackage{listings} 8 | \usepackage{graphicx} 9 | \renewcommand{\familydefault}{\sfdefault} 10 | \usepackage{setspace} 11 | \usepackage{caption} 12 | \captionsetup{labelformat=empty} 13 | \usepackage{tikz} 14 | \usetikzlibrary{positioning, calc, shapes.geometric, 15 | shapes.multipart, shapes, arrows.meta, arrows, decorations.markings, 16 | external, trees} 17 | \begin{document} 18 | \input{ /Users/malcolmbarrett/Google Drive/Active/dagtex/README_cache/tex_temp.tex } 19 | \end{document} 20 | -------------------------------------------------------------------------------- /README_cache/texput.log: -------------------------------------------------------------------------------- 1 | This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.5.31) 21 FEB 2019 21:16 2 | entering extended mode 3 | restricted \write18 enabled. 4 | %&-line parsing enabled. 5 | **/Users/malcolmbarrett/Google Drive/Active/dagtex/README_cache/tex_tempDoc.tex 6 | 7 | ! Emergency stop. 8 | <*> /Users/malcolmbarrett/Google 9 | Drive/Active/dagtex/README_cache/tex_tempDo... 10 | 11 | Here is how much of TeX's memory you used: 12 | 4 strings out of 492647 13 | 123 string characters out of 6129578 14 | 56162 words of memory out of 5000000 15 | 3990 multiletter control sequences out of 15000+600000 16 | 3640 words of font info for 14 fonts, out of 8000000 for 9000 17 | 1141 hyphenation exceptions out of 8191 18 | 0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,80000s 19 | ! ==> Fatal error occurred, no output PDF file produced! 20 | -------------------------------------------------------------------------------- /dagtex.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: XeLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | PackageRoxygenize: rd,collate,namespace 22 | -------------------------------------------------------------------------------- /man/add_edges.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/edges.R 3 | \name{add_edge} 4 | \alias{add_edge} 5 | \title{Add edges} 6 | \usage{ 7 | add_edge(.dag, .from, .to, start_position = NULL, end_position = NULL, 8 | .options = NULL, is_curved = FALSE, curve = "up", 9 | is_double_arrow = FALSE, linetype = "solid", annotate = NULL, ...) 10 | } 11 | \arguments{ 12 | \item{...}{} 13 | } 14 | \description{ 15 | Add edges 16 | } 17 | \examples{ 18 | 19 | } 20 | -------------------------------------------------------------------------------- /man/add_nodes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/edges.R, R/nodes.R 3 | \name{add_curved_edge} 4 | \alias{add_curved_edge} 5 | \alias{annotate_edge} 6 | \alias{add_node} 7 | \alias{add_swig_node} 8 | \title{Add nodes} 9 | \usage{ 10 | add_curved_edge(.dag, .from, .to, start_position = NULL, 11 | end_position = NULL, .options = NULL, curve = "up", 12 | is_double_arrow = FALSE, linetype = "solid", annotate = NULL, ...) 13 | 14 | annotate_edge(text, placement = "midway", position = "above") 15 | 16 | add_node(.dag, .name, .options = NULL, x = NULL, y = NULL, 17 | right_of = NULL, left_of = NULL, above = NULL, below = NULL, 18 | shape = NULL, is_swig = FALSE, ...) 19 | 20 | add_swig_node(.dag, .left, .right, .options = NULL, x = NULL, 21 | y = NULL, right_of = NULL, left_of = NULL, above = NULL, 22 | below = NULL, shape = NULL, ...) 23 | } 24 | \arguments{ 25 | \item{...}{} 26 | } 27 | \description{ 28 | Add nodes 29 | } 30 | \examples{ 31 | 32 | } 33 | -------------------------------------------------------------------------------- /man/dagtex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/dagtex.R 3 | \name{dagtex} 4 | \alias{dagtex} 5 | \title{Create a new DAG} 6 | \usage{ 7 | dagtex(...) 8 | } 9 | \description{ 10 | Create a new DAG 11 | } 12 | -------------------------------------------------------------------------------- /man/figures/README-example-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/man/figures/README-example-1.png -------------------------------------------------------------------------------- /man/figures/README-example-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/man/figures/README-example-2.png -------------------------------------------------------------------------------- /man/figures/README-tikz-ex-1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/man/figures/README-tikz-ex-1.pdf -------------------------------------------------------------------------------- /man/figures/README-tikz-ex-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malcolmbarrett/dagtex/2937788637be2957c3c0fd4e0b103cbb046703d7/man/figures/README-tikz-ex-1.png -------------------------------------------------------------------------------- /man/get_latex_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw_dag.R 3 | \name{get_latex_code} 4 | \alias{get_latex_code} 5 | \title{Get LaTeX code} 6 | \usage{ 7 | get_latex_code(.dag, add_header = TRUE) 8 | } 9 | \arguments{ 10 | \item{add_header}{} 11 | } 12 | \description{ 13 | Get LaTeX code 14 | } 15 | -------------------------------------------------------------------------------- /man/hello.Rd: -------------------------------------------------------------------------------- 1 | \name{hello} 2 | \alias{hello} 3 | \title{Hello, World!} 4 | \usage{ 5 | hello() 6 | } 7 | \description{ 8 | Prints 'Hello, world!'. 9 | } 10 | \examples{ 11 | hello() 12 | } 13 | -------------------------------------------------------------------------------- /man/insert_latex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw_dag.R 3 | \name{insert_latex} 4 | \alias{insert_latex} 5 | \title{Insert LaTeX} 6 | \usage{ 7 | insert_latex(.dag, ...) 8 | } 9 | \arguments{ 10 | \item{...}{} 11 | } 12 | \description{ 13 | Insert LaTeX 14 | } 15 | -------------------------------------------------------------------------------- /man/pipe.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/utils-pipe.R 3 | \name{\%>\%} 4 | \alias{\%>\%} 5 | \title{Pipe operator} 6 | \usage{ 7 | lhs \%>\% rhs 8 | } 9 | \description{ 10 | See \code{magrittr::\link[magrittr]{\%>\%}} for details. 11 | } 12 | \keyword{internal} 13 | -------------------------------------------------------------------------------- /man/plot_dagtex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw_dag.R 3 | \name{plot_dagtex} 4 | \alias{plot_dagtex} 5 | \title{Plot DAGs} 6 | \usage{ 7 | plot_dagtex(.dag, density = 320, ...) 8 | } 9 | \arguments{ 10 | \item{...}{} 11 | } 12 | \description{ 13 | Plot DAGs 14 | } 15 | -------------------------------------------------------------------------------- /man/print.dagtex.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw_dag.R 3 | \name{print.dagtex} 4 | \alias{print.dagtex} 5 | \title{Explicitly draw DAG} 6 | \usage{ 7 | \method{print}{dagtex}(x, ...) 8 | } 9 | \arguments{ 10 | \item{x}{} 11 | 12 | \item{...}{} 13 | } 14 | \description{ 15 | Explicitly draw DAG 16 | } 17 | -------------------------------------------------------------------------------- /man/tikz_picture.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/draw_dag.R 3 | \name{tikz_picture} 4 | \alias{tikz_picture} 5 | \title{Create tikz picture} 6 | \usage{ 7 | tikz_picture(..., scale = NULL, scale_x = NULL, scale_y = NULL) 8 | } 9 | \arguments{ 10 | \item{scale_y}{} 11 | } 12 | \description{ 13 | Create tikz picture 14 | } 15 | --------------------------------------------------------------------------------