I have successfully uploaded R package in CRAN. Now I want to publish its article. Reviewer 2 returned the paper due to memory usage issues. Now I am confused about this objection, how to solve this.
Generally, my package is about density plots and I create S3 class for each style of plot. Almost each function used 2 for
loops otherwise code is not too long. But according to Advanced R for
loops are slow. So what is best alternative?
Chunk of Code
xxx<-function(y,k,h){
n<-length(y)
x <- seq(min(y) + 0.05, max(y), length =k)
K <- matrix(rep(0, k * n), ncol = k)
fhat <- rep(0, k)
###########Loops###########
for(j in 1:k) {
for(i in 1:n) {
####main code###
}
fhat[j] <- 1/n * (sum(K[, j]))
}
results <- list(x=x, y=fhat)
class ( results ) <-c('list', 'XXX')
results
}
k
is grid point and defined by user. What is the problem and how to solve this? Additionally, they wrote code writing style is not too good; How I can improve this?