[R] Need Help!

Boris Steipe boris.steipe at utoronto.ca
Wed Apr 29 21:59:59 CEST 2015


A: Look at the function seq() e.g. seq(0.01, 1, by=0.005)

B: Don't post in HTML. Seriously. Do not.

C: You need to invest more time getting the basics down. Google for R introduction.

D: Ow. pi is a predefined constant. Your re-defintion loses accuracy. (See C:)

Please see here for some hints on how to ask questions productively:
http://adv-r.had.co.nz/Reproducibility.html
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example


B.




On Apr 29, 2015, at 10:47 AM, dawood ahmad <dawoodmalik at hotmail.com> wrote:

> Dear Sir/Madam,
> 
> I hope you will be fine. Recently, I have started to use R language. I am new in programming. 
> I have to fit my data with mathematical equation which I am pasting below. The problem is that one of the
> parameter named "ep" which is x-axis required a loop so that I could a range of data. Please see below the code,
> 
> 
> pi<-3.14159; c<-0.5; xc<-2; s<-6; Hc2<-30; H<-1; ep<-0.01; 
> f<-function(k) 1.211*10^(-6)*Hc2/H*(trigamma( ((ep + H/Hc2 + (2*xc/s)^2*(1 - cos(k*s))/2)/2*Hc2/H)) -  trigamma(((c + H/Hc2 + (2*xc/s)^2*(1 - cos(k*s))/2)/2*Hc2/H))); 
> integrate(f,-pi/s,pi/s)$value
> I have typed in bold the x-axis. If I execute this model, it works well. But, I want to make a loop for this parameter inorder to enter a range of values.For instance, from 0.01 to 1 with specific interval (increment interval 0.005). I will be really grateful if you help me in this matter.  With best Regards, Dawood 		 	   		  
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list