How can I create a column with time HH:MM from a timestamp column with time HH:MM:SS in my dataset
Tag: r
sql to r – select cases
I have included a lot of sql code in R using the sqldf library. Since this is becoming increasingly hard to digest, I would like to do it using, for example dplyr in native R. How would I do it for …
How can I translate this SQL code to R script using dplyr?
I’m currently working on a project and I want to summarize a column from a joined table twice. SQL code is this: …and the result is this: Database tables are as shown here: I hope that I have provided all the information needed. Question: How can I have the same result in R by only using dplyr library? Table names
Is there any way to avoid double quotes around an URL in R?
I am trying to pull data using an API call with GET from httr. The API call has SQL statements that require double quotes around table and field IDs, and single quotes around string values. This means I get some issues when I use the URL in R, because it needs quotes around it there as well. The API call
Connect to a DB using DBplyr
Problem I am trying to connect to a SQL Server which is on premises using dbplyr using the instructions here but I keep getting an error saying Invalid object name For simplicity I am using the same object naming convention as RStudio has in the instructions at the link above. Code that produces the error I use dbConnect to establish
create user defined WHERE SQL phrase in r
I am using RODBC to connect to a database. I would love for a user to be able to define wildcard strings to lookup in the SQL as part of a function. I cannot use CONTAINS as the database is not full-text indexed. The SQL I want to create is The user should be able to define as many wildcards
Encoding special characters SQL to R and back
I have a problem passing data from R to SQL and then reading it back The original data is from some excel files and have the following word: Průmyslový Using latin1 for encoding depreciates the u within the word Prumyslový Using latin2 for encoding changes the accent of the u Prùmyslový Which encoding could i use? I am using an
Find first occurance within a group of groups
I have a table with 5 columns. I want to find the % received of the last date and first occurance of date_rec. Output required: Answer In R, we can do slice after grouping by ‘Country’, ‘Flow’ The above assumes that the ‘Date’ are ordered (in the OP’s example it is already ordered). If not, then convert to Date class
Writing a Single Query w/ Multiple CTE Subqueries SQL/R
I have some data I would like to pull from a database, I’m using RStudio for my query. What I intend to do is write: The first CTE statement to pull all my necessary information. The second CTE statement will add two new columns for two row numbers, which are partitioned by different groups. Two additional columns will be added
Error :Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library
I’m trying to fetch data from MS SQL server in a shiny app. I’m using the odbc package version 1.2.2. When I run the app locally I am able to fetch the data and everything is fine. But on the server I have the following error : The following is a short version of my app. and the server :