Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-11 Thread David Winsemius
> On Dec 11, 2016, at 5:35 PM, frede...@ofb.net wrote: > > Dear R-Help, > > I was going to ask Jeff to read the entire works of William > Shakespeare to learn why his reply was not helpful to me... >From a typical US 10th grade English assignment: Cassius: "The fault, dear Brutus, is not in ou

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-11 Thread frederik
Dear R-Help, I was going to ask Jeff to read the entire works of William Shakespeare to learn why his reply was not helpful to me... Then I realized that the answer, as always, lies within... desub <- function(y) { e1=substitute(y, environment()) e2=do.call(substitute,list(e1), e

Re: [R] Overlapping of arrow in PCA

2016-12-11 Thread Jim Lemon
Hi Tan Dai, It looks like you have little or no variance in your measurements, and so the result is degenerate. The functions you are using are probably working properly, but there is nothing to display. Jim On Sat, Dec 10, 2016 at 6:04 PM, Tan Dai Chuan via R-help wrote: > Hi, i face the probl

Re: [R] Function implemented in R returns the wrong value

2016-12-11 Thread peter dalgaard
There are limits to how much people will do your debugging for you, but it looks like you are unpacking beta,gamma from par, but packing gamma,beta into start. Otherwise, print some of the values computed in the function and check. -pd > On 10 Dec 2016, at 20:01 , Fernando de Souza Bastos wrot

Re: [R] [FORGED] help with gradient boxplot

2016-12-11 Thread Paul Murrell
Hi Great to hear you have it working. Figuring out the names of grobs takes two things: 1. someone has to name the grobs 2. grid.ls() The reason why I did my example using 'lattice' is because 'lattice' names all of its grobs. There is a document ... http://lattice.r-forge.r-project.org/Vi

Re: [R] Assign a list to one column of data frame

2016-12-11 Thread Marlin JL.M
Dear Bert, This is awesome, thanks a lot! Best, Marlin On Sun, 2016-12-11 at 06:52 -0800, Bert Gunter wrote: > Use list indexing, "[[" not "[" . > > > df <- data.frame(a=1:3,b=letters[1:3]) > > x <- "new" > > df[[x]]<-  I(list(1:5,g = "foo", abb = matrix(runif(6),nr=3))) > > df > >   a b 

Re: [R] Function implemented in R returns the wrong value

2016-12-11 Thread Fernando de Souza Bastos
Thank you Duncan, it really was that! Fernando de Souza Bastos Professor Assistente Universidade Federal de Viçosa (UFV) Campus UFV - Florestal Doutorando em Estatística Universidade Federal de Minas Gerais (UFMG) Cel: (31) 99751-6586 2016-12-11 11:25 GMT-02:00 Duncan Murdoch : > On 10/12/2

Re: [R] Assign a list to one column of data frame

2016-12-11 Thread Marlin JL.M
If you see my previous example, I have tried something like > df[,n3] <- I(mylist) However, in my case, the name of the new column is in a variable (by user input) which can not be directly used by the dollar assign. On the other hand, "[<-" does not work correctly even if I wrap the list into "

Re: [R] Assign a list to one column of data frame

2016-12-11 Thread Bert Gunter
Glad to help. However, I need to publicly correct my misstatement. Both "[[" and "[" can be used and are useful for list indexing. As ?"[" clearly states, the former selects only a single column, while the latter can select several. Also: "Both [[ and $ select a single element of the list. The m

Re: [R] Assign a list to one column of data frame

2016-12-11 Thread Bert Gunter
Use list indexing, "[[" not "[" . > df <- data.frame(a=1:3,b=letters[1:3]) > x <- "new" > df[[x]]<- I(list(1:5,g = "foo", abb = matrix(runif(6),nr=3))) > df a b new 1 1 a 1, 2, 3, 2 2 b foo 3 3 c 0.248115 > df$new [[1]] [1] 1 2 3 4 5 $g [1] "foo" $abb [,1]

Re: [R] Function implemented in R returns the wrong value

2016-12-11 Thread Duncan Murdoch
On 10/12/2016 2:01 PM, Fernando de Souza Bastos wrote: The Log.lik function below returns the value '-INF' when it should return the value -5836.219. I can not figure out the error, does anyone have any suggestions? I haven't read it carefully, but a likely problem is that you are using constr

Re: [R] Assign a list to one column of data frame

2016-12-11 Thread Bert Gunter
?data.frame says: "If a list or data frame or matrix is passed to data.frame it is as if each component or column had been passed as a separate argument (except for matrices of class "model.matrix" and those protected by I). " So doing what Help says to do seems to do what you asked: > df <- da

Re: [R] Organize regression output

2016-12-11 Thread Jim Lemon
Hi Francesca, I'm not sure what you are doing here, but try this: regnames<-paste("r",letters[1:8],sep="") for(i in 1:8) { response<-rnorm(20) coef1<-rnorm(20) coef2<-rnorm(20) age<-sample(20:50,20) gender<-sample(c("M","F"),20,TRUE) assign(regnames[i],lm(response~coef1+coef2+age+gender)) }

Re: [R] how do I define a function which is equivalent to `deparse(substitute(x))`?

2016-12-11 Thread Jeff Newmiller
No. Read Hadley Wickham's "Advanced R" to learn why not. -- Sent from my phone. Please excuse my brevity. On December 10, 2016 10:24:49 PM PST, frede...@ofb.net wrote: >Dear R-Help, > >I asked this question on StackOverflow, > >http://stackoverflow.com/questions/41083293/in-r-how-do-i-define-a-f