I am trying to plot a graph using the plot_time_series function and keep on getting the following error
> Retail %>%
+ plot_time_series(Date, Profit, .interactive = F)
Error: Problem with `mutate()` input `.value_smooth`.
x No method for class character.
i Input `.value_smooth` is `auto_smooth(...)`.
Any suggestions? I tried uninstalling the timetk package but that didn't work.
Related
I'm trying to use the rayshader package in R to plot elevation data, but I'm getting an error when I call the plot_map() function. I can't even get the example to run without running into the following error. Any ideas on how to get this function to run?
error in evaluating the argument 'x' in selecting a method for function 'plotRGB': unused argument (asp = 1)
Here is the example code that I am calling.
library(rayshader)
#Here, I load a map with the raster package.
loadzip = tempfile()
download.file("https://tylermw.com/data/dem_01.tif.zip", loadzip)
localtif = raster::raster(unzip(loadzip, "dem_01.tif"))
unlink(loadzip)
#And convert it to a matrix:
elmat = raster_to_matrix(localtif)
#We use another one of rayshader's built-in textures:
elmat %>%
sphere_shade(texture = "desert") %>%
plot_map()
In my package, I like to create a mosaic plot. In the interactive session, this works well. However, if I call the function from an fresh R session with devtools::load_all, the error "Discrete value supplied to continuous scale" is raised.
Here is a minimum working example:
test_ggmosaic <- function(dat) {
dat <- datasets::mtcars
p <- ggplot2::ggplot(data=dat)+
ggmosaic::geom_mosaic(
ggplot2::aes(weight=mpg,x=ggmosaic::product(gear, cyl), fill=mpg)
) +
ggplot2::theme_bw()+
ggplot2::scale_fill_discrete(guide=ggplot2::guide_legend(reverse=TRUE)
)
return(p)
}
Now when this function is defined inside a package, and ggplot2 and ggmosaic are added to the Imports field in the DESCRIPTION file, and I call this function after loading devtools and (via load_all) the package the function is in, I get the error
Fehler: Discrete value supplied to continuous scale
When, on the other hand, I first execute
library(ggplot2)
library(ggmosaic)
and then call the function above, the plot appears (and does not make much sense in this example).
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!
Just starting to experiment TraMiner, after having read the (very good) User Guide
I managed to create the sequences from my data, but as I'm trying to plot I got the following errors:
> seqiplot(my.data$sequences, title="My first sequences", withlegend = TRUE)
Error in do.call(plot, args = plist) :
'what' must be a string or a function
Where does this come from and what can I do about it?
I think you get an error because you override the plot function. This reproduce the error:
plot <- 1
do.call(plot,list(0))
Error in do.call(plot, list(0)) :
'what' must be a character string or a function
This should ork:
rm(plot)
seqiplot(my.data$sequences, title="My first sequences", withlegend = TRUE)
I guess the error shows up because you restricted your sequence state object to the single variable my.data$sequences. Have you tried my.data instead?
Trying the ggplot2 examples in the online reference manual, and particularly in this page, I fail to produce all but the first of the second example's plots.
> d + stat_density2d(geom="tile", aes(fill = ..density..), contour = FALSE)
Error in `[<-.data.frame`(`*tmp*`, var, value = list(`NA` = NULL)) :
missing values are not allowed in subscripted assignments of data frames
In addition: Warning message:
Removed 34912 rows containing missing values (stat_density2d).
I have R ver. 2.10.1 and ggplot2 ver. 0.8.6
What is wrong?
It seems to be the bug reported here:
http://groups.google.com/group/ggplot2/browse_thread/thread/6a7929d2b122efb2