-project.org
Subject: Re: [R] replace zero in a matrix using random numbers
?rnorm tells you that n, the first argument, is the number of
observations/random numbers you wish to generate. You asked for 1.
So you need to ask for the number of 0's, something like:
> a <- matrix(rep(0:1,
?rnorm tells you that n, the first argument, is the number of
observations/random numbers you wish to generate. You asked for 1.
So you need to ask for the number of 0's, something like:
> a <- matrix(rep(0:1, 3), nrow =3)
> a
[,1] [,2]
[1,]01
[2,]10
[3,]01
> a[!a] <-
Hello,
Try to get the number of zero values before:
i <- er.miRCounts == 0
n <- sum(i)
er.miRCounts[i] <- rnorm(n,mean=1, sd=0.1)
Also, there is no need for a end-of-instruction ';'.
The semi-colon is the instruction separator, so if you put it at the end
you will be separating the instructio
Hi R users,
I am analyzing miRNA sequence data for a special network analysis, I need to
replace zero values in a matrix as random numbers with mean of 1 and standard
deviation of 0.1.
er.miRCounts[er.miRCounts==0] <- rnorm(1,mean=1, sd=0.1);
this code made all zero values as 1.13, not random
4 matches
Mail list logo