I’m writing a brief Quarto document where I explain some SQL clauses/keywords. I’d like to have all of those clauses to be highlighted in my code chunks, but not all of them are supported by default syntax highlighting. Is there a way to add custom keywords to syntax highlighting settings? For example, I wrote the following code chunks: And i
Tag: r
Replace multiple variables in R Sql Query
I have a query similar like the one below where I need to use multiple string of characters to replace in a single query. I am not too sure how to make sure a and b are passed into the %s in the query. I am getting the error ‘unused arguments (b)’ Any advice please? Thanks Answer sQuote only takes
select the last 30 days of POSIXct dates in R
Probably simple, but this is my first time working with POSIXct date format. I have a table of orders (that i got from a syl database) and I would like to select all rows of the last 30 days. so today’s date minus 30 days. my date is of the type POSIXct. Now, I know how to do this selection
Find total IDs between two dates that satisfies a condition
I have a dataset PosNeg like this. I need to find count of ID’s who have a pattern like this- P N P P or N P N N P N – that is having at least one N (negative) between two P’s(positive). If this pattern occurs at least once, then count that ID. Date is always in ascending order.
Translate SQL statement in R code using dplyr
I need help transalting an SQL statement regarding this dataset https://www.kaggle.com/datasets/hugomathien/soccer , into r code using dplyr. The SQL statement is : The r code that i have tried is: and i get this error : Error in dplyr::common_by(): ! by required, because the data sources have no common variables. Run rlang::last_error() to see where the error occurred. Run rlang::last_error()
How to add a vector to a table in backend using dbplyr (R)
I created a table from a data source using tbl(). I need to add a column including 1:nrow() to my dataset and tried different methods but I didn’t succeed. My code is as below: It doesn’t add column ID to my dataset and only adds column step. Using as.data.frame(), it works but so slow. Do you have any ideas? thanks
Syntax error in SQL code being used in R, no row_number function found
I am using RSQLite, DBI, and dbplyr packages. I’m watching this YouTube video by TechTFQ. I’m getting a syntax error with this line. Error: near “row_number”: syntax error I’m certain that the SQL syntax I’m writing here is the same as what I’m watching in the YouTube video, except for the differences in the dataframe that I’m using and the
R using RSQLite, DBI and dbplyr, can’t have more than one table in the RSQLite in order to make a join
I’m having a hard time understanding the behavior of these three packages: RSQLite, DBI, and dbplyr. I’m using the mtcars dataframe and I’m loading it with the tibble package to add the car name as one of the rows. I also created my own table that has information about where all these cars were built: By creating these two tables
How to convert large .csv file with “too many columns” into SQL database
I was given a large .csv file (around 6.5 Gb) with 25k rows and 20k columns. Let’s call first column ID1 and then each additional column is a value for each of these ID1s in different conditions. Let’s call these ID2s. This is the first time I work with such large files. I wanted to process the .csv file in
Converting XML to a dataframe R and extracting value from within
I have the following XML which I am trying to convert into a data frame in R or a table within SQL: I’ve tried using XMLtoDataFrame (“xml” library) but this just creates a table without any values. Would anyone be able to help with this please? Open to a SQL solution. Edit: I’m looking for my table to be in