0

I have a SQL query that when executed directly in R returns the correct result. A dataframe without German quotation marks. But when I run it in RMarkdown (to create a dashboard with Flex Dashboard) the quotes are in the requested dataframe. I think the problem is in the language settings, but I just can't get any further. The line

REPLACE(REPLACE(news.headline,'„',''),'“','') as headline 

ensures that the German quotation marks do not appear in the query.

---
title: "News Performance"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll

---

{r setup, include=FALSE}

library(flexdashboard)
library(RMySQL)

con = dbConnect(drv = MySQL(),
                user = DB_user,
                password =DB_pass,
                host = "DB_Host",
                port = Port_number,
                dbname = "DB_Name")

SQL_Statement = paste0("SELECT news.news_Id, 
                               REPLACE(REPLACE(news.headline,'„',''),'“','') as headline
                        FROM news
                        GROUP BY news.headline
                       ")

# get query
news_aktuell = dbGetQuery(con, SQL_Statement)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
nasbar
  • 40
  • 7
  • does your query execute normally? I'd expect it could fail, as the column news_Id is not contained in the group by or an aggregate function - didnt see initial comment, can ignore if it works – Chris Littler Feb 06 '19 at 15:26
  • Yeah, the query execute normally. Currently i am using a workaround and "gsub" the quotes. But I still couldn't figure out yet why the SQL statement produces the right result when I just execute it, but not when I Run the Markdown script. – nasbar Feb 07 '19 at 13:13

0 Answers0