Knut Krueger | 30 Jan 11:20 2015

digits in matrix

I have a matrix winth integer values after an arithmetic calulation
How can prevent the [1:3]1:3] part of the matrix to be converted to floats

data = matrix(c(1:16),nrow=4,ncol=4) #create matrix
data[4,] = data[4,]/3
data[,4] = data[,4]/3

Kind regards Knut

JSHuang | 30 Jan 02:34 2015

Re: Variables of a function called inside another one


  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 <- b+1
+ newc <- c+1
+ newd <- d+1
+ function2(a,newb,newc,newd)}
> function1(1:2,2:3,3:4,4:5)
[1] 13 17

View this message in context:
Sent from the R help mailing list archive at

Yan Wu | 30 Jan 00:41 2015

measure of goodness of fit for the model without an intercept


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!! 


	[[alternative HTML version deleted]]


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!! 


	[[alternative HTML version deleted]]

Lauren Meyer | 30 Jan 00:09 2015

df pseudoreplication in lme model

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 (YES, NO).
The variable we are assessing is the amount of toxin extracted (TOX1). Also,
some data is missing, and has already been removed.

Here is the model I am using and output:
model<- lme(TOX1~HOM*C18*CU, random=~1|PC/REP, data=Data4, method="ML")
Linear mixed-effects model fit by maximum likelihood
 Data: Data4
      AIC      BIC    logLik
  220.603 244.5213 -99.30151

Random effects:
 Formula: ~1 | PC
StdDev:    1.574392

 Formula: ~1 | REP %in% PC
         (Intercept)  Residual
StdDev: 0.0001356862 0.9724221

Fixed effects: TOX1 ~ HOM * C18 * CU
                        Value Std.Error DF   t-value p-value
(Intercept)          3.729044 0.8204586 48  4.545073  0.0000
HOMSON               0.423330 0.5175211 48  0.817995  0.4174
C18SML              -1.160060 0.5475120 48 -2.118784  0.0393
(Continue reading)

nevil amos | 30 Jan 05:26 2015

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


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 single command from a batch file  it works fine

however If I have  multiple lines in the batch file  eg:

"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 18
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 19
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 20
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 22
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 23
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 24
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 25
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 26
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 27
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 28
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 29
"C:\Program Files\R\R-3.1.0\bin\x64\Rscript.exe" myScript.R.R 30
it pauses after running the first line only.

How do I get all lines in this batch file to run sequentially?


(Continue reading)

Simon Kiss | 29 Jan 23:46 2015

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

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 actually
somehow calls the former.  Am I reading this wrong? Can someone explain the difference between the two functions?
Yours, Simon Kiss

John Fox | 29 Jan 23:09 2015

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

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.


> -----Original Message-----
> From: Krisztina Mosdossy [mailto:kriszmosdossy <at>]
> Sent: January-29-15 4:51 PM
> To: jfox <at>
> Subject: Re: [R] "effects" package issue for lme4's lmer()
> Hi John,
> Eureka! Apparently I'm set up to build R packages and the code worked.
> Thank you very much!
> -Krisz
> On Thu, Jan 29, 2015 at 4:29 PM, John Fox <jfox <at>> wrote:
> 	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.
(Continue reading)

C W | 29 Jan 22:02 2015

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

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 variable of interest, not x.

Thanks in advance,


	[[alternative HTML version deleted]]

Krisztina Mosdossy | 29 Jan 16:43 2015

"effects" package issue for lme4's lmer()

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 day. I am using R
version 3.1.2 (2014-10-31) -- "Pumpkin Helmet", lme4 package version 1.1-7,
effects package version 3.0-3 and lmerTest package version 2.0-20. I am
using a MacBook Pro OS 10.9.5.

I constructed my model using the lmer() function in the lme4 package as
well as the lmerTest() function:


Where "Duration" is a continuous response variable, while each fixed
explanatory variable is continuous and each random variable is categorical.
I scaled each continuous explanatory variable.

The problem I am having:




provides the lovely "wheel of death", my computer starts heating up and R
(Continue reading)

David L Carlson | 29 Jan 18:33 2015

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

Yes. I thought I was replying to a different message. Sorry.


-----Original Message-----
From: Chel Hee Lee [mailto:chl948 <at>] 
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 noticed that your personal conversation is on the 
R-help mailing list.

Chel Hee Lee, PhD

Biostatistician and Manager
Clinical Research Support Unit
College of Medicine
University of Saskatchewan

On 1/29/2015 11:28 AM, David L Carlson wrote:
> 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-bounces <at>] On Behalf Of Chel Hee Lee
(Continue reading)

David Villegas Ríos | 29 Jan 14:51 2015

Problem defining a grid in adehabitatHR (kernelUD)

Hi all,
I'm trying to estimate a HR area for several individuals using kernelUD and
kernel.area in adehabitatHR library.
My code is:


   area=kernel.area(kud,percent=95,unin ="m",unout="km2")

If I set for example grid=300 and extent=0.5, and same4all=TRUE, I get
apparently correct values. If I modify extent/grid, the output is pretty
much the same.

However I want to manually construct my grid based on a polygon delimited
by some coordinates that define the study area. Like this:


   # define the coordinates (all the detections fall inside the polygon)
   proj4string(loc) <- CRS("+proj=utm +zone=32")

   # create the raster

(Continue reading)