diff --git a/docs/LICENSE.html b/docs/LICENSE.html index b460a7b..50fbac6 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -52,6 +52,12 @@
-

Site built with pkgdown.

+

Site built with pkgdown.

diff --git a/docs/authors.html b/docs/authors.html index 69c6de3..9a8e648 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -52,6 +52,12 @@
-

Site built with pkgdown.

+

Site built with pkgdown.

diff --git a/docs/index.html b/docs/index.html index aadd16b..e0c86ac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -28,6 +28,12 @@
-

Site built with pkgdown.

+

Site built with pkgdown.

diff --git a/docs/news/index.html b/docs/news/index.html index d1c7670..dc112d7 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -52,6 +52,12 @@
+
+

+sunbust 1.0.3

+ +
+
+

+sunburst 1.0.2

+ +
+
+

+sunburst 1.0.1

+ +

sunburstR 1.0.0

@@ -188,6 +215,9 @@

Contents

-

Site built with pkgdown.

+

Site built with pkgdown.

diff --git a/docs/pkgdown.css b/docs/pkgdown.css index bcc0bd7..209ce57 100644 --- a/docs/pkgdown.css +++ b/docs/pkgdown.css @@ -137,9 +137,14 @@ pre, code { color: #333; } -pre img { +pre .img { + margin: 5px 0; +} + +pre .img img { background-color: #fff; display: block; + height: auto; } code a, pre a { diff --git a/docs/pkgdown.js b/docs/pkgdown.js index c8b38c4..4b81713 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -5,4 +5,41 @@ $(function() { offset: 60 }); + var cur_path = paths(location.pathname); + $("#navbar ul li a").each(function(index, value) { + if (value.text == "Home") + return; + if (value.getAttribute("href") === "#") + return; + + var path = paths(value.pathname); + if (is_prefix(cur_path, path)) { + // Add class to parent
  • , and enclosing
  • if in dropdown + var menu_anchor = $(value); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); }); + +function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); +} + +function is_prefix(needle, haystack) { + if (needle.length > haystack.lengh) + return(false); + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(false); + } + + return(true); +} diff --git a/docs/reference/add_shiny.html b/docs/reference/add_shiny.html index ff8cde4..dd90074 100644 --- a/docs/reference/add_shiny.html +++ b/docs/reference/add_shiny.html @@ -52,6 +52,12 @@
    -

    Site built with pkgdown.

    +

    Site built with pkgdown.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 5cad4f0..32a234a 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -52,6 +52,12 @@
    -

    Site built with pkgdown.

    +

    Site built with pkgdown.

    diff --git a/docs/reference/sunburst-shiny.html b/docs/reference/sunburst-shiny.html index a66c13a..a65f053 100644 --- a/docs/reference/sunburst-shiny.html +++ b/docs/reference/sunburst-shiny.html @@ -52,6 +52,12 @@
    -

    Site built with pkgdown.

    +

    Site built with pkgdown.

    diff --git a/docs/reference/sunburst.html b/docs/reference/sunburst.html index 2d17440..43cac71 100644 --- a/docs/reference/sunburst.html +++ b/docs/reference/sunburst.html @@ -52,6 +52,12 @@ -

    Sequences sunburst diagrams provide +

    Sequences sunburst diagrams provide an interactive method of exploring sequence data, such as website navigation paths.

    @@ -181,12 +187,10 @@

    Ar

    Examples

    -
    # devtools::install_github("timelyportfolio/sunburstR") - -library(sunburstR) +
    library(sunburstR) # read in sample visit-sequences.csv data provided in source -# only use first 200 rows to speed package build and check +# only use first 100 rows to speed package build and check # https://gist.github.com/kerryrodden/7090426#file-visit-sequences-csv sequences <- read.csv( system.file("examples/visit-sequences.csv",package="sunburstR") @@ -194,145 +198,141 @@

    Examp ,stringsAsFactors = FALSE )[1:100,] -sunburst(sequences)

    #> Warning: file("") only supports open = "w+" and open = "w+b": using the former
    #> Error in dirname(to): a character vector argument expected
    -not_run({ - - # explore some of the arguments - sunburst( - sequences - ,count = TRUE - ) +sunburst(sequences)
    #> Error in yaml.load(readLines(con), error.label = error.label, ...): argument "error.label" is missing, with no default
    +
    # NOT RUN { +# explore some of the arguments +sunburst( + sequences + ,count = TRUE +) - sunburst( - sequences - # apply sort order to the legends - ,legendOrder = unique(unlist(strsplit(sequences[,1],"-"))) - # just provide the name in the explanation in the center - ,explanation = "function(d){return d.data.name}" - ) +sunburst( + sequences + # apply sort order to the legends + ,legendOrder = unique(unlist(strsplit(sequences[,1],"-"))) + # just provide the name in the explanation in the center + ,explanation = "function(d){return d.data.name}" +) - # try with json data - sequence_json <- jsonlite::fromJSON( - system.file("examples/visit-sequences.json",package="sunburstR"), - simplifyDataFrame = FALSE - ) - sunburst(sequence_json) +# try with json data +sequence_json <- jsonlite::fromJSON( + system.file("examples/visit-sequences.json",package="sunburstR"), + simplifyDataFrame = FALSE +) +sunburst(sequence_json) - # try with csv data from this fork - # https://gist.github.com/mkajava/7515402 - # great use for new breadbrumb wrapping - sunburst( - csvdata = read.csv( - file = paste0( - "https://gist.githubusercontent.com/mkajava/", - "7515402/raw/9f80d28094dc9dfed7090f8fb3376ef1539f4fd2/", - "comment-sequences.csv" - ) - ,header = TRUE - ,stringsAsFactors = FALSE +# try with csv data from this fork +# https://gist.github.com/mkajava/7515402 +# great use for new breadbrumb wrapping +sunburst( + csvdata = read.csv( + file = paste0( + "https://gist.githubusercontent.com/mkajava/", + "7515402/raw/9f80d28094dc9dfed7090f8fb3376ef1539f4fd2/", + "comment-sequences.csv" ) + ,header = TRUE + ,stringsAsFactors = FALSE ) +) - # try with csv data from this fork - # https://gist.github.com/rileycrane/92a2c36eb932b4f99e51/ - sunburst( csvdata = read.csv( - file = paste0( - "https://gist.githubusercontent.com/rileycrane/", - "92a2c36eb932b4f99e51/raw/", - "a0212b4ca8043af47ec82369aa5f023530279aa3/visit-sequences.csv" - ) - ,header=FALSE - ,stringsAsFactors = FALSE - )) -}) -not_run({ - # use sunburst to analyze ngram data from Peter Norvig - # http://norvig.com/mayzner.html +# try with csv data from this fork +# https://gist.github.com/rileycrane/92a2c36eb932b4f99e51/ +sunburst( csvdata = read.csv( + file = paste0( + "https://gist.githubusercontent.com/rileycrane/", + "92a2c36eb932b4f99e51/raw/", + "a0212b4ca8043af47ec82369aa5f023530279aa3/visit-sequences.csv" + ) + ,header=FALSE + ,stringsAsFactors = FALSE +)) +# }# NOT RUN { +# use sunburst to analyze ngram data from Peter Norvig +# http://norvig.com/mayzner.html - library(sunburstR) - library(pipeR) +library(sunburstR) +library(pipeR) - # read the csv data downloaded from the Google Fusion Table linked in the article - ngrams2 <- read.csv( - system.file( - "examples/ngrams2.csv" - ,package="sunburstR" - ) - , stringsAsFactors = FALSE +# read the csv data downloaded from the Google Fusion Table linked in the article +ngrams2 <- read.csv( + system.file( + "examples/ngrams2.csv" + ,package="sunburstR" ) + , stringsAsFactors = FALSE +) - ngrams2 %>>% - # let's look at ngrams at the start of a word, so columns 1 and 3 - (.[,c(1,3)]) %>>% - # split the ngrams into a sequence by splitting each letter and adding - - ( - data.frame( - sequence = strsplit(.[,1],"") %>>% - lapply( function(ng){ paste0(ng,collapse = "-") } ) %>>% - unlist - ,freq = .[,2] - ,stringsAsFactors = FALSE - ) - ) %>>% - sunburst - - - library(htmltools) - - ngrams2 %>>% - ( - lapply( - seq.int(3,ncol(.)) - ,function(letpos){ - (.[,c(1,letpos)]) %>>% - # split the ngrams into a sequence by splitting each letter and adding - - ( - data.frame( - sequence = strsplit(.[,1],"") %>>% - lapply( function(ng){ paste0(ng,collapse = "-") } ) %>>% - unlist - ,freq = .[,2] - ,stringsAsFactors = FALSE - ) - ) %>>% - ( tags$div(style="float:left;",sunburst( ., height = 300, width = 300 )) ) - } - ) - ) %>>% - tagList %>>% - browsable -}) -not_run({ - library(treemap) - library(sunburstR) - library(d3r) - - # use example from ?treemap::treemap - data(GNI2014) - tm <- treemap(GNI2014, - index=c("continent", "iso3"), - vSize="population", - vColor="continent", - type="index") - - tm_nest <- d3_nest( - tm$tm[,c("continent", "iso3", "vSize", "color")], - value_cols = c("vSize", "color") +ngrams2 %>>% + # let's look at ngrams at the start of a word, so columns 1 and 3 + (.[,c(1,3)]) %>>% + # split the ngrams into a sequence by splitting each letter and adding - + ( + data.frame( + sequence = strsplit(.[,1],"") %>>% + lapply( function(ng){ paste0(ng,collapse = "-") } ) %>>% + unlist + ,freq = .[,2] + ,stringsAsFactors = FALSE ) - - sunburst( - data = tm_nest, - valueField = "vSize", - count = TRUE, - colors = htmlwidgets::JS("function(d){return d3.select(this).datum().data.color;}"), - withD3 = TRUE + ) %>>% + sunburst + + +library(htmltools) + +ngrams2 %>>% + ( + lapply( + seq.int(3,ncol(.)) + ,function(letpos){ + (.[,c(1,letpos)]) %>>% + # split the ngrams into a sequence by splitting each letter and adding - + ( + data.frame( + sequence = strsplit(.[,1],"") %>>% + lapply( function(ng){ paste0(ng,collapse = "-") } ) %>>% + unlist + ,freq = .[,2] + ,stringsAsFactors = FALSE + ) + ) %>>% + ( tags$div(style="float:left;",sunburst( ., height = 300, width = 300 )) ) + } ) -}) -# calendar sunburst example + ) %>>% + tagList %>>% + browsable +# }# NOT RUN { + library(treemap) + library(sunburstR) + library(d3r) + + # use example from ?treemap::treemap + data(GNI2014) + tm <- treemap(GNI2014, + index=c("continent", "iso3"), + vSize="population", + vColor="continent", + type="index") + + tm_nest <- d3_nest( + tm$tm[,c("continent", "iso3", "vSize", "color")], + value_cols = c("vSize", "color") + ) + + sunburst( + data = tm_nest, + valueField = "vSize", + count = TRUE, + colors = htmlwidgets::JS("function(d){return d3.select(this).datum().data.color;}"), + withD3 = TRUE + ) +# }
    # calendar sunburst example library(sunburstR) @@ -355,7 +355,7 @@

    Examp data.frame(xtabs(count~path,df)), # added a degree of difficulty by providing # not easily sortable names - sortFunction = htmlwidgets::JS( + sortFunction = htmlwidgets::JS( " function(a,b){ abb = { @@ -383,7 +383,22 @@

    Examp } " ) -)

    #> Warning: file("") only supports open = "w+" and open = "w+b": using the former
    #> Error in dirname(to): a character vector argument expected
    +)
    #> Error in yaml.load(readLines(con), error.label = error.label, ...): argument "error.label" is missing, with no default
    # sorting example: place data in order of occurence + +library(sunburstR) + +df <- data.frame( + group = c("foo", "bar", "xyz"), + value = c(1, 3, 2) +) + +sunburst(df, + # create a trivial sort function + sortFunction = htmlwidgets::JS('function(x) {return x;}'))
    #> Error in yaml.load(readLines(con), error.label = error.label, ...): argument "error.label" is missing, with no default
    +new_order <- c(3,2,1) +sunburst(df[new_order,], + sortFunction = htmlwidgets::JS('function(x) {return x;}'))
    #> Error in yaml.load(readLines(con), error.label = error.label, ...): argument "error.label" is missing, with no default
    +
  • -

    Site built with pkgdown.

    +

    Site built with pkgdown.