similar to: avoiding for loops

Displaying 20 results from an estimated 14000 matches similar to: "avoiding for loops"

2012 Apr 05
1
integrate function - error -integration not occurring with last few rows
Hi, I am using the integrate function in some simulations in R (tried ver 2.12 and 2.15). The problem I have is that the last few rows do not integrate correctly. I have pasted the code I used. The column named "integral" shows the output from the integrate function. The last few rows have no integration results. I tried increasing the doses, number of subjects, etc.... this error occurs
2012 Apr 04
3
Rgui maintains open file handles after Sweave error
Hello Folks, When I run the document below through sweave, rgui.exe/rsession.exe leaves a file handle open to the sweave-001.pdf graphic (as verified by process explorer). Pdflatex.exe then crashes (with a Permission Denied error) because the graphic file is locked. This only seems to happen when there is an error in the sweave document. When there are no errors, no file handles are left open.
2012 Apr 08
1
Avoid loop with the integrate function
Dear R users, I am running a loop with the integrate function. I have pasted the code below. I am integrating a function from time=0 to the time value in every row. I have to perform this integration over thousands of rows with different parameters in each row. Could someone please suggest if there is an efficient/faster/easier way to do this by avoiding the loops ? Thank you so much for your
2009 Mar 17
1
Combining Sweave and fancyvrb
I find Sweave very useful and I was trying to combine it with the latex package fancyvrb. I was trying to get line numbering and labels in order to reference the lines where particular commands occur. Unfortunately, I haven't been able to figure out how to do it. Maybe somebody can help me. The following is a sample Rnw file: the first part shows what I would like to get, the second what I
2012 Apr 05
4
Appropriate method for sharing data across functions
In trying to streamline various optimization functions, I would like to have a scratch pad of working data that is shared across a number of functions. These can be called from different levels within some wrapper functions for maximum likelihood and other such computations. I'm sure there are other applications that could benefit from this. Below are two approaches. One uses the <<-
2012 Apr 05
1
reclaiming lost memory in R
Dear list, I am trying to reclaim what I think is lost memory in R, I have been using gc(), rm() and also using Rprof to figure out where all the memory is going but I might be missing something. I have the following situation basic loop which calls memoryHogFunction: for i in (1:N) { dataset <- generateDataset(i) fit <- try( memoryHogFunction(dataset, otherParameters)) } and
2009 Apr 16
2
there are fontencoding problem in Sweave
I want write article by russian language using Sweave. For cyrillic text LaTeX use T2A encoding \usepackage[T2A]{fontenc} But in Sweave.sty we find: \RequirePackage[T1]{fontenc} It is source of critical problem. For example Rnw file $ cat estimation.Rnw \documentclass[A4paper]{article} \usepackage[T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian,english]{babel}
2009 Jun 26
0
Modifying Sweave.sty to allow escapes with fancyvrb package in LaTeX
Dear Colleagues: In an attempt to have things like # See page \pageref{this} inside comments in R code chunks I have modified Sweave.sty as below. I have followed fancyvrb's manual with regard to the use of the commandchars argument. But when compiling with LaTeX (using attached test file) I get a LaTeX error (/usr/share/texmf-texlive/tex/latex/ae/t1aett.fd) ! Missing \endcsname
2010 Aug 10
1
Sweave with dev.new()
Dear list. I am preparing a R package, and the last step is to write a package vignette using Sweave. However, I am experiencing some trouble when trying to include plots in my Sweave document. That is, in my package I have made some plotting functions in which I start by calling 'new.dev()' to start a graphics device of a certain width and height, and then proceed with plot(). These
2011 Sep 08
2
ggplot geom_freqpoly() layers ..?
Hi, I was trying to overlay/combine two freqpoly plots. The sample code below illustrates the problem. Essentially, I want to do is: 1. Have the same colour for all the lines in 'Plot 1' (and 'Plot 2'). Currently, all the lines in Plot 1 have different colours and all the lines in Plot 2 have different colors. I'd like for all lines in Plot 1 to be 'red' and all the
2003 May 08
3
Avoiding loops to spare time and memory
Is it possible to avoid the loop in the following function (or make the function otherwise more efficient) and can someone point me to a possible solution? (It would be great if hours could be reduced to seconds :-). # --------------------------------------------- RanEigen=function(items=x,cases=y,sample=z) { X=matrix(rnorm(cases*items),nrow=cases,byrow=F) S=crossprod(X-rep(1,cases) %*%
2016 Jul 29
2
strange behavior in 'inherits' check for loaded S4 object
I should add one more item that may be related here -- calling 'methods:::.requirePackage' returns a different result based on whether the package namespace is already loaded or not. If the package namespace is not loaded, the package is loaded and attached, and the package environment is returned: > methods:::.requirePackage("digest") Loading required package:
2016 Jul 31
2
strange behavior in 'inherits' check for loaded S4 object
(Just returning from the "wilds" of Canada, so not able to comment on the specifics, but ...) There is a basic point about generic functions that may be related to the "private" class question and my earlier remarks that Martin alluded to. R (and S4 before it) allows packages to define methods for a generic function in another package. Say, for plot() in graphics. The
2011 Sep 08
1
ggplot2 freqpoly() layers..?
Hi, I was trying to overlay/combine two freqpoly plots. The sample code below illustrates the problem. Essentially, I want to do is: 1. Have the same colour for all the lines in 'Plot 1' (and 'Plot 2'). Currently, all the lines in Plot 1 have different colours and all the lines in Plot 2 have different colors. I'd like for all lines in Plot 1 to be 'red' and all
2003 Jun 03
3
Update VR_7.1-6
The update of VR by downloading VR_7.1-6.zip and using install.packages (from local zip files) fails with the following error message: Error in file(file, "r") : unable to open connection In addition: Warning message: cannot open file `VR/DESCRIPTION' Other packages can be installed without problems, except of dse_2003.4-1 with a similar error message. Why? Operating System:
2002 Nov 13
1
Package documentation and rd.sty
Hi all, I've got a basic question regarding package documentation and rd.sty. I wrote my first own package, and now I would like to place the documentation into the appendix of another LaTex document. Seemingly I cannot simply \usepackage{Rd}, as this will modify the page-settings of my document. Is there a minimum style file which will just define the environments and commands needed for
2018 Nov 03
1
odd NOTE in R CMD check of data; Rcpp module related
With the current version of the "raster" package (that I maintain), R CMD check on packages "soilDB" and "PopGenReport" have this NOTE: Package: soilDB Check: data for non-ASCII characters New result: NOTE Error in .requirePackage(package) : unable to find required package 'raster' Calls: <Anonymous> ... .findInheritedMethods ->
2024 Mar 01
3
installation: while running make, unable to run pdflatex on 'NEWS.tex'
A kind member of R-core suggested this is due to a misconfiguration on my system, and to post it to the mailing list for troubleshooting. When trying to build R version 4.3.3, in at least two places during the process it gives LaTeX errors of the form: (example 1) you should 'make docs' now ... make[1]: Entering directory '/home/btyner/R-4.3.3/doc' creating
2012 May 07
1
Repeating
Dear All, I have a codes which calculates the result of Ripley's K function of my data. I want to repeat this process 999 times. However, i am getting an error when i use the "for i in" function. Is there any way to repeat this analysis 999 times. Here are the codes i used ; data4 <- matrix(c(sample(id),data1),203,3) a <- data4[,1] random.case=data4[a==0,]
2012 Aug 27
1
interpret the importance output?
> importance(rfor.pdp11_t25.comb1,type=1) %IncMSE v1 -0.28956401263 v2 1.92865561147 v3 -0.63443929130 v4 1.58949137047 v5 0.03190940065 I wasn't entirely confident with interpreting these results based on the documentation. Could you please interpret? [[alternative HTML version deleted]]