search for: set_colnames

Displaying 3 results from an estimated 3 matches for "set_colnames".

2020 Oct 08
0
Lahman Baseball Data Using R DBI Package
...atting$3" How to handle? You can rename columns on-the-fly by piping. See reference [1] and use either library(magrittr) or library(dplyr) or a combination thereof: library(magrittr) dbGetQuery(con2,"SELECT * FROM batting WHERE yearID = 2018 AND AB >600 ORDER BY AB DESC") %>% set_colnames(make.names(colnames(.))) #OR one of the following: library(dplyr) dbGetQuery(con2,"SELECT * FROM batting WHERE yearID = 2018 AND AB >600 ORDER BY AB DESC") %>% rename(X2B = `2B`, X3B = `3B`) library(dplyr) dbGetQuery(con2,"SELECT * FROM batting WHERE yearID = 2018 AND AB &gt...
2020 Oct 08
1
Lahman Baseball Data Using R DBI Package
...? You can rename columns on-the-fly by piping. See > reference [1] and use either library(magrittr) or library(dplyr) or a > combination thereof: > > library(magrittr) > dbGetQuery(con2,"SELECT * FROM batting WHERE yearID = 2018 AND AB >600 > ORDER BY AB DESC") %>% set_colnames(make.names(colnames(.))) > > #OR one of the following: > > library(dplyr) > dbGetQuery(con2,"SELECT * FROM batting WHERE yearID = 2018 AND AB >600 > ORDER BY AB DESC") %>% rename(X2B = `2B`, X3B = `3B`) > > library(dplyr) > dbGetQuery(con2,"SELECT * F...
2020 Oct 03
1
Lahman Baseball Data Using R DBI Package
The double quotes are required by SQL if a name is not of the form letter-followed-by-any-number-of-letters-or-numbers or if the name is a SQL keyword like 'where' or 'select'. If you are doing this from a function, you may as well quote all the names. -Bill On Fri, Oct 2, 2020 at 6:18 PM Philip <herd_dog at cox.net> wrote: > The \?2B\? worked. Have no idea why. Can