From 1277546b0e0834191b209964c50f31660890b3c3 Mon Sep 17 00:00:00 2001 From: Stanislaw Jastrzebski Date: Sun, 27 Sep 2015 21:07:34 +0100 Subject: [PATCH] Fixes #574 and other CRAN submission issues --- DESCRIPTION | 7 +++---- NAMESPACE | 18 ++++++++++++++++++ R/gmum.R | 8 +++++++- R/gng.R | 9 ++++++--- R/gng.utils.R | 2 ++ man/calculateCentroids.Rd | 2 ++ man/findClosests.Rd | 2 ++ man/gng.Rd | 2 ++ src/packThis.sh | 3 +++ src/svmlight/svm_learn.c | 2 +- tests/test-all.R | 4 ++++ 11 files changed, 50 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c39a0dc3..e10b422b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gmum.r Version: 0.2 -Date: 2015-08-05 +Date: 2015-09-25 Title: Efficient C++ Implementations of SVM, GNG and CEC Models Type: Package Author: Wojciech Czarnecki, Stanislaw Jastrzebski, Marcin Data, Igor Sieradzki, Mateusz Bruno-Kaminski, Karol Jurek, Piotr Kowenzowski, Michal Pletty, Konrad Talik, Maciej Zgliczynski @@ -8,14 +8,13 @@ Maintainer: Stanislaw Jastrzebski Description: Package focusing on efficiency (C++ implementations) and intuitive API. gmum.r is a close collaboration between GMUM group members (http://gmum.net) and students. License: MIT + file LICENSE Repository: CRAN -Depends: +Imports: ggplot2 (>= 1.0.0), stats, igraph, SparseM, - httr, Matrix, - MASS (>= 7.3), + httr, Rcpp (>= 0.11.6) LinkingTo: Rcpp, RcppArmadillo, BH NeedsCompilation: yes diff --git a/NAMESPACE b/NAMESPACE index 154dfd7f..15cc7320 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -80,4 +80,22 @@ importFrom(ggplot2,scale_colour_brewer) importFrom(ggplot2,scale_fill_brewer) importFrom(ggplot2,scale_size_continuous) importFrom(ggplot2,scale_size_identity) +importFrom(grDevices,rainbow) +importFrom(graphics,hist) +importFrom(graphics,pairs) +importFrom(graphics,par) +importFrom(graphics,plot) +importFrom(graphics,plot.new) +importFrom(graphics,points) +importFrom(graphics,title) +importFrom(httr,GET) +importFrom(httr,content) +importFrom(stats,na.omit) +importFrom(stats,prcomp) +importFrom(stats,predict) +importFrom(stats,rnorm) +importFrom(stats,runif) +importFrom(stats,update) +importFrom(utils,data) +importFrom(utils,read.csv) useDynLib(gmum.r) diff --git a/R/gmum.R b/R/gmum.R index 8ce54528..70c2ef29 100644 --- a/R/gmum.R +++ b/R/gmum.R @@ -1,3 +1,9 @@ +#' @importFrom grDevices rainbow +#' @importFrom graphics hist pairs par plot plot.new points title +#' @importFrom stats na.omit prcomp predict rnorm runif update +#' @importFrom utils data read.csv +NULL + # Lazy loading to allow for discovery of all files evalqOnLoad( { # Autocompletion override @@ -12,7 +18,7 @@ evalqOnLoad( { .DollarNames.Rcpp_CecModel <<- autocompl # Workaround RStudio bug - if(exists(".rs.getAnywhere")) { + if(exists(".rs.getAnywhere") && !exists(".rs.getAnywhere.original")) { .rs.getAnywhere.original <<- .rs.getAnywhere .rs.getAnywhere <<- function(a, envir=.GlobalEnv){ .rs.getAnywhere.original(a, .GlobalEnv) } } diff --git a/R/gng.R b/R/gng.R index e963bc68..2aa9f020 100644 --- a/R/gng.R +++ b/R/gng.R @@ -4,7 +4,6 @@ library(methods) #' @importFrom ggplot2 scale_size_continuous scale_size_identity geom_point aes ggplot geom_tile scale_fill_brewer scale_alpha_identity scale_colour_brewer geom_abline NULL - #' Use first two spatial coordinates as position in layout #' #' @note You can pass any igraph layout algorithm to plot @@ -113,8 +112,10 @@ gngLoad <- NULL #' @param community.detection.algorithm Used algorithm from igraph package, by default spinglass.community #' #' @examples +#' \dontrun{ #' gng <- GNG(gng.preset.sphere(100)) #' print(node(gng, calculateCentroids(gng)[1])$pos) +#' } calculateCentroids <- NULL #' Find closest node @@ -128,11 +129,12 @@ calculateCentroids <- NULL #' @param x Can be either \code{vector} or \code{data.frame.} #' #' @examples +#' \dontrun{ #' gng <- GNG(gng.preset.sphere(100)) #' # Find closest centroid to c(1,1,1) #' found.centroids <- calculateCentroids(gng) #' findClosests(gng, found.centroids, c(1,1,1)) -#' +#' } findClosests <- NULL #' Check if GNG is running @@ -421,6 +423,7 @@ clustering.Rcpp_GNGServer <- NULL #' @param seed Seed for internal randomization #' #' @examples +#' \dontrun{ #' X <- gng.preset.sphere(100) #' y <- round(runif(100)) #' # Train in an offline manner @@ -436,7 +439,7 @@ clustering.Rcpp_GNGServer <- NULL #' terminate(gng) #' # Plot #' plot(gng) -#' +#' } GNG <- NULL #' @title convertToIGraph diff --git a/R/gng.utils.R b/R/gng.utils.R index f4e51705..defe1dbe 100644 --- a/R/gng.utils.R +++ b/R/gng.utils.R @@ -1,3 +1,5 @@ +#' @importFrom httr GET content + #' @export #' @rdname print.gng #' @method print Rcpp_GNGServer diff --git a/man/calculateCentroids.Rd b/man/calculateCentroids.Rd index bab37edb..50640cf3 100644 --- a/man/calculateCentroids.Rd +++ b/man/calculateCentroids.Rd @@ -19,7 +19,9 @@ Using passed community.detection finds communities and for each community pick n Get centroids } \examples{ +\dontrun{ gng <- GNG(gng.preset.sphere(100)) print(node(gng, calculateCentroids(gng)[1])$pos) } +} diff --git a/man/findClosests.Rd b/man/findClosests.Rd index 530166d0..e5196650 100644 --- a/man/findClosests.Rd +++ b/man/findClosests.Rd @@ -20,9 +20,11 @@ Finds closest node from given list to vector. Often used together with calculate Find closest node } \examples{ +\dontrun{ gng <- GNG(gng.preset.sphere(100)) # Find closest centroid to c(1,1,1) found.centroids <- calculateCentroids(gng) findClosests(gng, found.centroids, c(1,1,1)) } +} diff --git a/man/gng.Rd b/man/gng.Rd index 91e448ba..a823695f 100644 --- a/man/gng.Rd +++ b/man/gng.Rd @@ -52,6 +52,7 @@ see \url{http://sund.de/netze/applets/gng/full/tex/DemoGNG/node20.html}} Construct GNG object. Can be used to train offline, or online. } \examples{ +\dontrun{ X <- gng.preset.sphere(100) y <- round(runif(100)) # Train in an offline manner @@ -68,4 +69,5 @@ terminate(gng) # Plot plot(gng) } +} diff --git a/src/packThis.sh b/src/packThis.sh index 3cc4ac06..27b29753 100755 --- a/src/packThis.sh +++ b/src/packThis.sh @@ -43,3 +43,6 @@ rm -r $destination/..Rcheck rm -r $destination/.git rm -r $destination/.idea rm -r pkg/pkg +rm -r pkg/doc +rm -r pkg/cmake +rm -r pkg/libs diff --git a/src/svmlight/svm_learn.c b/src/svmlight/svm_learn.c index 920cec38..42bb5895 100644 --- a/src/svmlight/svm_learn.c +++ b/src/svmlight/svm_learn.c @@ -3714,7 +3714,7 @@ CFLOAT *kernel_cache_clean_and_malloc(KERNEL_CACHE *kernel_cache, } kernel_cache->invindex[result]=docnum; kernel_cache->lru[kernel_cache->index[docnum]]=kernel_cache->time; /* lru */ - return((CFLOAT *)((long)kernel_cache->buffer + return((CFLOAT *)((intptr_t)kernel_cache->buffer +(kernel_cache->activenum*sizeof(CFLOAT)* kernel_cache->index[docnum]))); } diff --git a/tests/test-all.R b/tests/test-all.R index 45e02dd5..46f33941 100644 --- a/tests/test-all.R +++ b/tests/test-all.R @@ -24,4 +24,8 @@ if(!is.installed("e1071")){ install.packages("e1071",repos='http://cran.us.r-project.org') } +if(!is.installed("MASS")){ + install.packages("MASS",repos='http://cran.us.r-project.org') +} + test_check('gmum.r')