Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed the selected parameter in favor of get_selected.
- Loading branch information
1 parent
9930b98
commit 8befa75
Showing
9 changed files
with
78 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Generated by roxygen2 (4.0.2): do not edit by hand | ||
|
||
export(get_selected) | ||
export(renderTree) | ||
export(shinyTree) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' Get the selected nodes from a tree | ||
#' | ||
#' Extract the nodes from the tree that are selected in a more | ||
#' convenient format. You can choose which format you prefer. | ||
#' | ||
#' @param tree The \code{input$tree} shinyTree you want to | ||
#' inspect. | ||
#' @param format In which format you want the output. Use | ||
#' \code{names} to get a simple list of the names (with attributes | ||
#' describing the node's ancestry), or \code{slices} to get a list | ||
#' of lists, each of which is a slice of the list used to get down | ||
#' to the selected node. | ||
#' @export | ||
get_selected <- function(tree, format=c("names", "slices")){ | ||
format <- match.arg(format, c("names", "slices"), FALSE) | ||
switch(format, | ||
"names"=get_selected_names(tree), | ||
"slices"=get_selected_slices(tree)) | ||
} | ||
|
||
get_selected_names <- function(tree, ancestry=NULL, vec=list()){ | ||
if (is.list(tree)){ | ||
for (i in 1:length(tree)){ | ||
anc <- c(ancestry, names(tree)[i]) | ||
vec <- get_selected_names(tree[[i]], anc, vec) | ||
} | ||
} | ||
|
||
a <- attr(tree, "stselected", TRUE) | ||
if (!is.null(a) && a == TRUE){ | ||
# Get the element name | ||
el <- tail(ancestry,n=1) | ||
vec[length(vec)+1] <- el | ||
attr(vec[[length(vec)]], "ancestry") <- head(ancestry, n=length(ancestry)-1) | ||
} | ||
return(vec) | ||
} | ||
|
||
get_selected_slices <- function(tree){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
% Generated by roxygen2 (4.0.2): do not edit by hand | ||
\name{get_selected} | ||
\alias{get_selected} | ||
\title{Get the selected nodes from a tree} | ||
\usage{ | ||
get_selected(tree, format = c("names", "slices")) | ||
} | ||
\arguments{ | ||
\item{tree}{The \code{input$tree} shinyTree you want to | ||
inspect.} | ||
|
||
\item{format}{In which format you want the output. Use | ||
\code{names} to get a simple list of the names (with | ||
attributes describing the node's ancestry), or | ||
\code{slices} to get a list of lists, each of which is a | ||
slice of the list used to get down to the selected node.} | ||
} | ||
\description{ | ||
Extract the nodes from the tree that are selected in a more | ||
convenient format. You can choose which format you prefer. | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters