similar to: Substitute and quotes

Displaying 20 results from an estimated 20000 matches similar to: "Substitute and quotes"

2008 May 02
2
Extract lags from a formula
Hi folks! How do I extract lags from a formula? An example: mod.eq<-formula(x~lag(x,-1)+lag(x,-2)) > mod.eq x ~ lag(x, -1) + lag(x, -2) > mod.eq[1] "~"() > mod.eq[2] x() > mod.eq[3] lag(x, -1) + lag(x, -2)() I'm trying to extract the lags into a vector that would be simply [1,2]. How do I do this? I'm using the dyn package to do dynamic
2006 May 15
3
Dyn or Dynlm and out of sample forecasts
All: How do I obtain one step ahead out-of-sample forecasts from a model using "dyn" or "dynlm" ? Thanks! Best, John [[alternative HTML version deleted]]
2006 Jun 21
5
colClasses
Hi Folks! I'm reading in some data from a .csv file that has a date column. How do I use colClasses to get read.csv to recognize the date column? The documentation on this seems to be nil - And yes, I've read help and R Data Import/Export and can't figure out what the colClasses syntax is. Thanks, john [[alternative HTML version deleted]]
2018 Aug 12
3
substitute() on arguments in ellipsis ("dot dot dot")?
Hi. For any number of *known* arguments, we can do: one <- function(a) list(a = substitute(a)) two <- function(a, b) list(a = substitute(a), b = substitute(b)) and so on. But how do I achieve the same when I have: dots <- function(...) list(???) I want to implement this such that I can do: > exprs <- dots(1+2) > str(exprs) List of 1 $ : language 1 + 2 as well as: >
2018 Aug 13
2
substitute() on arguments in ellipsis ("dot dot dot")?
Interestingly, as.list(substitute(...())) also works. On Sun, Aug 12, 2018 at 1:16 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > On 12/08/2018 4:00 PM, Henrik Bengtsson wrote: >> >> Hi. For any number of *known* arguments, we can do: >> >> one <- function(a) list(a = substitute(a)) >> two <- function(a, b) list(a = substitute(a), b =
2013 May 16
3
Substitute / delayedAssign (was: Substitute unaware when promise objects are evaluated)
Duncan, Thank you for the clarification on how delayedAssign works. Should R-level interfaces to promise objects ever become available, I expect they would at time come in handy. On the subject of substitute and delayedAssign, I do have a follow-up question for the list. I'm trying to convert a named list of expression objects into an environment of promise objects. After conversion, each
2013 May 15
1
Substitute unaware when promise objects are evaluated
R-devel, I used the 'substitute' function to create labels for objects inside an environment, without actually evaluating the objects, as the objects might be promises. However, I was surprised to see that 'substitute' returns the expression slot of the original promise even after the promise has been forcibly evaluated. (Doesn't the promise go away after evaluation?) This
2007 Mar 23
1
substitute and S4 objects
Hi all, I don't understand why this does not what I expect : ## code start here ############## setClass("num",representation(x="numeric")) num<-function(x) new("num",x=x) add<-function(e1,e2) { cat("Computing ",deparse(substitute(e1)),"+",deparse(substitute(e2)),"\n") e1@x+e2@x }
2006 Jun 23
3
Problems with weekday extraction from zoo objects
Hi Folks! I'm struggling with dates - but enough about my personal life..... I have two daily time series files. In one (x) the date format is Y/m/d and the other (y) is d/m/y. I used read.zoo on both and they read into R with no problem. Then I use: weekdays(as.Date(x$DATE)) and get what I expect - all the days of the week in my data set. When I use:
2009 Apr 07
3
write text file as output without quotes
Hi R, When I use the below to write the text file try=data.frame(rep("a",5), rep("b",5)) write.table(try,"z:\\try.txt",row.names=F,col.names=F,sep="\t") the output contains two columns with quotes! Is there a way to write without quotes? I tried try[,1]=noquote(try[,1]) try[,2]=noquote(try[,2]) Thank you, Regards, Ravi Shankar
2007 Dec 21
1
substitute() bug? (PR#10525)
The first four lines of code below work as normal. The fifth thorows an error: "Error in paste(theta[1], "=", 5) : object "theta" not found" x=rnorm(1000); bob=density(x); topp=5; plot(bob,xlab="", ylab="", main=substitute(paste(theta[1],"=",topp),list(topp=topp)), type="l"); plot(bob$y~bob$x,xlab="",
2018 Aug 13
1
substitute() on arguments in ellipsis ("dot dot dot")?
Since you're already using bang-bang ;) library(rlang) dots1 <- function(...) as.list(substitute(list(...)))[-1L] dots2 <- function(...) as.list(substitute(...())) dots3 <- function(...) match.call(expand.dots = FALSE)[["..."]] dots4 <- function(...) exprs(...) bench::mark( dots1(1+2, "a", rnorm(3), stop("bang!")), dots2(1+2, "a",
2005 Oct 13
1
Getting ... as an unevaluated list
Hi, I'm trying to get ...as a list of unevaluated arguments, ie. substitute(list(...)) gives me an unevaluated list of the arguments, but I want a list of the unevaluated arguments. My attempts so far: (function(...) substitute(...))(a=1, b=a) # Only returns first (function(...) substitute(list(...)))(a=1, b=a) # Unevaluated list, not list of unevaluated (function(...)
2014 May 01
3
How to test if an object/argument is "parse tree" - without evaluating it?
This may have been asked before, but is there an elegant way to check whether an variable/argument passed to a function is a "parse tree" for an (unevaluated) expression or not, *without* evaluating it if not? Currently, I do various rather ad hoc eval()+substitute() tricks for this that most likely only work under certain circumstances. Ideally, I'm looking for a isParseTree()
2017 Sep 19
0
remove quotes from matrix
Works fine for me. What do you object to in the following? Calling the above df "d", > dm <- as.matrix(d) > dm Sub_Pathways BMI_beta SAT_beta VAT_beta 1 "Alanine_and_Aspartate" " 0.23820" "-0.02409" " 0.94180" 2 "Alanine_and_Aspartate" "-0.31300" "-1.97510" "-2.22040" 3
2008 Aug 01
3
Reading data in R-metrics
Hi Folks! I used the code below previously with no problems, but now I get: DTB3<-read.table("C:\\Program Files\\R\\R-2.7.1\\DTB3.csv",header=TRUE,sep=",") > tail(DTB3) DATE VALUE 14233 2008-07-23 1.56 14234 2008-07-24 1.62 14235 2008-07-25 1.71 14236 2008-07-28 1.70 14237 2008-07-29 1.69 14238 2008-07-30 1.67 >
2012 Mar 20
1
Remove quotes from a string to use in a variable call
Hi, I have a string that I want to use in a variable call. How can I remove the quotes and/or the string properties of the string to use it in a variable call? Here's an example: library(lme) fm2 <- lme(distance ~ age, data = Orthodont, random = ~ 1) summary(fm2) I want to update the above regression to include new predictors according to what is in a string: predictors <-
2004 Mar 18
12
substitute question
Consider the following example: # substitute a with b in the indicated function. Seems to work. > z <- substitute( function()a+1, list(a=quote(b)) ) > z function() b + 1 # z is an object of class call so use eval # to turn it into an object of class expression; however, # when z is evaluated, the variable a returns. > eval(z) function()a+1 Why did a suddenly reappear again
2008 Jan 24
1
Error using Rmetrics to read data
Hi folks. This set of code used to work, but after upgrading to the latest version of Rmetrics it no longer does. Any ideas? SP500<-read.table("SP500.csv",header=TRUE,sep=",") > head(SP500) Date Open High Low Close Volume Close2 1 8/4/2006 1280.26 1292.92 1273.82 1279.40 2530970112 1279.40 2 8/3/2006 1278.22 1283.96 1271.25 1280.27
2008 Jul 02
1
Multiple time series plots
Hi all: I'm trying to plot two time series created in Rmetrics and label the x-axis with dates. I tried the following: dates <- as.Date(seriesPositions(x.agg)) r <- as.Date(range(dates)) ts.plot(x.agg@Data[,c(1,5)],gpars=list(ylab="Volume", lty=c(1:2),xaxt="n",main="Plot of Volume")) axis.Date(1, at=seq(r[1], r[2], length.out=10),