setting figure size in Rmd file

I was playing around with Rmd code chunk settings. I wanted to have a code chunk inside my Rmd file that set a figure size for a portion of my codes (that is why I don't put it in YAML header). I do not knit the file, just looking at the inline image previews

```{r }
# set image dimensions

and then to apply it I want smth like this

but this does not produce desired outcome, while specifying numbers directly inside the code works:

```{r fig.height=17, fig.width=12, units=units}

I wonder why it is not recognized, when the value is supplied from the variable, iItried: {r fig.height=r fig.hight} but that also did not work.