Re: [R] R- Help (looping)

2012-07-31 Thread Rui Barradas
Hello, Inline Em 31-07-2012 02:59, Wellington Silva escreveu: Ok, This really helped. You've probably noticed, I'm a begginer using R. And when you said that you tried with rnorm and the counts were not zero, where did you use the rnorm? Where the runif is, in its stead use matrix(

Re: [R] R- Help (looping)

2012-07-31 Thread Rui Barradas
Hello, Glad it helped. E fico à espera do relatório. Rui Barradas Em 31-07-2012 14:40, Wellington Silva escreveu: Rui, This is a cientific initiation program. The idea is to develop a code which can simulate data and calculate the ARL later. *So, a little bit later yesterday night, after

[R] R- Help (looping)

2012-07-30 Thread Wellington G. Silva
Hi, I'm Wellington from Brazil and I have the following issue: I've been working on a project a for a while, and I'm having trouble in using the loop (for) I need to read a column (c1), and for each value of this column, I need to check if it's within the control limits So, I was

Re: [R] R- Help (looping)

2012-07-30 Thread Rui Barradas
Hello, Your code example doesn't make much sense, it needs decrypting. Let's see, for(k in 1:length(c1)){ if(c1[k] lcl | c1[k] ucl) {do something} } If this is it, then you can completely avoid the loop: i1 - c1 lcl | c1 ucl # create an index vector out.of.control - c1[ i1 ]

Re: [R] R- Help (looping)

2012-07-30 Thread Rui Barradas
Hello, Try the following. # make up some data dds - 1e3 nc - 10 xss - data.frame(matrix(runif(nc*dds, min=-1, max=1), ncol=nc)) names(xss) - paste0(xs, 1:10) # two functions with descriptive names getControlLimits - function(x, L = 3){ mu - mean(x) sigma - sd(x) c(lcl = mu -