I have a probably really basic question concerning the possibility to solve functions in R, but to know the answer would really help to understand R better.

I have following equation:

0=-100/(1+r)+(100-50)/(1+r)^2+(100-50)/(1+r)^3+...(100-50)/(1+r)^10

How can I solve this equation in R finding the variable r?

I tried sth. like this:

```
n <- c(2:10)
0 = -100/(r+1)+sum((100-50)/((1+r)^n))

```

But got an error message:

```
Error in 0 = -100/(r + 1) + sum((100 - 50)/((1 + r)^n)) : 
invalid (do_set) left-hand side to assignment

```

What's the problem and how can I find r?