Displaying 3 results from an estimated 3 matches for "farida".
Did you mean:
faria
2009 Dec 03
4
Replace values in a vector
Hi all,
I have a vector like this:
x<- c(0.7, 0.1, 0, 0.2, 0.2, 0, 0, 0 , 0, 0.4, 0, 0.8, 1.8)
I would like to replace the zero values with the first previous non zero value.
my returning vector should look like this:
y<-c( 0.7, 0.1, 0.1,0.2,0.2,0.2,0.2,0.2, 0.4, 0.4, 0.8, 1.8)
How can I do this in R without using for loop?
Thank you
2009 Dec 30
1
Removing replicated rows
...[6,] 6 1.0
[7,] 1 1.5
[8,] 1 1.5
[9,] 1 1.5
[10,] 4 2.0
[11,] 4 2.0
[12,] 3 2.5
[13,] 3 2.5
[14,] 3 2.5
m<-c(1,1,3,1,2)
> y
y1 y2
[1,] 2 0.5
[2,] 6 1.0
[3,] 1 1.5
[4,] 1 1.5
[5,] 1 1.5
[6,] 4 2.0
[7,] 3 2.5
[8,] 3 2.5
can anyone suggest the best way to do this?
Many thanks in advance,
Farida
[[alternative HTML version deleted]]
2010 Oct 06
1
replaces a matrix of "NA"s in an array with the previous matrix with numbers
Dear list,
Does anyone know if there is a function that replaces a matrix of "NA"s in
an array with the previous matrix with numbers? For example, I have an
array
ab <- array(dim=c(3,3,15),dimnames=list(rows=1:3,cols=1:3,dim=times)) .
Select out put from the array is:
, , dim = 0.478356969557745
cols
rows 1 2 3
1 0.4921053 0 0.5078947
2 0.0000000 0