similar to: the inverse of assign()

Displaying 20 results from an estimated 40000 matches similar to: "the inverse of assign()"

2012 Aug 29
5
Extracting the name of a function (inverse of match.fun("myFun"))
Hi all, is there a way to extract the name of a function, i.e. do the reverse of match.fun applied to a character string? I would like to print out the name of a function supplied to another function as an argument. For example: myFunc = function(x) { x+1 } applyFunc = function(fnc, x) { fnc = match.fun(fnc) fnc(x) } Is there a way to obtain "myFunc" from the argument fnc in
2010 Jan 18
2
An argument processing puzzle.
I have been trying to write a function mv(a,b) to move an object a to object b. It returns no value, but only exists for this side effect. Basically it just does b <- a; rm(a). With some checking and prompting about over-writing. The thing is, I'd like to be able to use either call by name or call by value syntax. I.e. I want to set up my argument processing so that mv(a,b)
2007 Sep 04
4
Q: selecting a name when it is known as a string
I am 100% certain that there is an easy way to do this, but after experimenting off and on for a couple of days, and searching everywhere I could think of, I haven't been able to find the trick. I have this piece of code: ... attach(d) if (ORDINATE == 'ds') { lo <- loess(percent ~ ncms * ds, d, control=loess.control(trace.hat = 'approximate')) grid <-
2006 Nov 13
2
A printing "macro"
I am exploring the result of clustering a large multivariate data set into a number of groups, represented, say, by a factor G. I wrote a function to see how categorical variables vary between groups: > ddisp <- function(dvar) { + csqt <- chisq.test(G,dvar) + print(csqt$statistic) + print(csqt$observed) + print(round(csqt$expected)) + round(csqt$residuals) + } > > x
2011 Mar 10
1
about textConnection
I need read a table in a string with special format. I used read.csv and textConnection function. But i am confuse about textConnection by follow code. case A: It is OK£¡ str0 <- '{"abc",{"def","X,1&Y,2&Z,3"}}' str1 <- strsplit(str0,'"')[[1]][6] str2 <- gsub("&","\n", str1) con <-
2009 Feb 07
3
Output results to a single postscript document
Hello R users, I have been trying to output all my results (text, plots, etc) into the same postscript file as one document, but have been unable to...Can anyone help me improve my code below so that I can accomplish this? Currently I have to output them separately then piece them back together into one document.. Thanks in Advance for any help! options (scipen=999, digits=7)
2013 Apr 04
6
categorized complete list of R commands?
every time I read the R release notes for the next release, I see many functions that I had forgotten about and many functions that I never knew existed to begin with. (who knew there were bibtex facilities in R? obviously, everyone except me.) I wonder whether there is a complete list of all R commands (incl the standard packages) somewhere, preferably each with its one-liner AND
2006 Jul 07
4
Modifying parsed code
I would like to take this: .img(plot(1:10), filename="a") and produce plot(1:10) ie. whenever .img is used, I want to take the first argument and throw away everything else. (I am trying to produce a Sweave like environment in which I can apply certain functions, but not have them displayed in the output) I think I should be able to do it using substitute, but I don't know how
2009 Sep 28
4
How to assess object names within a function in lapply or l_ply?
Dear All, to produce output of several columns of a data frame, I tried to use lapply and also l_ply. In both cases, I would like to print a header line containing also the name of the respective column in the data frame. For example, I would like the following lapply(data.frame(a=1:3, b=2:4), function(x) print(deparse(substitute(x)))) to produce: [1] "a" [1] "b" and
2009 Jul 02
4
Name of data.frame as a text string?
I've passed a data.frame as an input into a function which does some plotting on a 4x4 matrix of certain parameters within in the data.frame. I'd like to add a small header on top of each plot with the name of the data.frame so that it's clear as I compare these 16 things where each on came from. So far I haven't found the right way to get the name of the data.frame as a string
2012 Oct 04
2
Help with R Fitting an inverse Gamma
Dear all, I am new in R and would like to ask for someone's help in understanding where I go wrong with the following code: rm(list=ls()) # Required packages library(MCMCpack) # Simulated data set.seed(1) data = rinvgamma(n=250, shape = 5, scale = 2) + 2 hist(data) # log-likelihood ll = function(par){ if(par[1]>0 & par[2]>0 & par[3]<min(data)) return(
2016 Oct 03
4
Manual avanzado de R
Buenas, Alguien puede recomendarme un manual avanzzado de R, que me enseñe por ejemplo como aplicar tapply con sacar la pendiente de una recta, y cosas así. Gracias Jesús [[alternative HTML version deleted]]
2010 Oct 08
2
What do you call the value that represents a missing argument?
Hi all, What's the official name for the value that represents a missing argument? e.g. formals(plot)$x str(formals(plot)$x) deparse(formals(plot)$x) is.symbol(formals(plot)$x) What's the correct way to create an object like this? (for example if you are manipulating the formals of a function to add an argument with no default value, as in http://stackoverflow.com/questions/3892580/).
2009 Apr 02
4
Deleting rows based on identity variable
I have created this data frame to help illustrate my problem. id<-c(rep(1,5),rep(2,5),rep(3,5),rep(4,5),rep(5,5)) x<-rep((seq(1:5)),5) y<-c(0, 0.1, 0.5, 0.4, 0.2, 0, 0.1, 0.5, 0.4, 0.12, 0, 0.1, 0.5, 0.55, 0.2, 0, 0.1, 0.5, 0.3, 0.2, 0, 0.1, 0.6, 0.4, 0.1) d1<-cbind(id,x,y) I would like to delete all rows where id=4, however, when I tried the command  d2=d1[-c(id==4),] and looked
2008 Oct 16
2
Grouped Histogram (colored)
Hi all, I'm trying to create a histogram which shows the frequency of variables within a certain timeframe. I've been using SPSS before, but I didn't quite like it... To describe my problem further here are some example variables: the "event" is actually a string which I recoded using: [code] data$event_class = as.numeric(as.factor(data$event)) [/code] I've recoded
2018 Mar 14
1
Fwd: Learning advanced R
Hi Albrecht, I am forwarding your reply to the full group. It's been a while since I did this and I don't remember the details. Maybe someone else can comment. (I am a bit busy at the moment.) If no one supplies the information in a few days I will try to take a look. In the meantime you can start your reading on-line. :-) Regards, Eric Dear Eric, I downloaded the material from
2012 Feb 04
1
'deparse(substitute'))' then 'assign' in a S4 methods
Hi the list, I am writing a function in which I need to affect a variable on a higher level. My fnction could be: ++++++++++++++++++ fooBis <- function(x){ nameObject <- deparse(substitute(x)) print(nameObject) assign(nameObject,4,envir=parent.frame()) } > fooBis(e) [1] "e" > e [1] 4 ----------------- (to simplify, this fnction can affect only the number
2010 Mar 15
2
Strange behavior of assign in a S4 method.
Hi the list, I define a method that want to change an object without assignation (foo(x) and not x<-foo(x)) using deparse and assign. But when the argument of the method does not match *exactly* with the definition of the generic function, assign does not work... Anything wrong? Christophe #------ Does not work ------#
2018 Jan 07
1
help needed on quantmod....
dear members, I am using quantmod to work with stock prices... I am trying to append the data got from getQuote to the one got by getSymbols. The function is named "apnd". The code is as follows: function(x){ if ((class(x) == "xts") || (class(x) == "zoo")){ sym <- deparse(substitute(x))
2007 Dec 26
2
Rbind-ing a list into one item
Hi, I am doing the following: 1. I have a list of files.. Files1=list.files("some directory",pattern="some pattern") 2. I define a list as res=vector("list", length(files1)) 3. I read all the files into this list: res=lapply(files1, read.csv) I now want to rowbind all the items in the list into one big mass (all files have same number of columns). I tried