```
# calculates the length of leg a and b of a right triangle when c and alpha
# is given
calculateTriangle <- function(alpha, c) {
alphaRad <- alpha * pi/180
a <- sin(alphaRad) * c
b <- cos(alphaRad) * c
result <- data.frame(x = round(a, 2), y = round(b, 2))
return(result)
}
# example of function usage
calculateTriangle(45, 60)
```

```
## x y
## 1 42.43 42.43
```

Good, but

function(c, alpha) (cbind({c*sin(alpha*pi/180)}, {c*cos(alpha*pi/180)}))

is really hard to read!! Please tidy your code. Have a look at Google’s R style guide.

Thanks for your feedback, Tim. This function might be the better solution, anyway. Are you happy with the style of the function, now?

Yes, much better! Well done!