Error Msgs After Package Updates for My Dashboard Outputs - r

I just installed a bunch of new package updates this morning (including plotly, dygraphs, rCharts, shiny and shinydashboard), and suddenly almost all outputs on my dashboard that I worked months on are broken, while they worked yesterday without a problem! For most charts I get the following error:
ERROR: object of type 'closure' is not subsettable
This is for plotly graphs like this one:
ui:
plotlyOutput("Top10Events")
server:
output$Top10Events <- renderPlotly({
x <- list(
title = " "
)
y <- list(
title = "Total Events"
)
plot_ly(x = Top10$event,
y = Top10$totalEvents.x,
type = "bar",
color = Top10$totalEvents.x,
name = "This Month",
marker = list(color = brewer.pal(10, "Paired"))) %>%
layout(xaxis = x, yaxis = y, autosize = F, width = 700, height = 350, margin = m)
p2 <- add_trace(
p,
x = Top10$event,
y = Top10$totalEvents.y,
name = "Last Month",
type = "bar",
color = Top10$totalEvents.y,
marker = list(color = brewer.pal(10, "Paired")))
})
I read that this error occurs mostly when {} are missing for reactive values, but as everything just worked fine yesterday I don't think this is the issue.
I figured it is likely a shiny issue? So I installed the old version of Shiny (0.13.2) successfully, but get a new error:
Error in get(Info[i, 1], envir = env) :
lazy-load database 'C:/Users/user/Documents/R/R-
3.3.1/library/shiny/R/shiny.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
Tried it with an older shinydashbaord version as well (0.5.2), but I get the following error when installing:
The following object is masked from ‘package:graphics’:
box
My version of R & RStudio is also the newest apparently.
Any suggestions on how to approach the debugging process further and save my dashboard?
Many thanks, any help is appreciated!
EDIT:
The latest oldest plotly version I can find on https://cran.r-project.org/src/contrib/Archive/plotly/ is only plotly_3.6.0, while I am currently running 4.5.2 (as I figured it might be a plotly issue).
Trying to install the 3.6.0 version, I get again the following error:
The following object is masked from ‘package:igraph’:
%>%
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:graphics’:
layout
EDIT 2: Sorry for all the edits - so now I managed to upload the old plotly package, 3.6.0, and everything works again. Seems like the new package is either full of bugs, or I need to code my graphs differently? I could not find any helpful resource on that. Could anyone help?

I think that the new packages you install have objects of the same name of your old packages, thereby "overwriting" your old objects. You could try accessing your masked objects by using graphics::layout() instead of layout().
Edit: Look here for more information.

Related

Error with R tibble: Error in vectbl_restore(xo, x) : object 'tibble_restore_impl' not found

I've had this error pop up out of nowhere and I have no idea what to do to fix it. Running the code below,
library(ggplot2)
library(tibble)
del <- tibble(x = c(1,2), y = c(2, 4))
ggplot(data = del) + geom_point(aes(x = x, y = y))
results in the following error:
Error in vectbl_restore(xo, x) : object 'tibble_restore_impl' not found
However, if I instead do the following, it works fine:
del <- tibble(x = c(1,2), y = c(2, 4))
ggplot(data = as.data.frame(del)) + geom_point(aes(x = x, y = y))
And it is not specific to ggplot or tibble creation. If for example I import a .csv file (using read.csv), and the select/filter a subset using dplyr, I then get the same error if I try to plot it using ggplot2, or if I try to save it using write.table(). I had none of these issues until last Monday and I'm not sure what caused it. I haven't updated any of the aforementioned packages. The only thing I've tried to do is install cmdstanr, which I didn't manage to do since I was getting the following error:
> library(cmdstanr)
> check_cmdstan_toolchain()
Error:
A toolchain was not found. Please install RTools 3.5 and run
write('RTOOLS35_HOME=rtools35/install/path/', file = "~/.Renviron", append = TRUE)
replacing 'rtools35/install/path/' with the actual install path of RTools 3.5.
Then restart R and run 'cmdstanr::check_cmdstan_toolchain(fix = TRUE)'.
I stopped trying to install it because I thought it wasn't worth my time since I already have a functioning version of rstan.

I keep getting the same error no matter what from R library rWBclimate

I am trying to use the package "rWBclimate", but nothing works and I keep getting the same error message.
Even when I try running code from the vignette (see code below) I get the same error
(https://cran.r-project.org/web/packages/rWBclimate/vignettes/rWBclimate.pdf).
I have tried several functions and I have fiddled around with the UTF-settings, I have also updated R and all packages to the latest versions...
library(rWBclimate)
usa.dat <- get_model_temp("USA", "mavg", 2080, 2100)
usa.dat.bcc <- usa.dat[usa.dat$gcm == "bccr_bcm2_0", ]
usa.dat.had <- usa.dat[usa.dat$gcm == "ukmo_hadcm3", ]
usa.dat.bcc$ID <- paste(usa.dat.bcc$scenario, usa.dat.bcc$gcm, sep = "-")
usa.dat.had$ID <- paste(usa.dat.had$scenario, usa.dat.had$gcm, sep = "-")
plot.df <- rbind(usa.dat.bcc, usa.dat.had)
ggplot(plot.df, aes(x = as.factor(month), y = data, group = ID, colour =
gcm, linetype = scenario)) + geom_point() + geom_path() + ylab("Average
temperature in degrees C \n between
xlab("Month") + theme_bw()
Error = "No encoding supplied: defaulting to UTF-8.
Error in rep(locator, dim(data_out)[1]) : invalid 'times' argument"
Any suggestions?
Thank you
The encoding is not the problem here, that is not an error message.
When running vignette this is what pops up for me:
No encoding supplied: defaulting to UTF-8.
Error in rep(locator, dim(data_out)[1]) : invalid 'times' argument
The first bit is FYI - R is telling you it defaults to UTF-8.
Check the description file in the package of for example tidyverse, ggplot, caret. You will observe that there is a line reading:
Encoding: UTF-8.
In the description file of the package rWBclimate the encoding is missing which I reckon is prompting R's message.
The second bit is the error and I suspect the issue is with the package itself as a quick glance shows some of the functions are not visible to R, ie. check_ISO_codes() returns an error: could not find function "check_ISO_code". I am not entirely sure if the code is even maintained anymore, there were some questions about its status:
https://github.com/ropensci/rWBclimate/issues/35
If I understand correctly the maintenance was shifted but I am not sure if the package has since been updated in any way.
In any case, hope you get to the bottom of this!

Plotly code - viewer graph doesn't showup

I am running the example code for the Slider function (example 2) in R:https://plot.ly/r/animations/
I want to simply reproduce the given example.
However, the graph doesn't show up in my viewer.
This is the codeI run in R:
library(plotly)
library(gapminder)
p <- gapminder %>%
plot_ly(
x = ~gdpPercap,
y = ~lifeExp,
size = ~pop,
color = ~continent,
frame = ~year,
text = ~country,
hoverinfo = "text",
type = 'scatter',
mode = 'markers'
) %>%
layout(
xaxis = list(
type = "log"
)
)
I didn't change it from the way it is described here.
Can one help me and tell me why the graph doesn't show up?
I tried to run the code at start without success as well.
Basically the issue was :
Evaluation error: `as_dictionary()` is defunct as of rlang 0.3.0 Please use `as_data_pronoun()` instead.
I think you just need to update your dplyr to the latest version 0.7.7.
install.packages("dplyr") #or update current version
Also check that :
Any package larger than a few Kb gives the message:
Warning in install.packages :
unable to move temporary installation ‘C:\Users[myname]\R\win-library\3.4\file2b884fc37c13\packagename’ to ‘C:\Users[myname]\R\win-library\3.4\packagename’
If so,Type in : trace(utils:::unpackPkgZip,edit = T)
and edited Line 140 Sys.sleep(0.5) to Sys.sleep(2).
Then you can Run your code and print p
Check out the plot
btw a real cool one !

Plotly - unused arguments error - appears inconsistent

I am creating a Rmarkdown document that contains a number of plots created with plotly.
I cannot figure out why one of my plots is throwing an 'unused arguments' error, as the plot I create before it, which using the same arguments but a different subset of data, works fine. I want to use these 2 plots in a subplot.
Here's what I've got:
df_subset1_p <-
plot_ly(df_subset1, x = ~Month, y = ~data.percent, width = 800, height = 500) %>%
add_lines(color = ~cat) %>%
layout(xaxis = x, yaxis = y, margin = m)
df_subset2_p <-
plotly(df_subset2, x = ~Month, y = ~data.percent, width = 800, height = 500) %>%
add_lines(color = ~cat) %>%
layout(xaxis = x, yaxis = y, margin = m)
Before I can even call the subplot, df_subset2_p throws the error:
Error in plotly(df_subset2, x = ~Month, y = ~data.percent, : unused arguments (x = ~Month, y = ~data.percent, width = 800, height = 500)
I get the error on the 2nd plot, even if I try to run it first. The error reproduces if I just run the script and not the RMarkdown.
The structure of the dataframes looks fine to me. Month is a factor and data.percent is numeric for both.
I tried removing width, height and layout options, same error.
The error reproduces if I run the script without Rmarkdown.
I haven't found this exact problem reported by others on SO, though there are some similar complaints suggesting a compatibility issue between plotly and ggplot (older versions) or that another loaded package is using the same function name. But I don't see how this can be the case here, since I have many previous plots in the notebook that work fine.
df_subset2_p <-
plotly([...])
should be:
df_subset2_p <-
plot_ly([...])
Edit:
See ?plotly and ?plot_ly
The error was all in the typo. (Sighs.)
plot_ly initiates a plotly visualization, whereas plotly is a deprecated function previously used to store plotly account credentials.
Always use plot_ly.

ggnet2 : Error: Each variable must be a 1d atomic vector or list

I am trying to use ggnet2 for visualizing a network analysis, but have run into an error with the vignette.
I can generate a random network,
library(ggnet2)
library(network)
library(sna)
library(ggplot2)
net = rgraph(10, mode = "graph", tprob = 0.5)
net = network(net, directed = FALSE)
# vertex names
network.vertex.names(net) = letters[1:10]
With an output that looks reasonable
>net
Network attributes:
vertices = 10
directed = FALSE
hyper = FALSE
loops = FALSE
multiple = FALSE
bipartite = FALSE
total edges= 28
missing edges= 0
non-missing edges= 28
Vertex attribute names:
vertex.names
No edge attributes
However, when I try to run..
ggnet2(net)
I get an error
Error: Each variable must be a 1d atomic vector or list. Problem variables: 'x', 'y', 'xend', 'yend'
I am not clear on how this error is arising in the vignette as net is a list, and all variables within it are lists. I have checked to ensure that I have all the necessary packages and they are up-to-date as well as the most recent R version.
I just tried ggnetwork and seem to get a similar error.
Any thoughts on why this errors is arising?
The error message says
Error: Each variable must be a 1d atomic vector or list. Problem
variables: 'x', 'y', 'xend', 'yend'
If you do the following
library(ggnetwork)
net <- ggnetwork(net)
class(net$x)
you will find that x is a one column matrix. The same is true for your other components. So doing
net$x <- net$x[,1]
net$y <- net$y[,1]
net$xend <- net$xend[,1]
net$yend <- net$yend[,1]
will change these all to 1d atomic vectors and
ggplot(net, aes(x = x, y = y, xend = xend, yend = yend)) +
geom_edges(aes(linetype = "directed"), color = "grey50")
should work. You can read more about how to make ggnetwork work for prettier graphs.
I had the same issue following the tutorial at briatte.github.io/ggnet.
The issue went away after I updated the 'igraph', 'ggplot', 'intergraph', 'GGally' packages and installed the 'ggnetwork' from source:
install.packages("ggnetwork", type="source").
This was suggested here to fix another issue, but somehow it worked for me on this one. Perhaps you could give it a try.
I think I've found a solution for the issue, at least on my machine. I'm running R 3.4.3 on Win 10, but this is probably not platform-related.
Until now I've had the CRAN version of GGally installed, along with network and sna, just as mentioned in the example, and this setup threw the exact same error mentioned above. I was confused as the original network object doesn't even have members like x, xend, etc. It turned out that these are in fact members of the ggnetwork object, which is created invisibly during the command ggnet() (ggnetwork vignette).
So I've tried installing ggnetwork: install.packages("ggnetwork") along with the source version of ggnet
(devtools::install_github("briatte/ggnet")).
ggnetwork was installed succesfully, but the package couldn't be loaded because it said that ggplot2 is not installed (which I've found strange because it's a package that I use on a daily basis as part of the tidyverse library).
ggnet installation failed for some reason related to packages being already loaded.
I've restarted the R session, tried loading ggnetwork again, which again failed for lack of ggplot2, so I installed ggplot2. I tried once again installing ggnet from source, (this time before any packages were loaded) and it worked.
So, to sum it up:
After restarting the R session:
install.packages("ggnetwork")
install.packages("ggplot2")
devtools::install_github("briatte/ggnet")
I don't know exactly which step did it, but afterwards the example script produced a graph plot, just as it was supposed to:
library(ggnetwork)
library(network)
library(sna)
library(ggnet)
net = rgraph(10, mode = "graph", tprob = 0.5)
net = network(net, directed = FALSE)
network.vertex.names(net) = letters[1:10]
ggnet2(net)

Resources