similar to: Calling the curve function with a character object converted into an expression

Displaying 20 results from an estimated 10000 matches similar to: "Calling the curve function with a character object converted into an expression"

2018 May 03
1
Calling the curve function with a character object converted into an expression
Typo: should be NULL not NUL of course An alternative approach closer to your original attempt is to use do.call() to explicitly evaluate the expr argument: w <- "1 + x^2" do.call(curve, list(expr = parse(text = w), ylab ="y")) Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus
2018 May 03
0
Calling the curve function with a character object converted into an expression
Sebastian: This is somewhat arcane, perhaps even a bug (correction on this welcomed). The problem is that the "expr" argument to curve() must be an actual expression, not a call to parse that evaluates to an expression. If you look at the code of curve() you'll see why (substitute() does not evaluate expr in the code). Another simple workaround other than sticking in the eval()
2009 Sep 02
2
combining grid.text, expression and variables
Dear R-users, I am trying to use the grid.text and expression functions to display several character strings and plotmath text on a viewport. Some strings can include a variable portion (PI.limits in the following example), which I thought could be implemented by combining the bquote and the expression functions. Unfortunately, my expressions do not seem to be evaluated. I would greatly
2018 Mar 12
7
Equivalent of gtools::mixedsort in R base
Hi, Searching for functions that would order strings that mix characters and numbers in a "natural" way (ie, "a1 a2 a10" instead of "a1 a10 a2"), I found the mixedsort and mixedorder from the gtools package. Problems: 1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does 2- gtools has not been updated in 2.5
2018 Apr 09
3
Question about subset
Hi, The help page for subset states "subset: logical expression indicating elements or rows to keep: missing values are taken as false." Before I try to re-invent the wheel, I would like to know if one of the base or recommended packages would contain a variant of the subset function that would consider missing values as true. Thanks
2011 Feb 03
1
Getting variable names in function output
Dear R-users, I would like to have some advises about a problem illustrated by the following snippet. Within myf, I need to evaluate a piece of R code that is passed as a character argument and then return the objects that are created by this code. The difficulty comes from the fact that the content of the code is variable and unknown to me (obviously not in this illustration!). With the
2009 May 14
1
Problem with viewports, print.trellis and more/newpage
Dear R-users, I have got the following problem. I need to create 4x2 arrays of xyplot's on several pages. The plots are created within a loop and plotted using the print function. It seems that I cannot find the proper grid syntax with my viewports, and the more/newpage arguments. The following script is a simplification but hopefully will suffice to illustrate my problem. Any suggestion
2009 Apr 28
1
Understanding padding in lattice
Dear R-users, I am trying to understand what the different padding arguments in trellis.par.set are exactly controlling the space around lattice plots. I have used the following code as a basis for testing but it did not really help me to visualize how the value of each argument changes the margins and the plotting area. I guess a better way to visualize the effects of these padding items
2009 Feb 03
2
Numeric class and sasxport.get
Dear R-users, The sasxport.get function (from the Hmisc package) automatically defines the class of imported variables. I have noticed that the class of theoretically numeric variables is simply "labelled", although character variables might end up been defined as "labelled" "Date" or "labelled" "factor". Is there a way to tell sasxport.get to
2009 Jul 02
2
Passing expression as argument to do.call
Dear R-users, I would like to know how expressions could be passed as arguments to do.call functions. As illustrated in the short example below, concatenating lists objects and an expression creates an expression object, which is not an acceptable argument for do.call. Is there a way to avoid that? Thanks you Sebastien foo <- list(x=1:10, y=1:10) mylist <- list(pch=6, col=2) title
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does This is tangential, but do.call(order, mydataframe) is not safe to use in a general purpose function either - you need to remove the names from the second argument: > d <- data.frame(method=c("New","New","Old","Old","Old"),
2018 Apr 09
0
Question about subset
Sent from my iPhone > On Apr 8, 2018, at 9:06 PM, Sebastien Bihorel <sebastien.bihorel at cognigencorp.com> wrote: > > Hi, > > The help page for subset states "subset: logical expression indicating elements or rows to keep: missing values are taken as false." > > Before I try to re-invent the wheel, I would like to know if one of the base or recommended
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
??? > y <- sort( c("a1","a2","a10","a12","a100")) > y [1] "a1" "a10" "a100" "a12" "a2" > mixedsort(y) [1] "a1" "a2" "a10" "a12" "a100" **Please read the docs!** They say that mixedsort() and mixedorder() both take a **single
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
split any mixed columns into letter and number columns and then order can be used on that: DF <- data.frame(x = c("a10", "a2", "a1")) o <- do.call("order", transform(DF, let = gsub("\\d", "", x), no = as.numeric(gsub("\\D", "", x)),
2009 Apr 20
3
How to force axis to have the same range
Dear R-users, I am trying to produce (standard and trellis) scatterplots which use the same range of the x and y axes. In addition, I would like the plots to be physically square. Is there one or more specific argument(s) to plot and xyplot what would do that? I have looked at various combinations of asp and pin value, but could not get what I wanted.. Thank you in advance for your help
2003 Jul 30
2
Plotting a function with curve()
Why does > curve(function(y) y^2, from=0,to=1) not work, whereas > myf <- function(y) y^2 > curve(myf, from=0,to=1) work? For the former, I get the error message Error in curve(function(y) y^2, from = 0, to = 1) : 'expr' must be a function or an expression containing 'x' I'm using R1.7.0 under Windows XP. Damon Wischik.
2009 Sep 15
1
Regular expression problem
Dear R-users, I am trying to use the grep function to test whether a particular string is of the form "n.../mydir/myfile.mytype.myext". Anything between n and mytype could vary, and anything after mytype could vary. I tried to proceed by steps to build my regular expression... but I do not really understand why the last call of the following code do not work. Any help would be
2011 Feb 22
1
Discrepancies in run times
Dear R-users, I am in the process of creating new custom functions and am quite puzzled by some discrepancies in execution time when I run some R scripts that call those new functions. So here is the situation: - let's assume I have created two custom functions, called myg and myf; - myg is mostly a plotting function, which makes a heavy use of grid and lattice functions; - myf is a function
2009 Aug 21
2
Problem with passing a string to subset
Dear R-users, The following question bothered me for the whole afternoon: how can one pass a string as the conditioning argument to subset? I tried plain mystr, eval(mystr), expression(mystr), etc... I don't to be able to find the correct syntax > foo <- data.frame(a=1:10,b=10:1,c=rep(1:2,5)) > mystr<-"c==1" > subset(foo,c==1) a b c 1 1 10 1 3 3 8 1 5 5 6
2011 Apr 21
1
Package check issue: Rprofile.site is not used
Dear R-users, I am having some issues with a package I am working on (using R 2.12.1 in a Linux environment) and would like to have your opinions/advises. My package - let's call it mypackage for the purpose of this email - passes all checks of R CMD check, except for the following failure message: Error : .onLoad failed in loadNamespace() for 'mypackage', details: call: