similar to: where/what is i? for loop (black?) magic

Displaying 20 results from an estimated 60000 matches similar to: "where/what is i? for loop (black?) magic"

2004 Apr 06
4
Index of a Loop Variable?
Hi Everyone:-- Is it possible, within a for loop not explicitly using whole-number indexing, to find out the index value of the loop variable within the vector or list that's being looped through? For example, in -- x <- seq(5, 50, by=5) index.in.x <- 1 for (i in x) { cat(paste(" index of i-value ", i, " within x: ", index.in.x, sep=""), fill=T)
1999 Nov 27
0
(Correction) File caching while "oplocks=False", black magic or what?
This is a corrected version of an incorrect message sent previously. *Sorry for this*. This message replaces references to lock (in the old message) with lseek. (Actually locking problems have a special position in my mind, at least for the last 3-4 years, when I am programming in heterogenous networks. But that's another story...) WELL, HERE IS THE CORRECTED MESSAGE: NOTE: I have
2012 Mar 13
1
3D Black-Scholes Graph Help!
Hello all! I would like to create a 3d plot, with the option price explained by the underlying price and time. Unfortunately, I can't quite get it to work. I would very much appreciate your help! Thanks, Anna # Black-Scholes Option Graph library(lattice) blackscholes <- function(s, k, r=.1, t=5, sigma=.9,call=TRUE) { #calculate call/put option d1 <-
2005 Aug 03
3
red-black-green color palette?
I'm working on some heatmaps, and the person I'm working with would prefer a red-black-green color palette (red denoting gene induction and green denoting gene repression). Does such a palette exist already? If not, is there an easy way to create one? Thanks, Jake
2011 Mar 31
2
That dreaded floating point trap
Hi, I had a piece of code which looped over a decimal vector like this: for( i in where ){ thisdata <- subset(herde, herde$mlr >= i) # do stuff with thisdata.. } 'where' is a vector like seq(-1, 1, by=0.1) My problem was: 'nrow(thisdata)' in loop repetition 0.4 was different if 'where' was seq(-1, 1, by=0.1) than when 'where' was seq(-0.8, 1,
2006 Nov 20
2
problem with loop to put data into array with missing data for some files
Dear R-help community, My main goal of this message is to find a way of skipping a file of a month/year in a loop that does not exist (and making it's output into an data.out array would be NA) and moving onto the next year/month in the loop to carry on filling data.out with real precipitation data. The situation so far: I downloaded 50 years worth of GRIB data files from the NCEP data
2007 Jul 04
2
for loop doesn't stop with upper loop value
Hi list, could anyone please educate me on the following: lst<-seq(47, 239, by=12) for(n in lst) { lower=n; upper=lower+10 for(i in lower+2 : upper) { print(paste(n, " i: ", i, " lower: ",lower, " upper :", upper)) } } does not stop when i = upper A while loop fixes this but, I still don't understand why the for loop doesn't stop
2005 May 13
1
How to convert color to black & white
Dear all, Could someone please explain to me how to convert color to black & white. For example: barplot(1:5,col = rainbow(5)) Because I need to print my plot to save my ink color printer. I don't want to convert to grayscale, but keep it as an RGB. I would be very happy if anyone could help me. Thank you very much in advance. Kindly regards, Muhammad Subianto
2009 Oct 22
1
Cairo package, png files within for loop are black?
Hello, I am generating .png images using the Cairo package in a for loop (looping on the number of zones, number of zones equals the number of plots to create based on different zone data). When I run the R script the .png files are created but they are all black? If I comment out the for loop and force my zones to equal one the png file is created correctly? Is there an issue with
2012 May 25
3
Multiple cbind according to filename
Hi all, I'm just a beginner with R but I have not been able to search for any relevant answer to my problem. I apologize if it has in fact been asked before. Recently I've realized that I need to combine hundreds of pairs of data frames. The filenames of the frames I need to combine have unique strings. This is my best guess as to the approach to take: filenames<-list.files()
2013 Feb 01
2
Nested loop and output help
Hello Everyone, My name is Thomas and I have been using R for one week. I recently found your site and have been able to search the archives of posts. This has given me some great information that has allowed me to craft an initial design to an inquiry I would like to make into the breakdown of McNemar's test. I have read an intro to R manual and the posting guides and hope I am not violating
2005 Dec 05
5
What is wrong with this FOR-loop?
Hi, I have a more complex example, but the problem boils down to this FOR-loop not filling in the res-matrix run_rows<-seq(0,1,0.05) run_cols<-seq(0.3,0.6,0.05) res<-matrix(NA,length(run_rows),length(run_cols)) for(i in run_rows) { for(j in run_cols) { res[i,j]=i+j #niether the above, nor res[[i,j]]=i+j work, why? } } Thank you, Serguei
2006 Nov 20
3
problem with loop to put data into array with missing data forsome files
Hi Jenny If you want a general solution I understand. However I just downloaded the file fine (as far as I can tell) so you are welcome to have a copy. I can email it to you if you want. I do not think your test for NA is valid. i.e if(test != "NA"){ } I think you should use if(is.na(test)){ } Or something similar. J --- John Seers Institute of Food Research Norwich
2011 Apr 23
2
Loop and Solver with Black/Scholes-Formula
Hello, for my diploma thesis I need to program a solver for Merton?s respectively Black?s and Scholes? Option pricing formula, which should be achieved for several dates. What I want to do is to estimate the value of a firm?s assets "vA" (x[2] denotes vA) and the option-implied volatility of firm?s assets "sigA" (x[1] denotes sigA) by solving it simultaneous using the Black
2011 Nov 18
1
couting events by subject with "black out" windows
I large datset that includes subjects(ID), Dates and events that need to be counted.  Not every date includes an event, and I need to only count one event per 30days, per subject.  So in essence, I need to create a 30-day "black out" period during which time an event cannot be "counted" for each subject.  The reason is that a rule has been set up, whereby a subject can only be
2017 Oct 12
1
Recurrence plots in R using different colours
Hello, I am an absolutely beginner with regards to R, so forgive me for my potentially very stupid questions. I have been attempting to create recurrence plots using R. The data I am using is based on a mutually exclusive and exhaustive coding scheme with over 40 individual codes which can be assigned to 6 higher order categories. When I carry out the usual rqa command, my plot is pretty much
2013 Jun 18
1
hist function in a for loop
Dear all, I need to create a for-loop in which I can compute multiple histograms My code is the following : #singlefile includes huge csv file #I want to specify the binsize #I would like to compute in the for -loop the histograms numfiles <- length(singlefile) for (i in 1 :51) { binsize <- -20 :20/2 hist(singlefile(singlefile$GVC[singlefile$new_id==i]], break=seq(),
2010 Aug 23
1
Speeding up sum and prod
Looking for more ways to speed up R, I've found that large improvements are possible in the speed of "sum" and "prod" for long real vectors. Here is a little test with R version 2.11.1 on an Intel Linux system > a <- seq(0,1,length=1000) > system.time({for (i in 1:1000000) b <- sum(a)}) user system elapsed 4.800 0.010 4.817 > system.time({for (i
2003 Mar 25
1
BUG report : 'rnorm' (LINUX, R 1.6.2) (PR#2682)
Dear colleague, unfortunately 'rnorm' does not create normal distributed numbers as you can see with following histogramm: > hist(rnorm(1000000),breaks=100) and > hist(pnorm(rnorm(1000000)),breaks=100) I have done several chi^2-tests which have all failed: > chi2unif<- function(x,N) > { > anz=length(x) > f0<-rep(anz/N,times=N) >
2005 Feb 18
1
Disable Loop Detection
Hello, I've got the following situation: --------- Asterisk1 ------------- SER ---------- other world | | ----------Asterisk2 ----------------- In addition i'm doing a sort of "vhost" on the asterisk machines, so there could be 3 seperate companies using 1 asterisk box. If an asterisk1 user calls