Irucka Embry
2012-Dec-21 00:47 UTC
[R] variable names in numeric list and Bayesian inference
Hi everyone, I have received assistance from my previous post (comparison of large data set), but I still need some assistance. This is the revised code (along with some new code that I am requesting assistance with correcting): files <- paste0("MaxFloodDepth_", 1:54, ".txt") fileobs <- "MaxFloodDepth_Observed.txt" readfun <- function(x) { u <- as.matrix(read.ascii.grid(x)$data) u[u != 0] <- 1 u } observeddepth <- readfun(fileobs) modeldepth <- lapply(files, readfun) mynames <- function(x) { variable.names(modeldepth, prefix = "ModelDepth.") x } modeldepths <- lapply(modeldepth, mynames) # here the objective is to assign the name of ModelDepth1: ModelDepth54 for the 54 numeric entries in the modeldepths element to use this information in later steps. I need to know which ModelDepth element (1:54) is still relevant after I determine f2 for each of the 54 elements. I only want to keep those ModelDepth elements and their associated name. I am not getting any names added to the modeldepths, how do I get the names added to each set of 54 numeric entries in modeldepths? f2 <- function(obs, model){ obs <- as.logical(obs) model <- as.logical(model) s1 <- sum(obs & model) s2 <- sum(obs & !model) s3 <- sum(!obs & model) s1/(s1 + s2 + s3) } modeldepths <- lapply(modeldepths, function(x) f2(observeddepth, x)) modeldepthnew <- modeldepth[modeldepth > 0.7] # Here the objective is to pick the 31 of the 54 files (31 of the 54 elements have an f2 greater than 0.7) with their complete 272x976 cells because that information will then be used in the next step. The next step will be to perform a Bayesian inference where the modeldepthnew represents the prior likelihood. Are there any suggestions on a specific R package to use in the Bayesian inference steps? 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 – POP3 – Calendar – SMS – Translator – Much More!</font></font></span> [[alternative HTML version deleted]]