Here is the code:
data(attitude)
library(ggplot2)
library(reshape2)
qplot(x=Var1, y=Var2, data=melt(cor(attitude)), fill=value, geom="tile")
Here is the error that appears:
Error in .Call("_scales_doColorRamp", PACKAGE = "scales", colors, x,
alpha, : "_scales_doColorRamp" not available for .Call() for
package "scales"
I already tried to delete and reinstall package "scales" or to restart R but with no change.
EDIT: Problem solved. I desinstalled and reinstalled the package "scales" but, this time, when they asked me "Do you want to install from sources the package which needs compilation?" during the installation, I answer "no". The script works now. Does anyone know why it solved it?
Related
I usually plot my data with the following ggplot syntax:
ggplot(sent.TN.yr.avg, aes(y = (log10(mean)), x = YEAR, color = ECOREGION)) +
geom_point(size = 1, alpha = 0.4) +
geom_smooth(se=TRUE) +
xlab(expression(paste("Year"))) + ylab(expression(paste("Mean TN (", mu, "g", L^-1,")"))) +
theme_light()
But this recently led me to the following loadnamespace(name) error:
Error in loadNamespace(x) : there is no package called ‘labeling’
I'm not sure how this code prompted an error related to "labeling." Still, I tried restarting RStudio and installing that, but it cannot be supported by this version of RStudio (2022.02.3). I also tried the same thing with the "scales" package and got the same result. I've also tried changing the repository to different CRAN mirrors with no success.
Any tips?
Package ggplot2 imports package scales which imports package labeling. So in order to use ggplot you should have installed the other two packages as well.
The version of RStudio most likely has nothing to do with it. But if you recently switched from R version 4.1.* to R4.2.* you have to upgrad all your installed packages (they have to be recompiled after a major R version release).
You can do this in RStudio: Tools -> Check for Package Updates...
or directly in R with: update.packages(checkBuilt = TRUE)
By the way, on the ggplot2 page there is an example of how mathematical expressions can be inserted into axis labels:
https://ggplot2.tidyverse.org/articles/faq-axes.html?q=superscript#how-can-i-add-superscripts-and-subscripts-to-axis-labels
I try to use the function "get_data_structure" but got an error as below.
Could anyone know how to fix it?
Thank you in advance
get_data_structure("DUR_D")
Error in data.frame(data_structure#concepts) :
trying to get slot "concepts" from an object (class "data.frame") that is not an S4 object
The problem appears to be a bug in the version of the OECD package on CRAN. If you install the development version, it works. First, close R and reopen a clean new session, then run this:
remotes::install_github("https://github.com/expersso/OECD")
library(OECD)
get_datasets()
get_data_structure("DUR_D")
remotes::install_github("https://github.com/expersso/OECD")
library(OECD)
dataset <- "DUR_D"
dstruc <- get_data_structure(dataset)
Try with get_dataset("DUR_D") i.e. without -s. as get_datasets() with -s will return a dataframe of available datasets.
It is a bug in the package OECD 0.2.5.
It works with the package version 0.2.4 which you can install from CRAN's archived package section (https://cran.r-project.org/src/contrib/Archive/OECD).
If you want to access the archived package version directly in R, use the following code:
devtools::install_version("OECD", version = "0.2.4", repos = "https://stat.ethz.ch/CRAN/")
Note that this requires the package 'devtools' to be installed.
I want to create a lognormal (or other distribution) probability plot in R (for R-studio). I have looked around on the web for an example but none of the examples tell me what package I need to install in order to use the function.
logn_prob_plot <- function()
{
x<-rlnorm(10,5,1)
x
probplot(x,qdist=qlnorm,xlab="failure time",ylab="lognormal probability")
}
Error in probplot(x, qdist = qlnorm, xlab = "failure time", ylab = "lognormal probability") : could not find function "probplot"
Writing up the comment thread as an answer:
The error (could not find function "probplot") is showing up because a necessary package is not installed. It's not specifically related to creating a probability plot.
Googling "r probplot" turns up the documentation for the package e1071, which is available in CRAN.
The package can be installed by entering install.packages("e1071") in your terminal or by selecting Tools -> Install Packages in the RStudio GUI. You can then load that package using library("e1071").
Today I've been asked to draw some charts using plotly package for a Shiny application but i can't figure out how to solve my problem, so i've decided to ask for some help !
Everytime I try to use the function "plot_ly" I get the same error :
Error in arrange_impl(.data, dots) :
Evaluation error: as_dictionary() is defunct as of rlang 0.3.0.
Please use as_data_pronoun() instead.
I tried to remake the example from the official website of plotly and the result stay the same !
For instance, when i try the following code I get the message above :
library(plotly)
USPersonalExpenditure <-
data.frame("Categorie"=rownames(USPersonalExpenditure),
USPersonalExpenditure)
data <- USPersonalExpenditure[,c('Categorie', 'X1960')]
p <- plot_ly(data, labels = ~Categorie, values = ~X1960, type = 'pie')
I also re-installed the package, updated every package i had installed but their is nothing to do i'm still stucked with that error.
I didn't found anything revelant on google neither.
Thank you in advance and happy new year !
I solved my issue ! I didn't had the package dplyr installed actually...
The answer that helped me was given by cderv (https://community.rstudio.com/t/plotly-unable-to-draw-graphs/20639) :
This seems like a compatibility issue between :package: version. rlang version seems to be newer than your installed dplyr can deal with
I am a new user of R, i have tried the following code. It gives an error. Can anyone help, please. The codes are:
library(ggplot2)
data(diamonds)
qplot(price, data=diamonds)
I am running R (2.15.3) in a x64 Wintel computer, having the very same problem.
I just googled around and found the following solution:
1st - From a fresh R session (not using RStudio, just in case), uninstall the packages "ggplot2", "scales", "plyr", "reshape2", "gtable"
remove.packages(c("ggplot2","scales","plyr","reshape2","gtable"))
2nd - quit R and go to your library directory. I had found that plyr library is not completely removed by remove.packages, keeping the plyr ddl in the system. Then manually remove the library folders, if needed.
3rd - Start R again and install again the libraries.
install.packages(c("ggplot2", "scales", "plyr", "reshape2", "gtable"))
4th - Update packages to get the latest versions.
update.packages(ask=FALSE, checkBuilt=TRUE)
5th - I runned a very symple example to check that ggplot2 is properly installed:
library(ggplot2)
library(gridExtra)
ggplot(mtc, aes(x = factor(gear))) + geom_bar(stat = "bin")
A very simple barplot should be rendered.
Hope it works for you!
D.