Re: [R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Peter Langfelder
On Sat, Mar 11, 2017 at 2:11 PM, Mohammad Tanvir Ahamed via R-help wrote: > Thanks for reply. > as I said , the function in the package is like > myplot <- function(x,y) { plot(x,y) } > > not like > myplot <- function(x,y) { plot(x,y,...) } > > And I cant change the function

Re: [R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Jeff Newmiller
You can't. You can skip the package and roll your own functions if the package functions are not written to use ... -- Sent from my phone. Please excuse my brevity. On March 11, 2017 2:11:39 PM PST, Mohammad Tanvir Ahamed via R-help wrote: >Thanks for reply. >as I said

Re: [R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Rolf Turner
On 12/03/17 11:11, Mohammad Tanvir Ahamed wrote: Thanks for reply. as I said , the function in the package is like myplot <- function(x,y) { plot(x,y) } not like myplot <- function(x,y) { plot(x,y,...) } And I cant change the function inside the package!! So , in this case how to solve the

Re: [R] About error in the panel

2017-03-11 Thread William Dunlap via R-help
You will get this error if 'df' does not have columns named "X" and "Y", so df$X or df$Y is NULL. E.g., > df <- data.frame(One=1:3, Two=11:13) > df$Three <- df$One + df$noSuchColumn Error in `$<-.data.frame`(`*tmp*`, "Three", value = numeric(0)) : replacement has 0 rows, data has 3

Re: [R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Mohammad Tanvir Ahamed via R-help
Thanks for reply. as I said , the function in the package is like myplot <- function(x,y) { plot(x,y) } not like myplot <- function(x,y) { plot(x,y,...) } And I cant change the function inside the package!! So , in this case how to solve the problem ? Tanvir Ahamed Göteborg, Sweden |

Re: [R] About error in the panel

2017-03-11 Thread Jeff Newmiller
Copy one statement at a time into a new R session. When you get an error you will know what you need to look at more closely. RStudio makes this easy with the Start New R Session menu option and using Ctrl-Enter in the editor. -- Sent from my phone. Please excuse my brevity. On March 11, 2017

Re: [R] [FORGED] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Rolf Turner
On 12/03/17 10:26, Mohammad Tanvir Ahamed via R-help wrote: Hi!, Lets I have a function form a package. The function is, as an example, myplot <- function(x,y) { plot(x,y) } Now I can use the function according to function's defined argument. x<- sort(runif(200)) y<- 1:200 myplot(x,y) Now

Re: [R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Franklin Bretschneider
Dear Mohammad Tanvir Ahamed, Re: > Hi!, > > Lets I have a function form a package. > The function is, as an example, > > myplot <- function(x,y) { plot(x,y) } > > > Now I can use the function according to function's defined argument. > > x<- sort(runif(200)) > y<- 1:200 > myplot(x,y)

[R] Override/Insert (Change) a value (default value) inside a function

2017-03-11 Thread Mohammad Tanvir Ahamed via R-help
Hi!, Lets I have a function form a package. The function is, as an example, myplot <- function(x,y) { plot(x,y) } Now I can use the function according to function's defined argument. x<- sort(runif(200)) y<- 1:200 myplot(x,y) Now I want to input extra argument or override default value

Re: [R] About error in the panel

2017-03-11 Thread lily li
I think this is the problem. How to solve then? On Sat, Mar 11, 2017 at 12:18 PM, Bert Gunter wrote: > Typo, should be: > > 3. A guess: You are sourcing the entire script in the editor panel > into R, and there is something screwed up there. > > -- Bert > > > Bert Gunter

Re: [R] About error in the panel

2017-03-11 Thread Bert Gunter
Typo, should be: 3. A guess: You are sourcing the entire script in the editor panel into R, and there is something screwed up there. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his

Re: [R] About error in the panel

2017-03-11 Thread lily li
Thanks for your reply. I thought anything about R questions can be posted here. About your third point, what does it mean? I did the same thing before for other scripts, but this one does not work. Thanks again. On Sat, Mar 11, 2017 at 12:12 PM, Bert Gunter wrote: > 1.

Re: [R] About error in the panel

2017-03-11 Thread Bert Gunter
1. Not reproducible, hence impossible to say. 2. This is r-help. RStudio is totally separate and its own support page. 3. A guess: Use are sourcing the entire script in the editor panel into R, and there is something screwed up there. Cheers, Bert Bert Gunter "The trouble with having an open

Re: [R] About error in the panel

2017-03-11 Thread lily li
More specifically, it shows the following when I typed traceback(): 3: stop(sprintf(ngettext(N, "replacement has %d row, data has %d", "replacement has %d rows, data has %d"), N, nrows), domain = NA) 2: `$<-.data.frame`(`*tmp*`, "Z", value = numeric(0)) 1: `$<-`(`*tmp*`, "Z", value =

[R] About error in the panel

2017-03-11 Thread lily li
Hi R users, I have a problem about using R studio. For example, there is a dataframe that has many columns. I want to aggregated column X and column Y into column Z. Column Z does not exist before the aggregation. I use the code below: df$Z = df$X + df$Y However, it does not work in the top left

Re: [R] find index in a list of list

2017-03-11 Thread ce
Thank you both, indeed combining two solutions fixed my problem : > which(sapply(mylist, mycompare,find)) [1] 2 I admit list of lists is not the optimal design, it's out of my control but is there is not much data in it, so performance is not an issue. For the sake of R's honour I didn't

Re: [R] find index in a list of list

2017-03-11 Thread Jeff Newmiller
Since the offered solution already checks each top level element using the "identical" function, you just need a different comparison function, like perhaps: mycompare <- function( x, y ) { identical( x[[ "a" ]], y[[ "a" ]] ) && identical( x[[ "b" ]], y[[ "b" ]] ) } Note that your decision

Re: [R] nls fitting & plotting to data subsets defined by combinations of categorical variables

2017-03-11 Thread J C Nash
Given that nls() often gives failures of the "singular gradient" type, you may want to give package nlsr a try with the nlxb() function. It should be able to use analytic gradients on this expression, has bounds, and uses a Marquardt stabilized solver. It can still fail, but is more robust than

Re: [R] Linear Mixed-Effects Model

2017-03-11 Thread Bert Gunter
Have you read the docs? Is this some kind of homework? -- this list does not do homework. We expect minimal efforts at least on the part of posters. We do not do tutorials here. I think you need to do some reading on your own before posting further. Try posting on the r-sig-mixed-models list to

[R] nls fitting & plotting to data subsets defined by combinations of categorical variables

2017-03-11 Thread DANIEL PRECIADO
Dear list, I want to apply the same nls function to different subsets of a larger dataset. These subsets are defined as unique combinations of two (categorical) variables, each one with two levels, so I should obtain 4 sets of parameters after fitting. I have managed to do it in a loop,

Re: [R] find index in a list of list

2017-03-11 Thread ce
Sorry I rejoiced too soon. In fact original list is more complex like : mylist <- list(list(a=10,b="x",c=1),list(a=11,b="y",c=2),list(a=12,b="z",c=5)) and I still need to find index of where a = 11 and b = "y" and I have no c value , -Original Message- From: "ce"

[R] field values from text file to dataframe

2017-03-11 Thread Vijayan Padmanabhan
Dear r-help group I have a text file which is a data dump of a pdf form as given below.. I want it to be converted into a data frame with field name as column names and the field value as the row value for each field. I might have different pdf forms with different field name value pairs to

Re: [R] find index in a list of list

2017-03-11 Thread ce
Exactly. Thanks a lot, I was trying sapply with to result. -Original Message- From: "Rui Barradas" [ruipbarra...@sapo.pt] Date: 03/11/2017 10:06 AM To: "ce" , r-help@r-project.org Subject: Re: [R] find index in a list of list Hello, Something like this? find <-

Re: [R] find index in a list of list

2017-03-11 Thread Rui Barradas
Hello, Something like this? find <- list(a=11,b="y") which(sapply(mylist, identical, find)) Hope this helps, Rui Barradas Em 11-03-2017 14:59, ce escreveu: Hi all, I have a list of lists like this : mylist <- list(list(a=10,b="x"),list(a=11,b="y"),list(a=12,b="z")) I want to find the

[R] find index in a list of list

2017-03-11 Thread ce
Hi all, I have a list of lists like this : mylist <- list(list(a=10,b="x"),list(a=11,b="y"),list(a=12,b="z")) I want to find the index of list in mylist where a = 11 and b = "y" , so I want to get 2 as a result Thanks in advance __

[R] Linear Mixed-Effects Model

2017-03-11 Thread ????
Dear R Help: What does "lmer(responce ~ factor1*factor2 + (factor1*factor2 | group1) + (factor1*factor2| group2), data)" mean? And "lmer(responce ~ factor1*factor2 + (factor1*factor2 | group1) + (factor1*factor2| group2), data)" vs. "lmer(responce ~ factor1*factor2 + (factor1+factor2 | group1)

Re: [R] Help with lapply and tapply

2017-03-11 Thread Rui Barradas
Also, the OP's FUN1 is NOT a function. It's the result of a function call. A function would be FUN1 <- function(x) EM_mixture_copula(...) Hope this helps, Rui Barradas Em 11-03-2017 10:29, Michael Hannon escreveu: I think Bert's advice is sound. Let me add a few, miscellaneous comments:

Re: [R] Help with lapply and tapply

2017-03-11 Thread Michael Hannon
I think Bert's advice is sound. Let me add a few, miscellaneous comments: (1) Some people find "by" easier than "tapply". (2) The "apply" function can, as I'm sure you (Bert) know, iterate over a matrix. (3) Hadley probably has better ways to do all of this (it's hard to keep up). -- Mike On

Re: [R] plotting longitudinal data with ggplot

2017-03-11 Thread Ulrik Stervbo
You need to set the aesthetic 'group' to something meaningful, probably ID in this case. HTH Ulrik On Fri, 10 Mar 2017, 19:30 Rayt Chiruka, wrote: > i am trying to convert a dataset from wide to long format using package > tidyr- (seems to have been done) > > wen in try

Re: [R] reading form data from pdf forms

2017-03-11 Thread Ulrik Stervbo
I don't know if there's a pure R option, but i believe pdftk can extract the form data which you can then manipulate in R. Best Ulrik On Sat, 11 Mar 2017, 05:14 Vijayan Padmanabhan, < padmanabhan.vija...@gmail.com> wrote: > Dear R-Help group > Is there any way that I can programmatically

Re: [R] write.xlsx

2017-03-11 Thread peter dalgaard
Also, this is from a package. Which? (AFAIR, there are at least two possibilities). What is is the docs? Does it even allow an append= argument? -pd > On 10 Mar 2017, at 14:49 , Michael Dewey wrote: > > Dear Paul > > Have you defined a variable T or F somewhere? >

Re: [R] problem with PCA

2017-03-11 Thread Denis Francisci
Thank you David for your answer. If I understood the relative positions of variable arrows don't reflect the coefficient of correlation of the original variables. In fact these positions change if I use different PC axes. But in some manual about PCA in R I read: "Pairs of variables that form