What does %>% function mean in R?

%…% operators %>% has no builtin meaning but the user (or a package) is free to define operators of the form %whatever% in any way they like. For example, this function will return a string consisting of its left argument followed by a comma and space and then it’s right argument. “%,%” <- function(x, y) … Read more

Fixing a multiple warning “unknown column”

This is an issue with the Diagnostics tool in RStudio (the tool that shows warnings and possible mistakes in your code). It was partially fixed at this commit in RStudio v1.1.103 or later by @kevin-ushey. That fix was partial, because the warnings still appeared (albeit with less frequency). This issue was reported with a reproducible … Read more

Extract a dplyr tbl column as a vector

With dplyr >= 0.7.0, you can use pull() to get a vector from a tbl. library(dplyr, warn.conflicts = FALSE) db <- src_sqlite(tempfile(), create = TRUE) iris2 <- copy_to(db, iris) vec <- pull(iris2, Species) head(vec) #> [1] “setosa” “setosa” “setosa” “setosa” “setosa” “setosa”

Display / print all rows of a tibble (tbl_df)

You could also use print(tbl_df(df), n=40) or with the help of the pipe operator df %>% tbl_df %>% print(n=40) To print all rows specify tbl_df %>% print(n = Inf) edit 31.07.2021: in > dplyr 1.0.0 Warning message: `tbl_df()` was deprecated in dplyr 1.0.0. Please use `tibble::as_tibble()` instead. df %>% as_tibble() %>% print(n=40)

Use dynamic name for new column/variable in `dplyr`

Since you are dynamically building a variable name as a character value, it makes more sense to do assignment using standard data.frame indexing which allows for character values for column names. For example: multipetal <- function(df, n) { varname <- paste(“petal”, n , sep=”.”) df[[varname]] <- with(df, Petal.Width * n) df } The mutate function … Read more

data.table vs dplyr: can one do something well the other can’t or does poorly?

We need to cover at least these aspects to provide a comprehensive answer/comparison (in no particular order of importance): Speed, Memory usage, Syntax and Features. My intent is to cover each one of these as clearly as possible from data.table perspective. Note: unless explicitly mentioned otherwise, by referring to dplyr, we refer to dplyr’s data.frame … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)