[R] Solving an equation in R (and using a loop)
jorismeys at gmail.com
Fri Oct 16 00:34:54 CEST 2009
I tried :
> test <- 0:10000
> test2 <- f(0:10000)
> test <- seq(0,1,by=0.00001)
> test2 <- sapply(test,f)
with the values you gave.
And according to this result, you did nothing wrong. Zero is the only
root of the function, as it is a monotone asymptotic to 0 for x>0, and
not defined for negative x. Are you sure you're looking for the root
of that function?
On Thu, Oct 15, 2009 at 11:18 PM, leohearn <leohearn at dal.ca> wrote:
> So, I have a dataset and I'm trying to solve for a parameter in an equation
> using the dataset. Before applying more sophisticated statistical
> techniques, I want to tell R to solve it out for each observation. I know I
> have to use a loop for it (and I have done that before, but am a bit rusty),
> but before I do that, I'm trying to get R to solve it for just one
> observation, to make sure that I have that part right before applying to the
> rest. However, when I do it, I get 0 for an answer, which is a valid answer,
> but a trivial one. What am I doing wrong? (tips for the loop would also be
> appreciated, but this is my main concern right now.)
> Here's my code:
> r is the unknown. I've plugged in a couple numbers from my data for b, x1,
> and x2 such as:
> and gotten 0 both times.
> Thanks in advance for your help.
> View this message in context: http://www.nabble.com/Solving-an-equation-in-R-%28and-using-a-loop%29-tp25916187p25916187.html
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> 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