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
>>
>
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..
> 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:
>> >
>>
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
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
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]
&
, 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
})
> > 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]
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
9 matches
Mail list logo