rCharts dTable Error - r

Hi I'm new to rCharts and could definitely use some help. I'm getting the error below when I try to run the following.
Code:
dTable(airquality, sPaginationType = "full_numbers")
Error:
Error in as.character(tools:::httpdPort) :
cannot coerce type 'closure' to vector of type 'character'
Also when I try ?dTable I get the message:
No documentation for ‘dTable’ in specified packages and libraries:
you could try ‘??dTable’
I installed rCharts and devtools using:
install.packages("devtools")
and
install.packages("base64enc")
devtools::install_github("ramnathv/rCharts")
then I called both libraries using library(devtools) and library(rCharts).
Any tips greatly appreciated.

I created a fig directory under my current working directory, ran the following code and it created an html file with the sortable table in the fig directory:
#install.packages("devtools")
install.packages("base64enc")
require(base64enc)
library(devtools)
require(rCharts)
data("airquality")
table1 <- dTable(airquality, sPaginationType = "full_numbers")
table1$save('./fig/table1.html', standalone=TRUE)

Related

'tk_chooseDirectory' is not an exported object from 'namespace:tcltk'

I am following code from this guidebook, https://www.adb.org/sites/default/files/publication/698091/guidebook-mapping-poverty-data-integration-ai.pdf
And inputted
wd <- tcltk::tk_choose.dir(caption ="Select Working Directory") into R
but received the error message Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") : [tcl] invalid command name "tk_chooseDirectory".
When I changed it to wd <- tcltk::tk_chooseDirectory(caption ="Select Working Directory")
I get the error
Error: 'tk_chooseDirectory' is not an exported object from 'namespace:tcltk'.
The only lines of code I have before these are installing packages, but since tcltk is a base package of R, it's unlikely that's the problem.
How do I solve this? Thank you! I've attached a photo of the example code.

Error: 'set_envvar' is not an exported object from 'namespace:xfun'

I'm trying to run Data Exploration in my R Studio, version 1.3.959 on my windows10.I wrote following test code
if (!require(devtools)) install.packages("devtools")
devtools::install_github("boxuancui/DataExplorer", ref = "develop")
library(DataExplorer)
diabetes_data <- read.csv("https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.csv", header = FALSE)
names(diabetes_data) <- c("number_of_times_pregnant", "plasma_glucose_conc", "diastolic_bp", "triceps_skinfold_thickness", "two_hr_serum_insulin", "bmi", "diabetes_pedigree_function", "age", "label")
# create report
create_report(diabetes_data)
But I'm getting error message
Error: 'set_envvar' is not an exported object from 'namespace:xfun'
Can you please help me to resolve the issue?
I just had this problem and updating my packages solved the issue, especially the package xfun from which set_envvar is originated.

load data error (Read10X, Seurat - Guided Clustering Tutorial)

I am trying to follow the tutorial from Seurat website.
https://satijalab.org/seurat/v3.1/pbmc3k_tutorial.html
I got an error when loading the data.
Load the PBMC dataset
pbmc.data <- Read10X("1_Guided_tutorial/pbmc3k_filtered_gene_bc_matrices.tar.gz")
Error in Read10X("1_Guided_tutorial/pbmc3k_filtered_gene_bc_matrices.tar.gz") :
Directory provided does not exist
I have set my working directory as the image showed. Can anyone let me know what is the problem? Thank you!
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("multtest")
library(dplyr)
library(Seurat)
library(patchwork)
# Load the PBMC dataset
pbmc.data <- Read10X(data.dir = "1_Guided_tutorial/pbmc3k_filtered_gene_bc_matrices.tar.gz")
I was trapped with this problem few minutes before, and I find the solution now.
Try to use these codes:
install.packages("Seurat")
library(Seurat)
install.packages(c('dplyr','patchwork'))
library(dplyr)
library(Seurat)
library(patchwork)
in order to install the environment for scRNA analysis

Error in seas(AirPassengers) : no output has been generated

I am getting this error when I run:
library(seasonal)
m <- seas(AirPassengers)
I have installed the package.
I have uninstalled R, Rstudio, reinstalled and tried again, same error.
Could someone help?
Thanks
I can't reproduce exactly the same error now but I remember following error after I installed the seasonal package:
Error in seas(AirPassengers) : could not find function "seas"
After cleaning up my workspace the error was gone.
Following code is working for me and resulting in the plot below:
library(seasonal)
head(AirPassengers)
m <- seas(AirPassengers, regression.aictest = c("td", "easter"))
plot(m)

Installing required packages in Shiny app

I have a shiny app that I want everybody to be able to run using runGitHub with the only pre requisite of having the shiny packaged installed.
In order for all the needed packages to be installed and loaded in the person´s computer the first time he runs the program, my code in server.R starts with:
if (!require("pacman")) install.packages("pacman")
pacman::p_load("maptools","dplyr","data.table","reshape2","ggplot2","plyr","rgdal","rgeos","shinyjs","scales","DT","readxl")
library(maptools)
library(dplyr)
library(data.table)
library(reshape2)
library(ggplot2)
library(plyr)
library(rgdal)
library(rgeos)
library(shinyjs)
library(scales)
library(DT)
library(readxl)
Nevertheless, I just tested it in someone elses pc and the following error shows up:
Error in library(shinyjs) : there is no package called ‘shinyjs’
After I installed shinyjs manually, the following showed up:
Warning: Error in library: there is no package called ‘maptools’
Stack trace (innermost first):
46: library
45: eval [helper.R#1]
44: eval
43: withVisible
42: source
3: runApp
2: runUrl
1: runGitHub
Error in library(maptools) : there is no package called ‘maptools’
And so on. This is my first shiny app, so I don't know how am I supposed to achieve this. My complete code can be accessed by running:
runGitHub("Mapas_BBVA_municipios","IArchondo",display.mode="showcase")
There are chances that the packages might have some dependencies along with it, so all packages with dependencies need to be installed. To resolve this for every new user, you can perform check and install(if necessary) like this.
#list of packages required
list.of.packages <- c("pacman","maptools","dplyr","data.table","reshape2","ggplot2","plyr","rgdal","rgeos","shinyjs","scales","DT","readxl")
#checking missing packages from list
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
#install missing ones
if(length(new.packages)) install.packages(new.packages, dependencies = TRUE)
Hope this helps.
This works for me:
list_of_packages = c("ggplot2","pacman")
lapply(list_of_packages,
function(x) if(!require(x,character.only = TRUE)) install.packages(x))

Resources