Displaying 2 results from an estimated 2 matches for "khess".
Did you mean:
thess
2012 Apr 05
4
Appropriate method for sharing data across functions
...be interpreted but must be built first.
JN
Example using <<-
rm(list=ls())
optstart<-function(npar){ # create structure for optimization computations
# npar is number of parameters ?? test??
OPCON<<-list(MAXIMIZE=TRUE, PARSCALE=rep(1,npar), FNSCALE=1,
KFN=0, KGR=0, KHESS=0)
# may be other stuff
ls(OPCON)
}
add1<-function(){
OPCON$KFN<<-1+OPCON$KFN
test<-OPCON$KFN
}
OPCON<<-list(MAXIMIZE=TRUE, PARSCALE=rep(1,4), FNSCALE=1,
KFN=0, KGR=0, KHESS=0)
ls(OPCON)
print(add1())
print(add1())
print(ls.str())
rm(OPCON) # Try to remo...
2012 Mar 25
2
avoiding for loops
I have data that looks like this:
> df1
group id
1 red A
2 red B
3 red C
4 blue D
5 blue E
6 blue F
I want a list of the groups containing vectors with the ids. I am
avoiding subset(), as it is
only recommended for interactive use. Here's what I have so far:
df1 <- data.frame(group=c("red", "red", "red", "blue",