I'm trying to obtain the following exact output.
Below is first what I initially tried and then what I saw while attempting to find a solution.
if(i<- 10) {choose(i, 0:10)}
[1] 1 10 45 120 210 252 210 120 45 10 1
pascalTriangle <- function(h) {
lapply(0:h, function(i) choose(i, 0:i))
}
> pascalTriangle(10)
[[1]]
[1] 1
[[2]]
[1] 1 1
[[3]]
[1] 1 2 1
... etc.
The second code gets the right numbers, but the formatting is way off and I'm stumped on how I could go about tweaking the code to obtain my desired output. If I'm missing any information you need please let me know