Skip to main content

All Questions

Tagged with
2 votes
1 answer
54 views

how to view modified environment in R

In this R question, lexical scoping is used to implement a stateful function. The setter and getter methods for a point "class" work as expected to change the coordinates of the point, a &...
Hasse1987's user avatar
  • 333
2 votes
1 answer
61 views

Are there any risks to accessing internal functions with :: or :::?

I've been developing a package in R which has a number of functions (some exported, some not) which are used by other functions in the package. Since the package loads and attaches itself, is there ...
divibisan's user avatar
  • 12.1k
1 vote
1 answer
25 views

Scope of identifiers in R formulas/expressions

I'm using as.ggplot from ggplotify to wrap some chord diagrams from the circlize package so I can arrange them nicely using patchwork. However, since as.ggplot takes a formula or expression as an ...
Luther Blissett's user avatar
1 vote
2 answers
83 views

How to keep function call attributes consistent in lapply and Map?

I want to attach the function call as an attribute. While using fn() directly works fine, when I run it inside lapply(), it returns X[[i]] instead of the actual name passed to the d= parameter. I ...
jay.sf's user avatar
  • 71.1k
0 votes
1 answer
124 views

R Variable scoping issue of parallel calculation (%dofuture%) in a nested function

I have a variable scoping issue when I try to do the parallel calculation using %dofuture% in a nested function. Here is the error message I get: Error in eval(quote({ : object 'opt' not found Here ...
HsunHung Chu's user avatar
1 vote
2 answers
69 views

Avoid lazyness in ggplot aes(color=variable)

In a for-loop I continue to add geom_... to a plot. I'd like each geom-object to have a separate color and a corresponding entry in the legend. library(ggplot2) means <- 1:5 sds <- 1:5 plt <...
derM - not here for BOT dreams's user avatar
0 votes
0 answers
72 views

Scope variables and functions in R

I have the following data: trials <- data.frame( full_condition = rep(c("condition1", "condition2", "condition3"), times = 3), participant_md5 = rep(c("...
Ahmad B's user avatar
  • 117
3 votes
0 answers
93 views

Setter not found when used inside an R package

First time asking here -I will try to do my best-. I am writing an analysis package using R for which unfortunately I cannot disclose much. The core object that the package is using to get data and ...
Shepard's user avatar
  • 31
2 votes
1 answer
148 views

Is there a python equivalent to R's `with`?

In R, the with function constructs an environment from some data - this allows you to refer to items in your data as if they are variables, so this: with(list("a" = 12, "b" = 13), {...
henryn's user avatar
  • 1,227
0 votes
0 answers
39 views

forecast subset function is not accessible via :: notation

Consider this MWE and it outputs: forecast::subset(forecast::woolyrnq, start = 0 , end = 10) # Error: 'subset' is not an exported object from 'namespace:forecast' forecast:::subset(forecast::woolyrnq,...
Someone2's user avatar
  • 495
2 votes
2 answers
34 views

R: Back-referencing data frame in `with` expression

Is there a way to back-reference the scope in a with expression in R? I'm trying to write the following (valid) statement in a more elegant (i.e. non-repetitive) way: with(subset(mtcars, cyl > 4), {...
NicolasBourbaki's user avatar
2 votes
1 answer
82 views

predict.lme is unable to interpret a formula defined from a variable

I have been stymied by an error that traces back to predict.lme, running inside a function, failing to interpret a formula based on a variable that has been passed from outside the function. I know ...
Jeff Phillips's user avatar
2 votes
1 answer
234 views

Programming on the data.table with "env" in a function

I am interested in joining two data.tables in a function. However, when using the new env for programming on the data.table, I am unable to join the data.tables in a function because the argument I ...
Michael Lachanski's user avatar
1 vote
1 answer
109 views

How to refer to the .GlobalEnv of the session using callr::r

My understanding of callr::r is that the function I am providing is evaluated in a new session of R. If (for whatever reason) I want to keep the .GlobalEnv of this session, I thought I could do it ...
thothal's user avatar
  • 19.4k
0 votes
0 answers
136 views

Defined variable in shiny app is not defined

I am trying to use the variable Z in my shiny app, but it says the variable doesn't exist. I clearly defined it a few lines above the lme call. Does anyone know why the value of Z is not preserved? # #...
Vons's user avatar
  • 3,325

15 30 50 per page
1
2 3 4 5
18