Hi, how are you?

I have the following truncated R code:

fileobs <- "MaxFloodDepth_Observed.txt"
file1 <- "MaxFloodDepth_1.txt"
file2 <- "MaxFloodDepth_2.txt"

...

file54 <- "MaxFloodDepth_54.txt"


observeddepth = as.matrix(read.ascii.grid(fileobs)$data)
observeddepth[observeddepth!=0]<-1

modeldepth1 = as.matrix(read.ascii.grid(file1)$data)
modeldepth1[modeldepth1!=0]<-1

modeldepth2 = as.matrix(read.ascii.grid(file2)$data)
modeldepth2[modeldepth2!=0]<-1

...

modeldepth54 = as.matrix(read.ascii.grid(file54)$data)
modeldepth54[modeldepth54!=0]<-1

Each modeldepth* and observeddepth is 272x976

f2 <- function(obs, dat){
obs <- as.logical(obs)
dat <- as.logical(dat)
s1 <- sum(obs & dat)
s2 <- sum(obs & !dat)
s3 <- sum(!obs & dat)
s1/(s1 + s2 + s3)
}

f2all <- f2(observeddepth, modeldepth[1:54]) # I am including the
"[1:54]" in the code to indicate that I want to compare the
observeddepth data to each of the modeldepth data files

modeldepth <- as.matrix(c(modeldepth1, modeldepth2, ... modeldepth54))

modeldepth <- modeldepth_index[, f2 > 0.7] # I want to end with
modeldepth that only lists the specific 272x976 modeldepth data files
that had an f2 greater than 0.7

Is there any way to reduce the code? As you see, I am using the name for
all 54 files with both file and also modeldepth.

How can I create an f2 for each of the 54 comparisons?

Thank-you.

Irucka Embry 


<span id=m2wTl><p><font face="Arial, Helvetica, sans-serif" size="2" 
style="font-size:13.5px">_______________________________________________________________<BR>Get
 the Free email that has everyone talking at <a href=http://www.mail2world.com 
target=new>http://www.mail2world.com</a><br>  <font color=#999999>Unlimited 
Email Storage &#150; POP3 &#150; Calendar &#150; SMS &#150; Translator &#150; 
Much More!</font></font></span>
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to