Irucka,

You should cc R-help on all correspondence so that other readers of the
list can follow the conversation.

(1)  You say that you need 0s and 1s rather than TRUE/FALSE.  Since a 0/1
matrix and TRUE/FALSE matrix behave exactly the same way in most
applications, I'm not sure why it would matter which one you had.

(2)  My mistake.  I had not noticed that you were eliminating the case
where both the observed and the modeled were FALSE.  I have modified my
code to give the same results as your f2 function.
compare.all <- sapply(modeldepth, function(md) mean((md==observeddepth)[md
| observeddepth]))

(3)  My mistake again.  There should be only single brackets, not double
brackets.
justbig <- modeldepth[compare.all > 0.7]

Jean



On Fri, Dec 21, 2012 at 11:27 AM, Irucka Embry <iruc...@mail2world.com>wrote:

>  Hi Jean Adams, how are you?
>
> I want to thank you for your response to my request for assistance.
>
> I received some assistance yesterday afternoon and I was able to update
> the code which is posted here:
> http://r.789695.n4.nabble.com/variable-names-in-numeric-list-and-Bayesian-inference-td4653674.html.
> I posted the new code with some new questions that I have with regards to
> the code that I have written. Can you look over that post and suggest any
> code revisions for those aspects that do not work? Thank-you.
>
> The code that you suggested worked well overall, except for 3 aspects of
> it:
>
> Here I actually needed the binary 0s and 1s rather than a TRUE/FALSE
> logical matrix
>
> # a function to read in the data as a matrix of logicals
> myreadfun <- function(file) {
> as.matrix(read.ascii.grid(file)$data)!=0
> }
>
> Here I needed to calculate the f2 probability rather than the mean
>
> compare.all <- sapply(modeldepths, function(md) mean(md==observeddepth))
> > str(compare.all)
> num [1:54] 0.936 0.94 0.944 0.944 0.945 ...
>
> Here most of the entries are greater than 0.7, but it should just be 31 of
> the 54 that are greater than 0.7
>
> > justbig <- modeldepths[[compare.all > 0.7]]
> Error in modeldepths[[compare.all > 0.7]] :
> recursive indexing failed at level 2
>
> Once again, thank-you for your assistance.
>
> Irucka Embry
>
>
> <-----Original Message----->
> >From: Adams, Jean [jvad...@usgs.gov]
> >Sent: 12/21/2012 10:32:54 AM
> >To: iruc...@mail2world.com
> >Cc: r-help@r-project.org
> >Subject: Re: [R] comparison of large data set
> >
> >Irucka,
> >
> >
> >I did not test this code out on any data, but I think it will work.
> >
> >
> >Jean
> >
> >
> >
> >
> ># a function to read in the data as a matrix of logicals
> >myreadfun <- function(file) {
> >as.matrix(read.ascii.grid(file)$data)!=0
> >}
> >
> >
> ># names of the 54 modeled depth files
> >modfiles <- paste0("MaxFloodDepth_", 1:54, ".txt")
> >
> >
> ># read in the observed and modeled depth files
> ># observeddepth is a matrix
> >observeddepth <- myreadfun("MaxFloodDepth_Observed.txt")
> >
> ># modeldepths is a list of matrices
> >modeldepths <- lapply(filenames, myreadfun)
> >
> >
> ># calculate the proportion of matrix elements that agree with the
> observed file
> ># the results is a vector with one number for each modeled depth matrix
> >compare.all <- sapply(modeldepths, function(md) mean(md==observeddepth))
> >
> >
> ># select just those matrices that had a large proportion of agreements
> ># justbig is a list of matrices
> >justbig <- modeldepths[[compare.all > 0.7]]
> >
> >______________________________________________
> >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.
>
> _______________________________________________________________
> Get the Free email that has everyone talking at http://www.mail2world.com
> Unlimited Email Storage – POP3 – Calendar – SMS – Translator – Much More!
>

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