Skip to content

simple problems

5 messages · marciarr, Domenico Vistocco, Gabor Grothendieck +1 more

#
Hello R users,
I have been looking through Help files and Nabble list for the answers for
these simple questions, but it seems to be fruitless.
1- in a data frame with two columns, x and y, how do I get the corresponding
value of x to, let's say, the minimum value of the y column (min (data$y)) ?
2- how do I solve a simple equation? Considering the equation y= exp(-x)^12,
I would like to find the values of x for,  for example, y=0.01, so
exp(-x)^12=0.01. How do I do that using R?
I know those a probably very, very simple questions, but for which I do not
seem to find the answer.
Thank you very much,
Marcia
#
marciarr wrote:
data$x2[data$x1==min(data$x1)]
I know there is solve for linear equations, but I do not know if there is
a generic solver for other equations.
You could implement it using a numerical approach (perhaps it is yet in some
package).

domenico
#
On Dec 6, 2007 3:26 PM, marciarr <marcia.rocha at gmail.com> wrote:
In the builtin Formaldehyde data frame find the value of carb (first column)
which corresponds to the least value of optden (second column):

with(Formaldehyde, carb[which.min(optden)])
Search between 0 and 1 for the root of the indicated function:

uniroot(function(x) 0.1 - exp(-x)^12, 0:1)
#
Gabor Grothendieck a ?crit :
[ Snip.... ]
I beg your pardon ?

I'd rather use high-school algebra/analysis :
log(exp(-x)^12)=log(0.01)
12log(exp(-x)=log(0.01)
-12x=log(0.01)
x=-log(0.01)/12=log(100)/12

Rushing for a sophisticated numerical tool without thinking for an
explicit solution is easy, fast, lazy (I do that every day ...), but
deprives you of the process of understanding the problem.

Which was probably the point of this (probable) homework...

					Emmanuel Charpentier
#
On Dec 6, 2007 6:13 PM, Emmanuel Charpentier <charpent at bacbuc.dyndns.org> wrote:
The posting instructions ask for minimal code and its likely that the
poster did not literally mean that that was the eventual problem.