Issue title: Multilevel dictinory in YAML metadata not allowed
 Issue body: As discussed [here](https://stackoverflow.com/q/47284942), the following works with `bookdown`/`rmarkdown`/`knitr` through `RStudio`:

    ---
    params:
      first_level: ~
    ---
    
    ```{r}
    params
    ```

and produces

    ## $first_level
    ## NULL

This, however:

    ---
    params:
      first_level:
        second_level: ~
    ---
    
    ```{r}
    params
    ```

Is expected to give:

    ## $first_level
    ## $first_level$second_level
    ## NULL

but results in `Error: no value field specified for YAML parameter 'first_level'
Execution halted`.

@yihui informs me (at above link) that plain `rmarkdown38d1:d2b4:3d06:83e8:96a5:8c2:893d:aba5render`ing actually produces the expected, so there's likely an `RStudio` bug involved. 
 Comments: 
 Comment 0: I think this bug is actually in `rmarkdown`. That's where the error is coming from, and `rmarkdown38d1:d2b4:3d06:83e8:96a5:8c2:893d:aba5render` shows the error `Error: no value field specified for YAML parameter 'first_level' Execution halted` for me, even when run at the command line outside RStudio.

@yihui can you confirm that plain `rmarkdown38d1:d2b4:3d06:83e8:96a5:8c2:893d:aba5render` works for you? If so, what versions of knitr/rmarkdown are you using?
 Comment 1: Sorry, I don't know what happened when I tried this example a few days ago, but I tried it again today, and it seems to be an issue in **rmarkdown** indeed. I'll try to fix it there.
 Comment 2: After I thought about it more carefully, I'd say this is by design, and will not be changed: https://stackoverflow.com/a/47373541/559676

I think this issue can be closed.
 Comment 3: Okay, great. Thanks, @yihui.
{'source': 'GithubIssues', 'repo_name_with_owner': 'rstudio/rstudio', 'issue_id': 273914687, 'repo_stars': 4574.0}