Re: [R] on how to make a skip-table

2013-09-12 Thread Gang Peng
n.record <- length(record.lenths$NR) index <- record.lenths$NR %in% valida.records$NR tmp <- 1:n.record ind <- tmp[index] st <- 1 skip <- rep(0,length(ind)) for(i in 1:length(ind)){ if(st > > I've got two data frames, as shown below: > (NR means Number of Record) > > record.lenths >> >

Re: [R] How to avoid searching variables in global environment

2013-09-12 Thread Gang Peng
ode you will > want to use a package - the namespace mechanism and the check command > will take care of most of this sort of problem. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -Original Message- > > From: r-help-boun..

Re: [R] How to avoid searching variables in global environment

2013-09-12 Thread Gang Peng
> Bert > > > On Thu, Sep 12, 2013 at 2:08 PM, Sarah Goslee wrote: > >> Hi, >> >> You need to specify that a is an argument to the function: >> >> On Thu, Sep 12, 2013 at 3:56 PM, Gang Peng >> wrote: >> > For example: >> > >>

[R] How to avoid searching variables in global environment

2013-09-12 Thread Gang Peng
For example: a <- 1 f <- function(b){ return(a+b) } when we call function f(2), r will search the local environment first, if it cannot find a, it will search global environment, and return 3. How to avoid r searching the global environment and return an error when we call this function? T

Re: [R] Is it possible to avoid copying arrays when calling list()?

2013-08-16 Thread Gang Peng
If you don't want to copy the data, you can use environments. You can first define x and y in the global environment and then in the function, use function get() to get x, y in the global environment. When you change x and y in the function, x and y also change in the global environment. Best, Gan

Re: [R] A question about using delayedAssign

2013-08-16 Thread Gang Peng
yed assignments. > > ** ** > > (I cannot reproduce what you show using command line R on Linux.) > > ** ** > > Bill Dunlap > > Spotfire, TIBCO Software > > wdunlap tibco.com > > ** ** > > *From:* Gang Peng [mailto:michael.gang.p...@gmail.com] &

Re: [R] A question about using delayedAssign

2013-08-16 Thread Gang Peng
, msg) > msg <- "new!" > x [1] "old" Thanks, Gang 2013/8/16 Duncan Murdoch > On 13-08-14 9:11 PM, Gang Peng wrote: > >> I run the examples in delayedAssign: >> >> msg <- "old" >> delayedAssign("x", msg) >> ms

Re: [R] A question about using delayedAssign

2013-08-16 Thread Gang Peng
}) > > f <- function(p) paste(x, p) > > f("qwerty") > Assigning 'msg' to 'x' now > [[1]] > f("qwerty") > > [[2]] > paste(x, p) > > [[3]] > print(sys.calls()) > > [1] "old qwerty" > > x > [1]

[R] A question about using delayedAssign

2013-08-14 Thread Gang Peng
I run the examples in delayedAssign: msg <- "old" delayedAssign("x", msg) msg <- "new!" x If I run these four commands together, x is "new". If I run the first two commands first and then run the last two commands, x is "old". I just cannot figure out why. Thanks. Gang [[alternative HT