[R] place 4 ini files

2004-08-16 Thread Thomas . Bock
Dear expeRts,

I collect some lab specific functions for a package.
Some of this functions need initial data 
(ini files written in R-code). My question is:
Where is the place in the package structure for such files; 
how to load the files?
I think something like:

source(paste(R.home(),"/library/__pkg__/data/__.ini.R", sep=""))

looks a bit clumsy.
I haven't find something about this 
in the "writing R extensions".

Regards
Thomas 

|| Thomas Bock c/o Physikalisch-Technische Bundesanstalt
|| Abbestr. 2-12; D-10587 Berlin, Germany
|| Tel/Fax: ++49-30-3481-354/490, email: [EMAIL PROTECTED]
[[alternative HTML version deleted]]

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Thomas Bock
Dear list,

I can not understand why the expression in
the subject does not work correct:
> dcrn[which(fn == inve[2])]
numeric(0)
> inve[2]
[1] 406.7
> dcrn[which(fn == 406.7)]
[1] 1.3994e-07 1.3988e-07 1.3953e-07 1.3966e-07 1.3953e-07 1.3968e-07
Is this a kick self problem or an bug?

Thaks very much
Thomas
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] first value from nlm (non-finite value supplied by nlm)

2003-10-24 Thread Thomas Bock
Dear expeRts,

first of all I'd like to thank you for the
quick help on my last which() problem.
Here is another one I could not tackle:
I have data on an absorption measurement which I want to fit
with an voigt profile:
 fn.1 <- function(p){
   for (i1 in ilong){
 ff <- f[i1]
 ex[i1] <- exp(S*n*L*voigt(u,v,ff,p[1],p[2],p[3])[[1]])
   }
sum((t-ex)^2)
 }
out <- nlm(fn.1, p = c(fo, GG, GL), hessian = TRUE, steptol = 1e-5, 
iterlim = 1000)
foN <-  out$estimate[1]
GGN <-  out$estimate[2]
GLN <-  out$estimate[3]

This works fine but the my start value of S is to poor,
so I like to fit S in a second run, with the initial values from the 
first run
(two runs because I know that S as an parameter is an problem):

 fn.2 <- function(p){
   for (i1 in ilong){
 ex[i1] <- exp(p[1]*n*L*voigt(u,v,f[i1],p[2],p[3],GLN)[[1]])
 }
sum((t-ex)^2)
}
out <-nlm(fn.2, p = c(S,foN,GGN), hessian = TRUE,
  steptol = 1e-5, iterlim = 1000,print.level=2)
SN <-  out$estimate[1]
The problem is now that the first value from nlm() is positive (1E-6 !?)
and this leeds to an Inf:
 iteration = 0
Step:
[1] 0 0 0
Parameter:
[1] -3.80e-19  2.196660e+03  5.211179e-03
Function Value
[1] 0.5890603
Gradient:
[1]   Inf  11.23381 -23.61961 -
Error in nlm(fn.2, p = c(S, foN, GGN), hessian = TRUE, steptol = 1e-5,  :
   non-finite value supplied by nlm
In addition: Warning message:
NA/Inf replaced by maximum positive value
The number of parameters plays no role; same behaviour with p = c(S,GGN)

Can someone give a broad hint
Thomas
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] (on) first value from nlm (non-finit value supplied by nlm)

2003-10-27 Thread Thomas Bock
Dear R-helpers,

if someone is interested in (last night I dreamed):
 ...
SH <- -3.8
fn.2 <- function(p){
   for (i1 in ilong){
 ex[i1] <- (1E-19*p[1]*n*L*voigt(u,v,f[i1],foN,p[2],p[3])[[1]])
   }
sum((log(tt)-ex)^2)
}
out.2 <-nlm(fn.2, p = c(SH,GG,GL), hessian = TRUE,
  steptol = 1e-6, iterlim = 1000,print.level=2)
SN <-  out.2$estimate[1]*(1E-19)
GGN <- out.2$estimate[2]
GLN <-  out.2$estimate[3]
...
which works:
 ...
iteration = 10
Parameter:
[1] -3.83499  0.005181922  0.006242639
Function Value
[1] 1.068854
Gradient:
[1] -0.01561930  0.02665086 -0.01232618
Successive iterates within tolerance.
Current iterate is probably solution.
...
Another thing: 
Since I receive the R-help digest
I have this in my ~/.emacs:
(custom-set-faces
'(font-lock-string-face ((t (:foreground "green3"
'(font-lock-keyword-face ((t (:foreground "#f939ff"
)
(defun highlight-R-help ()
 (interactive)
 (highlight-regexp "Message:" 'font-lock-keyword-face)
 (highlight-regexp "Date:" 'font-lock-string-face)
 (highlight-regexp "Subject:" 'font-lock-string-face)
 (highlight-regexp "From:" 'font-lock-string-face))

(defun unhighlight-R-help ()
 (interactive)
 (unhighlight-regexp  "Message:" )
 (unhighlight-regexp  "Date:" )
 (unhighlight-regexp  "Subject:")
 (unhighlight-regexp  "From:"))
;;;
regards
Thomas
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] filter() function

2003-11-19 Thread Thomas Bock
Dear expeRts,

I have lots of time series vectors and I simply want to remove certain 
frequencies.
My problem is now that I can not find out how to calculate
automatic the filter coeff. for the filter() function which should 
remove this certain frequencies.
Is there an elegant way to do this?

Thanks
Thomas
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help