[R] problem in for loop

Ivan Calandra ivan.calandra at uni-hamburg.de
Thu Feb 24 18:44:22 CET 2011


Hi,

It's FAQ 7.31
Try this:
mone <- round(m-mzero)

HTH,
Ivan

Le 2/24/2011 18:31, li li a écrit :
> Hi all.
>     I was having some trouble with a for loop and I found the problem is the
> following.
>     Does anyone have some idea why I got the following R result? Since mone
> is equal to 3, why
> mu1 only have 2 components?
>
>
> library(MASS)
>> p0<- seq(0.1, 0.9,by=0.1)
>> m<- 10
>>
>>
>> p0<- p0[7]
>>
>> ## data generation
>>
>> mzero<- p0*m
>> mone<- m-mzero
>> mu1<- rnorm(mone, 0,1)
>> mu<- c(rep(0,mzero), mu1)
>>
>> var<- diag(m)
>> zv<- mvrnorm(n, mu, var)
> Error in mvrnorm(n, mu, var) : incompatible arguments
>> mone
> [1] 3
>> mu1
> [1] -0.08802108  0.77904786
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php



More information about the R-help mailing list