Displaying 2 results from an estimated 2 matches for "optstart".
2012 Apr 05
4
Appropriate method for sharing data across functions
...ructure in and out might be the proper way. An onAttach() approach was suggested by Paul
Gilbert and tried, but it has so far not succeeded and, unfortunately, does not seem to be
usable from source() i.e., cannot 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<<...
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",