diff --git a/DESCRIPTION b/DESCRIPTION index 9ebda70..215b18c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: dotViewer Title: View R Object in Shiny -Version: 0.1.0 +Version: 0.1.2 Author: Zhiming Ye Maintainer: Zhiming Ye Description: In RStudio, the Environment pane provides a good overview of diff --git a/NAMESPACE b/NAMESPACE index 8697a10..a15c5e7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,5 @@ # Generated by roxygen2: do not edit by hand export(ViewDF) +export(ViewList) export(ViewObj) diff --git a/R/Viewer.R b/R/Viewer.R index f9a8fe0..4797216 100644 --- a/R/Viewer.R +++ b/R/Viewer.R @@ -51,12 +51,56 @@ ViewObj<-function(x,selfExpr=F,pattern1=NULL,pattern2=NULL,pattern3=NULL,move=0, pattern3<-".*?:" } if(!selfExpr){ - .ViewInternal(capture.output(str(x,strict.width="cut")),pattern1 = pattern1,pattern2=pattern2,pattern3=pattern3,move=move,removeBlank=removeBlank) + .ViewInternal(capture.output(str(x,max.level = NA,list.len=100L,strict.width="cut")),pattern1 = pattern1,pattern2=pattern2,pattern3=pattern3,move=move,removeBlank=removeBlank) } else{ .ViewInternal(x,pattern1 = pattern1,pattern2=pattern2,pattern3=pattern3,move=move,removeBlank=removeBlank) } } +#' Viewing list in browser +#' +#' @param x A List +#' +#' @author Zhiming Ye +#' @return A shiny website +#' @export +#' +ViewList <- function(x){ + if(!is.list(x)){ + stop("Not A list!") + } + .ViewListInternal(x) +} + +.ViewListInternal <- function(x){ + require(shiny) + require(shinyTree) + require(shinyAce) + + ui <- shinyUI( + pageWithSidebar( + titlePanel("dotViewer 0.1.0"), + + sidebarPanel( + shinyTree("tree"),width = 10 + ), + mainPanel( + aceEditor("r_code", + mode = "r", # Set editor mode to R + theme = "textmate", # Set editor theme + value = capture.output(str(x,max.level = NA,list.len=100L,strict.width="cut")), + readOnly=T, + wordWrap=T,height="800px"),width = 10 + ) + )) + server <- shinyServer(function(input, output, session) { + output$tree <- renderTree({ + x + }) + + }) + shinyApp(ui=ui,server = server) +} .ViewInternal<-function(x,pattern1,pattern2,pattern3,move=0,removeBlank=T){ dt<-x @@ -152,7 +196,7 @@ ViewObj<-function(x,selfExpr=F,pattern1=NULL,pattern2=NULL,pattern3=NULL,move=0, ui <- shinyUI( pageWithSidebar( - headerPanel("dotViewer 0.1.0"), + titlePanel("dotViewer 0.1.0"), sidebarPanel( shinyTree("tree"),width = 10 @@ -192,3 +236,7 @@ ViewObj<-function(x,selfExpr=F,pattern1=NULL,pattern2=NULL,pattern3=NULL,move=0, shinyApp(ui = ui, server = server) } +.onAttach<-function(libname,pkgname){ + packageStartupMessage("\n***dotViewer***\nView DF using ViewDF, View Object using ViewObj, View List using ViewList\n=============\nAuthor:Zhiming Ye\n") +} +# attachment::att_amend_desc() diff --git a/man/ViewDF.Rd b/man/ViewDF.Rd index ab003b5..de85310 100644 --- a/man/ViewDF.Rd +++ b/man/ViewDF.Rd @@ -12,7 +12,7 @@ ViewDF(x, n = 10000) \item{n}{Display n lines} } \value{ -A shiny website +A shiny website rendered by DT } \description{ Viewing tables in browser diff --git a/man/ViewList.Rd b/man/ViewList.Rd new file mode 100644 index 0000000..dd6931b --- /dev/null +++ b/man/ViewList.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Viewer.R +\name{ViewList} +\alias{ViewList} +\title{Viewing list in browser} +\usage{ +ViewList(x) +} +\arguments{ +\item{x}{A List} +} +\value{ +A shiny website +} +\description{ +Viewing list in browser +} +\author{ +Zhiming Ye +} diff --git a/readme.md b/readme.md index f3504d9..7a161b6 100644 --- a/readme.md +++ b/readme.md @@ -8,25 +8,31 @@ - **S4 Object Inspection**: -Easily inspect S4 objects' slots and structure, similar to the RStudio environment. ![](Figs/S4obj.jpg) +Easily inspect S4 objects' slots and structure, similar to the RStudio environment, by print `ViewObj(x)`. + +![](Figs/S4obj.jpg) - **Comprehensive Property Overview**: -dotViewer parses the output of the `str()` function to generate a detailed property map using `ShinyTree`, providing a clear and organized overview of an object’s structure. +dotViewer parses the output of the `str()` function to generate a detailed property map using `ShinyTree`, providing a clear and organized overview of an object’s structure. ![](Figs/s3obj.jpg) - **S3 and Untested Object Compatibility**: -For objects like S3 and others that may not have been extensively tested, dotViewer offers an `AceEditor`-based editor. This editor allows for the preview of `str()` output with advanced features like syntax highlighting and search, enhancing your understanding of object structures, which are not supported in the default VSCode R extension. +For objects like S3 and others that may not have been extensively tested, dotViewer offers an `AceEditor`-based editor. This editor allows for the preview of `str()` output with advanced features like syntax highlighting and search, enhancing your understanding of object structures, which are not supported in the default VSCode R extension. ![](Figs/S3Tibble.jpg) +- **List Viewing**: + +`ShinyTree` is based on list, you can use `ViewList` to view lists. + - **DT-Based Table Preview**: When working over SSH connections, loading large tables into the VSCode front-end can potentially cause instability. dotViewer addresses this by providing a preview pane based on DT for table objects, ensuring a more stable experience. -![](Figs/DTExample.jpg) +![](Figs/DTExample.jpg) - **Integrated with VSCode**: @@ -90,6 +96,12 @@ Enjoy the convenience of RStudio’s object inspection capabilities within the p ``` dotViewer::ViewDF(x,n = 10000) # You can determine how many rows is passed to DT ``` + +3. **Viewing lists:** + + ``` + dotViewer::ViewList(x) + ``` ## License