Re: [R] df pseudoreplication in lme model

2015-01-29 Thread Jeff Newmiller
1) Wrong list... this belongs on R-sig-mixed, per the Posting Guide. 2) These lists are plain text only. HTML ends up getting corrupted. Please figure out your email client to avoid confusion. 3) It is difficult to troubleshoot with just the output... you are requested to make a minimal example

Re: [R] create a function with "subset" statement

2015-01-29 Thread JSHuang
Hi, The following is implemented with function named subsetAll. It calls the function subset1. The input to subset1 is the matrix A and a vector indicating the beginning and ending values for columns 1 and 2. Input to subsetAll is the matrix A and a matrix that is row bind from those vectors

Re: [R] Variables of a function called inside another one

2015-01-29 Thread JSHuang
Hi, Maybe I missed something. The following example works. It should not cause any problem with the same parameter names since their scopes are within the functions. > function2 <- function(a,b,c,d){ + a+b+c+d} > function2(1:2,2:3,3:4,4:5) [1] 10 14 > function1 <- function(a,b,c,d){ + newb <-

[R] measure of goodness of fit for the model without an intercept

2015-01-29 Thread Yan Wu
Hi, When I fit the regression model without an intercept term, R-squared tends to much larger than the R-squared in the model with an intercept. So in this case, what�s a more reasonable measure of the goodness of fit for the model without an intercept? Thanks a lot!! Yan [[alter

[R] df pseudoreplication in lme model

2015-01-29 Thread Lauren Meyer
Hello, I am trying to assess weather or not my df are pseudoreplicated in my lme model. my study was undertaken on five fish (labeled PC) each tested in two replicates(REP), across each combination of three treatments HOM, C18 and CU, each of which had two levels; HOM(SON, BLD),C18 SML, BIG), CU (

[R] How to run sequential Rscript command for windows command line with a batch file.

2015-01-29 Thread nevil amos
Hi, I need to run multiple iterations of a script to which I am supplying a single numeric argument I can open the command prompt window and enter a single command: "C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 18 and it runs OK and saves the outputs. Similarly if I run the same

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi Bill, You solved by problem. For some reason, I thought xname was only referring to name of the x-axis. I remember last time I fixed it, it was something about xname, couldn't get it right this time. Thanks! Saved me hours from frustration. Mike On Thu, Jan 29, 2015 at 9:04 PM, William Du

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread Alan Yong
Much thanks, Hadley! Cheers, Alan On Jan 29, 2015, at 12:36 PM, Hadley Wickham wrote: > On Thu, Jan 29, 2015 at 11:43 AM, Alan Yong wrote: >> Much thanks to everyone for their recommendations! I agree that fishing in >> the global environment isn't ideal & only shows my budding understanding

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread William Dunlap
Does help(curve) talk about its 'xname' argument? Try curve(10*foofoo, from=0, to=17, xname="foofoo") You will have to modify your function, since curve() will call it once with a long vector for the independent variable and func(rnorm(10), rnorm(10), mu=seq(0,5,len=501)) won't work right.

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi Rui, Thank you for your help. That works for now, but eventually, I need to be pass in x and y. Is there a way to tell the curve() function, x is a fix vector, mu is a variable! Thanks, Mike On Thu, Jan 29, 2015 at 5:25 PM, Rui Barradas wrote: > Hello, > > The following will work, but I

[R] foreign:::writeForeignSPSS vs. write.foreign(df, datafile, codefile, package='spss')

2015-01-29 Thread Simon Kiss
Hello: I discovered recently that the function foreign:::writeForeignSPSS allows for variable names longer than 8 characters and has an additional argument varnames. Neither of these capabilities exist with write.foreign. But according to the help file for write.foreign it seems that the latter

Re: [R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread Rui Barradas
Hello, The following will work, but I don't know if it's what you want. func2 will get x and y from the global environment. func2 <- function(mu){ x + y + mu ^ 2 } curve(func2, from = 0, to = 10) Hope this helps, Rui Barradas Em 29-01-2015 21:02, C W escreveu: Hi all, I want to graph

Re: [R] "effects" package issue for lme4's lmer()

2015-01-29 Thread John Fox
Dear Krisztina, I'm glad this worked out. I've cc'ed my response to r-help and Sandy Weisberg so everyone following this thread can see the outcome. Best, John > -Original Message- > From: Krisztina Mosdossy [mailto:kriszmosdo...@gmail.com] > Sent: January-29-15 4:51 PM > To: j...@mcma

Re: [R] create a function with "subset" statement

2015-01-29 Thread Jim Lemon
Hi S, I did try (briefly) to work out a way to use lapply but couldn't quite get it right. After a bit of fooling around the following does work as a standalone command: lapply(subsets, function(sub, x) do.call(subset,list(x,subset=eval(parse(text=sub, x=A) Thanks for the improvement. Jim

Re: [R] "effects" package issue for lme4's lmer()

2015-01-29 Thread John Fox
Dear Krisztina, I don't think that you mentioned that you were using Mac OS X and if you did I missed it. Presumably allEffects() still doesn't work because you didn't install the development version of effects. R-Forge doesn't build binary packages for Mac OS X. If you're set up to build R pa

[R] How to use curve() function without using x as the variable name inside expression?

2015-01-29 Thread C W
Hi all, I want to graph a curve as a function of mu, not x. Here's the R code: x <- rnorm(10) y <- rnorm(10) func <- function(x, y, mu){ x + y + mu ^ 2 } curve(f = func(x = x, y = y, mu), from = 0, to = 10) I know I can change variable mu to x, but is there a way to tell R that mu is the va

Re: [R] "effects" package issue for lme4's lmer()

2015-01-29 Thread Krisztina Mosdossy
Hello John, Thank you for your prompt reply! Unfortunately, I get the following message when trying to download the "effects" package from R-forge (and allEffects() doesn't work): Warning: unable to access index for repository > http://R-Forge.R-project.org/bin/macosx/mavericks/contrib/3.1 >

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread Hadley Wickham
On Thu, Jan 29, 2015 at 11:43 AM, Alan Yong wrote: > Much thanks to everyone for their recommendations! I agree that fishing in > the global environment isn't ideal & only shows my budding understanding of R. > > For now, I will adapt Chel Hee's "length(eval(parse(text=DFName))[,1])" > solution

Re: [R] "effects" package issue for lme4's lmer()

2015-01-29 Thread John Fox
Dear Krisztina, Thank you for your kind remarks about the effects package. The issue is almost surely the slow computation of Kenward-Roger standard errors for the effects, which we compute by default (KR=TRUE) for a linear mixed model fit by lmer(). This problem is compounded by a bug in allEffe

[R] "effects" package issue for lme4's lmer()

2015-01-29 Thread Krisztina Mosdossy
Hello fine R folks, I am a big fan of the "effects" package as it enables me to visualize my GLMM's quite nicely and with ease. I am, however, unable to find a way to use the effect() or allEffects() functions with my recent lmer model. I just updated R, lmerTest and effects packages the other da

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread Alan Yong
Much thanks to everyone for their recommendations! I agree that fishing in the global environment isn't ideal & only shows my budding understanding of R. For now, I will adapt Chel Hee's "length(eval(parse(text=DFName))[,1])" solution then fully explore Jeff's suggestion to put the data frames

Re: [R] Your personal email on the R-help mail list

2015-01-29 Thread David L Carlson
Yes. I thought I was replying to a different message. Sorry. David -Original Message- From: Chel Hee Lee [mailto:chl...@mail.usask.ca] Sent: Thursday, January 29, 2015 11:33 AM To: David L Carlson Subject: Your personal email on the R-help mail list Hi David, I am not sure if you notic

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread David L Carlson
That's fine, but I'm here in town if you want me to pick her up at the airport. David -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chel Hee Lee Sent: Thursday, January 29, 2015 9:18 AM To: Jeff Newmiller; Alan Yong; r-help@r-project.org Subject: Re: [

Re: [R] problem with conditional column sums

2015-01-29 Thread Chel Hee Lee
Or, you can also do the same job using 'colSums()' as shown in the below: > colSums(status=="I") 2010 2011 2012 344 > I hope this helps. Chel Hee Lee On 1/28/2015 7:31 PM, JSHuang wrote: Hi, I think you need quotation around I like the following: status 2010 2011 2012 1

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread Chel Hee Lee
I like Jeff's comments on the previous post. Regarding Alan's question, please see the following example. > df.1 <- data.frame(v1=1:5, v2=letters[1:5]) > df.2 <- data.frame(v1=LETTERS[1:3], v2=11:13) > DFName <- ls(pattern = glob2rx("df.*"))[1] > DFName [1] "df.1" > length(DFName[,1]) Error in D

[R] Problem defining a grid in adehabitatHR (kernelUD)

2015-01-29 Thread David Villegas Ríos
Hi all, I'm trying to estimate a HR area for several individuals using kernelUD and kernel.area in adehabitatHR library. My code is: library(adehabitatHR) h=50 kud=kernelUD(detections[,1],h=h,grid=grid,extent=extent,kern=c("bivnorm")) area=kernel.area(kud,percent=95,unin ="m",unout="km2

Re: [R] corrupted double-linked list

2015-01-29 Thread Göran Broström
On 2015-01-29 12:42, Duncan Murdoch wrote: On 29/01/2015 6:24 AM, Göran Broström wrote: Hello, A weird thing happened to me while I was playing around in the R console with a data frame ('fert'). The finale was - > with(fert[fert$parity ==

Re: [R] Error in help files connection

2015-01-29 Thread Duncan Murdoch
On 29/01/2015 7:09 AM, Axel Urbiz wrote: > Hello, > > I'm building a package on Mac OS. The build/check/install goes all ok. > Also, the package gets loaded properly with library("my_package"). > > However, when I call the help file for a given function in the package -- > i.e., "?my_function", I

[R] Error in help files connection

2015-01-29 Thread Axel Urbiz
Hello, I'm building a package on Mac OS. The build/check/install goes all ok. Also, the package gets loaded properly with library("my_package"). However, when I call the help file for a given function in the package -- i.e., "?my_function", I get the following error: "Error in gzfile(file, "rb")

Re: [R] Prediction of response after glm on whitened data

2015-01-29 Thread Xochitl CORMON
Thanks Thierry for your quick answer. Indeed this simplifies a lot my method so I decided to apply it. However I will be curious to check in which extend the coefficients obtained with the gls function are similar to the ones obtained using glm and whitening. It seems to me thant the method ar

Re: [R] corrupted double-linked list

2015-01-29 Thread Duncan Murdoch
On 29/01/2015 6:24 AM, Göran Broström wrote: > Hello, > > A weird thing happened to me while I was playing around in the R console > with a data frame ('fert'). The finale was > > - > > with(fert[fert$parity == 4, ], table(age, event)) >

Re: [R] create a function with "subset" statement

2015-01-29 Thread S Ellison
> -Original Message- > subsets<-list(B="(A[,1] %in% c(1,2) & A[,2] %in% c(1,2)) | (A[,1] %in% > c(3) & A[,2] %in% c(1)) | (A[,1] %in% c(4) & A[,2] %in% c(1:4))", C="(A[,1] > %in% > c(1:4) & A[,2] %in% c(1,2))", D="(A[,1] %in% c(1,2) & A[,2] %in% c(1:3)) | > (A[,1] > %in% c(3) & A[,2]

[R] corrupted double-linked list

2015-01-29 Thread Göran Broström
Hello, A weird thing happened to me while I was playing around in the R console with a data frame ('fert'). The finale was - > with(fert[fert$parity == 4, ], table(age, event)) event age 0 1 2 (14,20] 0 0 0 (20,

Re: [R] Passing a Data Frame Name as a Variable in a Function

2015-01-29 Thread peter dalgaard
On 29 Jan 2015, at 07:34 , Jeff Newmiller wrote: > This approach is fraught with dangers. > > I recommend that you put all of those data frames into a list and have your > function accept the list and the name and use the list indexing operator > mylist[[DFName]] to refer to it. Having functi