Error using plotly in Rstudio - unused argument plot$data - r

Even while using the sample code given in ggplotly help function... I'm continuously getting the below error
Error in map_layout(panel, plot$facet, layer_data, plot$data) :
unused argument (plot$data)

I had the same issue and followed the solution suggested by #royr2. Specifically, I installed the development version of plotly using devtools::install_github("ropensci/plotly") and restarted my R session and reloaded the package. After that, ggplotly worked again in RStudio.

I know this isn't an answer per se, but this has been documented as known issue with ggplot 2.1.0 - see link:
https://github.com/ropensci/plotly/issues/481

Related

plot_histogram() function in R not working. Please assist?

I'm trying to make a batch histogram visualization from my data in RStudio. Meaning, I want to create a histogram for each variable in my dataframe at once. For some reason I keep getting an error message saying that the plot_histogram() function doesn't exist. Has anyone else had this problem? Could this be a problem with the latest updated version of R? I recently downloaded R version 4.1.1 and have checked for package updates and am still having this problem. Any help would be much appreciated.
plot_histogram() error message
Okay, so the moral of the story is that the name in the upper left hand corner on the RDocumentation website is the package that needs to be installed for a function to work. So if R is saying that the package doesn't exist, install and load that name.
Package name on RDocumentation

Python - Bokeh Interactive Legend - Attribute Error

I am trying to make an interactive legend.
Even when I run the code in this link https://docs.bokeh.org/en/latest/docs/user_guide/interaction/legends.html
I get the error:
AttributeError: unexpected attribute 'legend_label' to Line, possible attributes are js_event_callbacks, js_property_callbacks, line_alpha, line_cap, line_color, line_dash, line_dash_offset, line_join, line_width, name, subscribed_events, tags, x or y
Any ideas why? I have the latest version of Bokeh, as far I know.
Use legend instead of legend_field or legend_label.
legend_label was added in version 1.4. You will have to update to that or later, or else refer to the docs specific to your version:
https://docs.bokeh.org/en/1.3.4/docs/user_guide/interaction/legends.html
I got a similar error when installing bokeh through the shell first and through the conda later. This got me with two versions and the old one was preferred.
I think what solved it for me: uninstalling previous versions, installing only conda (I have done it in Jupyter Notebook) and restarting the computer afterwards. Hope it helps.

Error using plotly from R from Windows command line

I am using plotly in a project being used/run from windows/linux/mac machines. Generally this has been working fine, but I have an issue when trying to generate plotly plots from command line in windows.
As a reproducible example, following the code here:
install.packages("plotly")
library(plotly)
p <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
p
Results in the error:
Error in shell.exec(url) :
access to '...\Local\Temp\Rtmpq42cvu\viewhtmla386dc27ae4/index.html' denied
That last backslash being the wrong way is an obvious candidate for the problem. And if I point my browser to the same file but with the last backslash changed to match the others, I see the plot as expected.
Could someone please check if they have the same problem? Note that I only have this problem when running from the command line. If I run the same code from Rstudio it works no problem. I'm on R version 3.4.0 and packageVersion("plotly") returns ‘4.6.0’.
Following the comment from #MikeWise (many thanks) I tried switching my default browser from firefox to chrome, and this fixed the issue.
Also, I have confirmed that this issue is also resolved by using an up-to-date version of firefox.

choroplethr sudden error in choro$render

very new to R, and this is my first question so please be kind :)
I was working with the choroplethr/choroplethrMaps/choroplethrZip packages for a few days without any issues, but suddenly, I keep getting the an error when I try to visualize a map--I have pasted the output below, and any help would be deeply appreciated.
The most perplexing issue for me is why it suddenly stopped working--I didn't add anything to the script--I get the same error with choroplethr/choroplethrMaps as well. Many thanks for your expertise and patience!
data(df_pop_zip)
choro = ZipChoropleth$new(df_pop_zip)
choro$title = "2012 ZCTA Population Estimates"
choro$ggplot_scale = scale_fill_brewer(name="Population", palette=2, drop=FALSE)
choro$set_zoom_zip(state_zoom="florida", county_zoom=NULL, msa_zoom=NULL, zip_zoom=NULL)
choro$render()
Error in FUN(X[[i]], ...) : attempt to apply non-function
I believe that your error can be solved by typing the following:
# install.packages("devtools")
library(devtools)
install_github("choroplethr", "arilamstein")
library(choroplethr)
If I install choroplethr from CRAN I can replicate your error. If I install it from github I can solve it. Note that the actual R code is currently the same in both github and CRAN, because I recently submitted a new version to CRAN.
When I load the version of choroplethr from CRAN I get this warning:
> library(choroplethr)
Warning message:
package ‘choroplethr’ was built under R version 3.2.4
However, the current version of R is 3.2.3. So it looks like CRAN is using different version of R for what they are distrbuting to the public and what they are using to build packages. I'm not sure why this is.
Note that while I think this solution will work for you, I don't find it particularly satisfying or elegant. I could probably install the development version of R to see if I can replicate (and debug) the issue myself. But at this point I'd rather wait until they officially release the new version to see if it is still present. I really don't have much experience with the development versions of R.

Does ggplot2 work with the current version of R (v 2.15.1)?

I am attempting to run the R code from this question
and I get the following error:
Error in rename(x, .base_to_ggplot, warn_missing = FALSE) :
could not find function "revalue"
I wonder whether it's an incompatibility between the R version I'm using and ggplot2 (v. 0.9.3.1). Is anybody aware of this problem, or is my issue something else?
Yes, ggplot2 works with the current version of R (3.0.1)
revalue is not a function in ggplot2, it's a function in plyr as pointed out in the comments.
A simple google search function revalue R will reveal this. Many packages depend on one another - so when you see an error like the one above, you need to use google/some other resource to find which package the missing function is from.

Resources