similar to: substitute, expression and factors

Displaying 20 results from an estimated 20000 matches similar to: "substitute, expression and factors"

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
2009 Oct 01
1
inverse currying
Dear list, I have the following function, sugar = function(fun, id = "id"){ ff <- formals(fun) if( id %in% names(ff)) stop("id is part of args(fun)") formals(fun) <- c(unlist(ff), alist(id=)) fun } which one may use on a function foo, foo = function(x){ x } sugar(foo) # results in the extended closure, function (x, id) { x } Its limitation (other
2009 Nov 03
2
how to display a string containing greek chrs and variables
I'm trying something that I thought would be pretty simple, but it's proving quite frustrating... I want to display, for instance, the correlation coefficient "rho" in a graph. I can do something like: text(x, y, paste("rho =", cor)) where cor would be my previously calculated correlation coefficient, and x and y the coordinates. Obviously that displays
2008 Jun 25
1
expression, strsplit, ...
DeaR list, I'm a bit lost in the behavior of substitute and co. I often use fairly long axis labels in my graphs (long to write, that is). Typically, they would contain some greek letters and units with exponents, as in: > xlab=expression(paste("text ", alpha, " / ", V,".", m^{-3}, ".", > kg^{-2}, ".", l^{4})) To make this a
2007 Jul 19
1
substitute and expression (Peter Dalgaard)
In this connection, note the following > a4 <- 4 > plotThis <- bquote(alpha==.(a), list(a=a4)) > do.call(plot, list(1:10, main=do.call(expression, c(plotThis)))) > do.call(plot, list(1:10, main=do.call(expression, plotThis))) Error in do.call(expression, plotThis) : second argument must be a list > ## Whereas plotThis has class "call", c(plotThis) has class
2010 Feb 14
3
evaluate variable within expression - how?
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt. Name: nicht verf?gbar URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100214/4b41a017/attachment.pl>
2011 Mar 09
2
switch and factors
Dear list, Reading the help page for ?switch didn't give me more than a hint at what's going on here, x = 5 y = 2 foo <- function(a="x"){ switch(a, "x" = x, "y" = y) } foo(factor('x', levels=c('y', 'x'))) # 2 It seems that switch, when given a factor, uses the numeric codes rather than the string
2009 Nov 10
3
drop unused levels in subset.data.frame
Dear list, subset has a 'drop' argument that I had often mistaken for the one in [.factor which removes unused levels. Clearly it doesn't work that way, as shown below, d <- data.frame(x = factor(letters[1:15]), y = factor(LETTERS[1:3])) s <- subset(d, y=="A", drop=TRUE) str(s) 'data.frame': 5 obs. of 2 variables: $ x: Factor w/ 15 levels
2009 Mar 25
2
"[.data.frame" and lapply
Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, > d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5))) > str(d) > > lapply(d, "[", i= c(1)) # fine, this extracts the first columns > lapply(d, "[", j= c(1, 3)) # doesn't do nothing ?! > > library(plyr)
2009 Mar 25
2
"[.data.frame" and lapply
Dear all, Trying to extract a few rows for each element of a list of data.frames, I'm puzzled by the following behaviour, > d <- lapply(1:4, function(i) data.frame(x=rnorm(5), y=rnorm(5))) > str(d) > > lapply(d, "[", i= c(1)) # fine, this extracts the first columns > lapply(d, "[", j= c(1, 3)) # doesn't do nothing ?! > > library(plyr)
2009 Nov 20
1
How to concatenate expressions
Dear R-users, I am developing a plotting function, which receives expressions and character/numerical vectors as part of the many input arguments and which tries to concatenate them before displaying the result to the plot. I currently cannot find a way to make this concatenation works. I have read several posts in the list that solved this problem by pasting the different elements together
2009 Apr 03
3
plyr and table question
Dear all, I'm puzzled by the following example inspired by a recent question on R-help, cc <- textConnection("user_id website time 20 google 0930 21 yahoo 0935 20 facebook 1000 25 facebook 1015 61 google 0940") d <- read.table(cc, head=T) ; close(cc) table(d$user_id) # count the
2011 Apr 26
2
grid stringHeight
Dear all, I'm puzzled by the behavior of stringHeight in the grid package. Consider the following test, library(grid) test <- function(lab="dog", ...){ g1 <- textGrob(lab) g2 <- rectGrob(height=grobHeight(g1), width=grobWidth(g1)) gg <- gTree(children=gList(g1,g2), ...) print(c("height:", convertUnit(stringHeight(lab), "mm",
2010 Aug 27
3
How to plot an expression-label with variable text
Disclaimer: I have read plotmath, but maybe it's too late today: How do I get the two labels to be the same: plot.new() lab =expression(paste("Estimated ", t[50]," from tgv")) text(0.5,0.5,lab) # Should look the same as above. I could not get the substitute right: what = "tgv" lab =expression(paste("Estimated ", t[50]," from ",what))
2010 Sep 09
1
scalable < > delimiters in plotmath
Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails with < > however, and I cannot find a workaround, grid.text(expression(bgroup("<",atop(x,y),">"))) Error in bgroup("<", atop(x, y), ">") : invalid group delimiter Regards, baptiste sessionInfo() R version
2010 Sep 09
1
scalable < > delimiters in plotmath
Dear list, I read in ?plotmath that I can use bgroup to draw scalable delimiters such as [ ] and ( ). The same technique fails with < > however, and I cannot find a workaround, grid.text(expression(bgroup("<",atop(x,y),">"))) Error in bgroup("<", atop(x, y), ">") : invalid group delimiter Regards, baptiste sessionInfo() R version
2009 Sep 28
2
dichromat, regexp, and grid objects
Dear list, The dichromat package defines a dichromat function which "Collapses red-green color distinctions to approximate the effect of the two common forms of red-green colour blindness, protanopia and deuteranopia." library(dichromat) library(grid) colorStrip <- function (colors = 1:3, draw = TRUE) { x <- seq(0, 1 - 1/length(colors), length = length(colors)) y <-
2009 Oct 26
1
regular expressions
Dear list, I have the following text to parse (originating from readLines as some lines have unequal size), st = c("START text1 1 text2 2.3", "whatever intermediate text", "START text1 23.4 text2 3.1415") from which I'd like to extract the lines starting with "START", and group the subsequent fields in a data.frame in this format: text1 text2
2010 Aug 27
2
export 4D data as povray density files
Dear list, I wish to visualise some 4D data as a kind of colour / translucent cloud in 3D. I haven't seen such plots in R (but perhaps I missed a feature of rgl). The easiest option I found would be to export the data in povray's df3 (density file) format and visualise it with povray. The format specification baffles me a little, http://www.povray.org/documentation/view/3.6.1/374/ ;
2010 Mar 10
4
write.fortran
Dear all, I'm trying to write tabular data to a text file, these data will be the input of a Fortran program. The format needs to be "(i7,2x,7(e15.7,2x))". I have not been able to find a clean way of producing this output with write.table. I searched for a "write.fortran" function similar to read.fortran() in package utils but I couldn't find any. Below is a small