[R] help on matrix column removal based on another matrix results
iembry
iruckaE at mail2world.com
Mon Nov 19 15:30:55 CET 2012
Hi everyone, now I am trying to finish writing the code (I had asked for
assistance on subtracting arrays)
This is what I what I am running in R:
> source("/home/ie/Documents/TTU/GA_Research/GLUE/R-Project/R_GLUE_Example/NSEr.R")
NSEr <- function (obs, sim)
{
{jjh <- (as.vector(obs) - sim)^2
Xjjhs <- apply(Xjjh, 2, sum)
Yii <- (obs - mean(obs))^2
Yiis <- apply(Yii, 2, sum)
NSEr <- 1 - (Xjjhs/Yiis)
}
NSEr}
> Vsim <- read.csv("1000Samples_Vsim.csv", header = TRUE, sep =",")
> Vsim <- as.matrix(Vsim[,-1]) # remove column 1 from analysis
> Vobs <- read.csv("Observed_Flow.csv", header = TRUE, sep =",")
> Vobs <- as.matrix(Vobs[,-1]) # remove column 1 from analysis
> NSEr <- NSEr(Vobs,Vsim);
> write.table(NSEr, "NSEr.csv", sep =",")
> NSErr <- t(matrix(NSEr))
> ## select the behavioural simulations and discard the rest
> Vsim <- Vsim[NSErr > 0.6]
> write.table(Vsim, "Vsim.csv", sep =",")
**Vsim becomes numeric[42016] rather than a double matrix of 101x416.
What is the proper way to remove the columns in Vsim where the NSEr for that
column is less than 0.6? I am trying to make Vsim a double matrix of
101x416.
Thank-you again.
Below is the rest of the code in R:
> ## normalise Qsim and compute the quantiles
> NSEr <- NSEr[NSEr > 0.6]
> write.table(NSEr, "NSEr_great_0.6.csv", sep =",")
> NSEr <- NSEr - 0.6
> write.table(NSEr, "NSEr_minus0.6.csv", sep =",")
> NSEr <- NSEr/sum(NSEr)
> write.table(NSEr, "NSEr_normalized.csv", sep =",")
> #NSEr = sum(NSEr)
> limits <- apply(Vsim, 1, "wtd.quantile", weights = NSEr, probs =
> c(0.05,0.95), normwt=F)
--
View this message in context: http://r.789695.n4.nabble.com/help-on-matrix-column-removal-based-on-another-matrix-results-tp4650043.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list