Questions tagged [r-glue]
76 questions
0
votes
0 answers
Can we use glue function inside a knitr kable function?
I have multiple table sets (table set 1, table set 2,...) so I want to create a function that would:
knit my table (in R markdown)
and automatically change the table caption depending on the table set I'm using
Below is the function I create,…

NganKD
- 71
- 6
0
votes
1 answer
How to combine outputs of different functions into a nicely report?
I have like:
. multiple plots, each created by a distinct function.
#Plot 1
sis_name <- babynames %>%
filter(name == "Kate", sex == "F") %>%
select("year", "name", "prop")
plot1 <- ggplot(data = sis_name) +
geom_line(mapping =…

Thuy Nguyen
- 7
- 3
0
votes
1 answer
Assign a set of vectors based on on a character vector (automating code)
I want to do a series of assignments
rename2014 <- eas_dictionary$name2014
rename2015 <- eas_dictionary$name2015
rename2017 <- eas_dictionary$name2017
names(rename2014) <- eas_dictionary$true_name
names(rename2015) <-…

daaronr
- 507
- 1
- 4
- 12
0
votes
1 answer
`stringr::str_glue`: how to escape backslash (\)?
I'd like str_glue to keep \ when I glue, but I don't understand how to escape it.
I have this reprex with the logical attempts I've made: (escaping the escape, etc)
library(stringr)
var <- "darkness"
str_glue("Hello {var} my old friend \
I've come…

csgroen
- 2,511
- 11
- 28
0
votes
1 answer
Using character object to indicate column name within R's glue function?
I am trying to create a "label" column in my dataset using the glue::glue function. I want each row of this label column to include the value of a user-selected column. For example, using the mtcars dataset, I'd like to create a label column that…

Jake Scott
- 3
- 1
0
votes
0 answers
Using glue to create a dynamic IP address for multiple sites, within a function R
I am trying to avoid a whole lot of repeating myself (copy/pasting) by using functions in my R code.
I have a working function as per below, but I can't figure out how to build the IP/file path address inside the function for different sites.
My…

prezzo
- 1
- 1
0
votes
1 answer
Zero-padding with glue
I want to use glue to accomplish sprintf('%02d', x) but I'm not sure it's possible.
vignette('transformers') suggests a sprintf-alike transformer sprintf_transformer and "front end" wrapper glue_fmt like this:
sprintf_transformer <- function(text,…

MichaelChirico
- 33,841
- 14
- 113
- 198
0
votes
1 answer
How to create a list of html text entries from data.frame columns in r (without loops)?
Imagine I have this df
df<-data.frame("A"=c("I","You","She"),"B"=c("kicked","like","saw"),"C"=c("can","dogs","birds"))
and some kind of text block base I want to use for HTML like this (df column names are in the brackets):
"Hello World
{A}…
{A}…

bart cubrich
- 1,184
- 1
- 14
- 41
0
votes
0 answers
Creating a for loop to implement ggplot2 with a series of variables. Consider everything as a missing value
I'm trying to develop a loop to plot every column from a dataset called chr, with the code I'm using, a for loop, conditioned by some criteria, to save plots in a list
desired_length <- 8
plot_list <- vector(mode = "list", length =…

fernando schuh
- 71
- 5
0
votes
0 answers
Update JSONB in Postgres using R
as the title states I am trying to update a jsonb field from inside R. I have several changes to apply. The original dataset is created by a third party application but needs to be corrected for several rows.
The following statement is working fine…

Johannes42
- 29
- 4
0
votes
1 answer
Get list element name from index
I'm trying to use the following glue code to create an informative error message
library(rlang)
library(glue)
my_function <- function(x) {
UseMethod("my_function", x)
}
my_function.default <- function(x) {
abort(glue(
"Can't calculate…

MayaGans
- 1,815
- 9
- 30
0
votes
0 answers
Is there any way to install "glue" in Mac OS Catalina?
I am trying to install the glue lib in my MacOS Catalina - which does not support 32-bit apps.
1 error generated.
make: *** [glue.o] Error 1
ERROR: compilation failed for package ‘glue’
* removing…
0
votes
1 answer
Better way to deal with namespace when using glue::glue
I want to create a function that itself uses the awesome glue::glue function.
However, I came to find myself dealing with some namespace issue when I want to glue a variable that exists in both function and global environments:
x=1
my_glue <-…

Dan Chaltiel
- 7,811
- 5
- 47
- 92
0
votes
1 answer
Scraping with Rvest and Glue packages in R specifically
I'm trying to scrape multiple pages of sports data using rvest and glue packages. I'm having trouble with the nesting and I think it's because the table from the website has a two line header (some headers are one line some are two). Here's the code…

Jeff Henderson
- 643
- 6
- 10
0
votes
0 answers
A package that needs compilation cannot be installed with a different name
I have a github clone of the glue R package for reasons. The name of this package is changed into glue.1.3.1 in this repository from its DESCRIPTION file for similar reasons. As a control group, I have an identical repository but this one's name is…

OganM
- 2,543
- 16
- 33