I try to build a custom geom to extend ggplot2.
While the function works, I am not able to build the package as I have the following error message:
==> devtools::document(roclets=c('rd', 'collate', 'namespace'))
Updating ggvis documentation
Loading ggvis
Error in ggproto("GeomDash", Geom, required_aes = c("x", "y"), non_missing_aes = c("linetype", (from geom_dash.R#57) :
impossible de trouver la fonction "ggproto"
Calls: suppressPackageStartupMessages ... withr_with_dir -> force -> source_many -> source_one -> eval -> eval
Ex�cution arr�t�e
Exited with status 1.
I installed the dev version of ggplot2 as recommanded by Hadley. With no success. For some reason it does not show an error when I try with a dummy function such as:
f <- function(x){
return(ggproto(x))}
But it doesn't work even with the initial code of geom_segment or by integrating the ggproto function in the package's folder.
You can find my function here
I've already created a package to extend ggplot2 with no problem. It still builds just fine.
Any suggestion? Cheers.
The problem was solved by editing the NAMESPACE as suggested by #Gregor.
Removing the existing NAMESPACE file and running
devtools::document()
allowed the creation of a clean NAMESPACE file containing the required exports and imports.
Related
I am trying to push the following package to CRAN, but I keep getting an error on the check.
Error:
✓ checking R/sysdata.rda ...
WARNING
‘qpdf’ is needed for checks on size reduction of PDFs
✓ checking installed files from ‘inst/doc’ ...
✓ checking files in ‘vignettes’ ...
E checking examples (3s)
Running examples in ‘oRus-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: analyseStories
> ### Title: Analysing Stories
> ### Aliases: analyseStories
>
> ### ** Examples
>
> # Transform the stories
> fileUrl <- example_stories()
> stories <- analyseStories(fileUrl, 7)
Joining, by = "word"
Joining, by = "word"
Error in loadNamespace(name) : there is no package called ‘reshape2’
Calls: analyseStories ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
Current problems:
The example is in orus::analyseStores(...) function.
The example actually runs and works on the pkgdown website.
The error appears only when doing devtools::check
I have tried multiple things:
This answer base::assign(".ptime", proc.time(), pos = "CheckExEnv") ERROR when using devtools::check suggested using dontrun{...}. It passes CRAN's check, but it was bounced by a person after a couple of days.
This answer R package fails devtools::check, because "could not find function" even though the function is imported in NAMESPACE suggested doing require on the missing library. I did require(reshape2) but the check still does not pass.
This answer "Could not find function" in Roxygen examples during CMD check suggests that I need to make all my functions public (exported). I don't want to do that. I tried doing orus:::some_function(...) to call to the non-exported functions inside analyseStores but it doesn't work either.
According to this one: R package build failed when checking examples the data is working and the function has the #export tag. Also, namespace is properly updated.
I have run out of options. Any idea of what is happening?
As #stefan suggested in the comments, I had to add reshape2 into the Suggested packages in the description file. I added using:
usethis::usepackage("reshape2", "Suggests")
Followed by regenerating the docs:
devtools:document()
Package is on its way to CRAN!
I'm quite new to R and I got an assignment that includes a sourcecode.
Part of the source code includes the following line:
library(preprocessCore)
Then I have in my source code a definition of the following function:
quantile.normalize.raw.gtex <- function(edata.mat)
{
norm_edata = normalize.quantiles(as.matrix(edata.mat))
rownames(norm_edata) = rownames(edata.mat)
colnames(norm_edata) = colnames(edata.mat)
return(norm_edata)
}
Finally, I have an object being initialized to the output of this function, after sending a predefined parameter:
tissue.edata.qn = quantile.normalize.raw.gtex(tissue.edata)
From what I understand, the library function is supposed to include the function normalize.quantiles, which is called in the function that is defined in my source code.
However, when I run the line library(preprocessCore) I get the following error:
Error in library(preprocessCore) :
there is no package called ‘preprocessCore’
I also tried to run the rest of the code and got the error:
Error in normalize.quantiles(as.matrix(edata.mat)) :
could not find function "normalize.quantiles"
I looked for the preprocessCore online and eventually I tried to write install.packages("preprocessCore"), but I got a warning message that this package is only available in version 3.6.0 of R, even though I checked and this is the version that I have.
If somebody has any idea what the problem is, I will appreciate your help.
Thanks in advance
The preprocessCore package is available in Bioconductor. So, to install it, you need the following lines:
source("http://bioconductor.org/biocLite.R")
biocLite("preprocessCore")
After that, you can load the package using library(preprocessCore)
Hope it helps.
Im working in Studio with a raster .tif image. I have watched a tutorial on plotting the raster with the code below, however it does not work for me. I get the error:
Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'
I have loaded the necessary packages(raster and rgdal)
I have also tried loading the arulesViz, yet get the same error
YIELD <- raster("//Users//DevinOsborne//Desktop//Thesis//QGIS projects //Project//Rasters//Images//Yield_wheat.tif")
plot(YIELD,main= "Yield map")
To expand on #Chelmy88 s answer, try sp::plot()
You will first need the sp package; install.packages("sp")
I was able to recreate your error with graphics::plot()
I believe that when you load raster library sp will also be loaded.
I had similar issue while using rgdal in a custome R package.
This error as been solved for me by loading the sp library. The problem was not arising when running the script alone, but once included in the package I had the same error when using plot():
Error in as.double(y) : cannot coerce type 'S4' to vector of type
'double'
This has been solved by adding import("sp") in the NAMESPACE file and "sp" to the Import list in the DESCRIPTION file.
Unfortunately I could not find which sp function is required, so I use a full import instead of a more targeted importFrom() in the NAMESPACE file.
I created a package for R to learn how to develop these things and I got a error that I can't resolve. I saw this error was nor uncommon but I could not find a solution.
This is the code of my package (pretty simple):
absconc<-function(x,a,b,...)
{
a<-as.numeric(a)
b<-as.numeric(b)
absconcCalc<- function(x,a,b,...)
{
conc<- (x*a)+b
}
conc<-absconcCalc(x,a,b,...)
print.absconc<- function(x,a,b,...)
{
cat("Slope:")
cat(a,"\n")
cat("Intercept:")
cat(b,"\n")
cat("Concentration:")
cat(conc)
}
print.absconc(x,a,b)
}
I created the package using package.skeleton and it worked like a charm, even the building of the package using R CMD build absconc worked.
The problem was when I trying to use the package it gave me Error: could not find function "absconc".
I though it was a problem coming from NAMESPACE and the export so I tried exporting the functions using export(absconc). When I tried building that I got an error saying:
Error in namespaceExport(ns, exports) :
undefined exports: absconc, absconcCalc, print.absconc
I am now scratching my head to understand why my function are not recognized.
I would appreciate some help on that as this is only my first package.
EDIT: here are my files (A bit messy, sorry)
https://github.com/Frisacher/absconc
You should not edit NAMESPACE by hand. Insert the line #' #export at the top of your R file and run devtools::document() in the console. This will do what is necessary for you.
Now you can execute devtools::load_all() and run your function.
More explicitly:
1) Create a folder named "R" below the root directory and create an R script that contains your function as Martin Morgan suggested in the comments.
2) Add a roxygen comment to your R script to export it:
#' #export
absconc<-function(x,a,b,...)
{
a<-as.numeric(a)
b<-as.numeric(b)
...
}
3) Execute devtools::document() in the console.
> devtools::document()
Updating absconc documentation
Loading absconc
Writing NAMESPACE
4) Load your package with devtools::load_all().
> devtools::load_all()
Loading absconc
5) Run your function.
> absconc(1,2,3)
Slope:2
Intercept:3
Concentration:5
I want to use functions from the Bioconductor packages hypergraph and hyperdraw without loading the packages. When running an example from the hyperdraw vignette
dh1 <- hypergraph::DirectedHyperedge("A", "B", "R1")
dh2 <- hypergraph::DirectedHyperedge(c("A", "B"), c("C", "D"), "R2")
hg <- hypergraph::Hypergraph(LETTERS[1:5], list(dh1, dh2))
hgbph <- hyperdraw::graphBPH(hg)
I get the error:
Error in hyperdraw::graphBPH(hg) : could not find function "hyperedges"
If I try to load hyperedges:
hyperedges <- hyperdraw:::hyperedges
I get the error
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) :
object 'hyperedges' not found
When I load both packages using library or require, I get no error (in running the above code without hypergraph:: and hyperdraw::).
The reason why I do not want to load the packages is because I am building a package which uses hyperdraw and hypergraph in only one function and I'd rather put these packages into Suggests than into Depends in my DESCRPTION file.
Does anyone have an idea how to solve this?
hyperdraw has this in it's DESCRIPTION file
Depends: R (>= 2.9.0), methods, grid, graph, hypergraph, Rgraphviz
and it's relying on finding hypergraph::hyperedges on the search() path. Personally, I think hyperdraw should include a line
importFrom(hypergraph, hyperedges)
in it's NAMESPACE file. Currently, the best thing to do is to add Depends: hyperdraw to your DESCRIPTION file, and to importFrom(hyperdraw, <whatever functions you need>). I have contacted the maintainer of hyperdraw to ask them to update the NAMESPACE as above; you could then merely Imports: hyperdraw. I think you're just making work for yourself and frustrating your users by trying to use Suggests or other approaches to subvert the need for formal dependencies.