Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

load .yml file in R

Tags:

r

I am trying to use config.yml in R. But whenever I load the file using

my config file looks like this

default: 
   dataconnection: 
     driver: 'ODBC Driver 11 for SQL Server' 
     server: 'server' 
     uid: 'Username' 
     pwd: 'password' 
     port: 1433 
     database: 'Data_Science' 

rsconnect: 
  dataconnection: 
    driver: 'FreeTDS' 
    server: 'server' 
    uid: 'username' 
    pwd: 'password' 
    port: 1433 
    database: 'Data_Science'

Code:

config <- config::get(file = "C:/Users/Samuel.Golomeke/Documents/Data Science/Codes/R codes/SQL_Server_shiny_connect/config")

I keep getting the following warning message:

Warning message: In readLines(con) : incomplete final line found on 'C:\Users\Samuel.Golomeke\Documents\Data Science\Codes\R codes\SQL_Server_shiny_connect\config.yaml'"

why is that?

like image 299
sammgolo Avatar asked Mar 21 '18 14:03

sammgolo


People also ask

Where do I put a YML file?

One of the most common uses for YAML is to create configuration files. It's recommended that configuration files be written in YAML rather than JSON, even though they can be used interchangeably in most cases, because YAML has better readability and is more user-friendly.

What is YAML in RStudio?

YAML (“Yet Another Markup Language” or “YAML Ain't Markup Language,” depending on who you ask) is the metadata that tells R Markdown, pandoc, and other software exactly how to process or display the document.

How do I create a YML file in R?

The yml file is simply a text file (use File > New file > Text File in RStudio). Save it as _site. yml or it won't work. You can also create a regular RScript or Rmarkdown file and then choose the pop up menu in the bottom right of the writing pane to change it to YAML.


1 Answers

Make sure the last line in the config.yaml file has a blank line with no whitespace (space, tab, etc).

like image 145
Jay Avatar answered Sep 29 '22 10:09

Jay