Skip to content

Commit

Permalink
Fixed issue 48: error loading mix data in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
brianstock committed Nov 19, 2015
1 parent 97ae77e commit 21a4f9a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
20 changes: 20 additions & 0 deletions R/build_mix_win.r
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,26 @@ btn_close <- gbutton(
if(svalue(hierarch_rad)==h_yes12) nested <- c(TRUE,FALSE)
visible(hierarch_win) <- FALSE
mixsiar$mix$fac_nested <- nested

if(mixsiar$mix$n.re==2 & mixsiar$mix$fac_nested[2]){
for(lev in 1:mixsiar$mix$FAC[[2]]$levels){
mixsiar$mix$FAC[[2]]$lookup[lev] <- mixsiar$mix$FAC[[1]]$values[which(mixsiar$mix$FAC[[2]]$values==lev)][1]
}
}
if(mixsiar$mix$n.re==2 & mixsiar$mix$fac_nested[1]){
for(lev in 1:mixsiar$mix$FAC[[1]]$levels){
mixsiar$mix$FAC[[1]]$lookup[lev] <- mixsiar$mix$FAC[[2]]$values[which(mixsiar$mix$FAC[[1]]$values==lev)][1]
}
}
if(mixsiar$mix$n.fe==1 & mixsiar$mix$n.re==1 & mixsiar$mix$fac_random[1]){ # make fac2 the random effect, fac1 the fixed effect
tmp <- mixsiar$mix$FAC[[1]]
mixsiar$mix$FAC[[1]] <- mixsiar$mix$FAC[[2]]
mixsiar$mix$FAC[[2]] <- tmp
mixsiar$mix$factors <- rev(mixsiar$mix$factors)
mixsiar$mix$fac_random <- rev(mixsiar$mix$fac_random)
mixsiar$mix$fac_nested <- rev(mixsiar$mix$fac_nested)
}

}
)
addSpring(hierarch_grp_all)
Expand Down
39 changes: 21 additions & 18 deletions R/load_mix_data.r
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# mix$fixed_effects vector of included fixed effects
# mix$n.effects number of random + fixed effects (n.re + n.fe)

# load_mix_data_script <- function(filename,iso_names,factors,fac_random,fac_nested,cont_effects){
load_mix_data <- function(filename,iso_names,random_effects,fixed_effects,cont_effects){
X <- read.csv(filename) # raw consumer data
n.iso <- length(iso_names) # number of isotopes
Expand Down Expand Up @@ -82,24 +83,26 @@ load_mix_data <- function(filename,iso_names,random_effects,fixed_effects,cont_e
re = fac_random[i],
name = fac_name)
}
if(n.re==2 & fac_nested[2]){
for(lev in 1:FAC[[2]]$levels){
FAC[[2]]$lookup[lev] <- FAC[[1]]$values[which(FAC[[2]]$values==lev)][1]
}
}
if(n.re==2 & fac_nested[1]){
for(lev in 1:FAC[[1]]$levels){
FAC[[1]]$lookup[lev] <- FAC[[2]]$values[which(FAC[[1]]$values==lev)][1]
}
}
if(n.fe==1 & n.re==1 & fac_random[1]){ # make fac2 the random effect, fac1 the fixed effect
tmp <- FAC[[1]]
FAC[[1]] <- FAC[[2]]
FAC[[2]] <- tmp
factors <- rev(factors)
fac_random <- rev(fac_random)
fac_nested <- rev(fac_nested)
}

# Moved to the Hierarchical question box, lines 184-200 in build_mix_win()
# if(n.re==2 & fac_nested[2]){
# for(lev in 1:FAC[[2]]$levels){
# FAC[[2]]$lookup[lev] <- FAC[[1]]$values[which(FAC[[2]]$values==lev)][1]
# }
# }
# if(n.re==2 & fac_nested[1]){
# for(lev in 1:FAC[[1]]$levels){
# FAC[[1]]$lookup[lev] <- FAC[[2]]$values[which(FAC[[1]]$values==lev)][1]
# }
# }
# if(n.fe==1 & n.re==1 & fac_random[1]){ # make fac2 the random effect, fac1 the fixed effect
# tmp <- FAC[[1]]
# FAC[[1]] <- FAC[[2]]
# FAC[[2]] <- tmp
# factors <- rev(factors)
# fac_random <- rev(fac_random)
# fac_nested <- rev(fac_nested)
# }
} # end random/fixed effects loop

CE_orig <- replicate(n.ce, NULL)
Expand Down
1 change: 1 addition & 0 deletions R/load_mix_data_script.r
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# mix$fixed_effects vector of included fixed effects
# mix$n.effects number of random + fixed effects (n.re + n.fe)

# load_mix_data <- function(filename,iso_names,random_effects,fixed_effects,cont_effects){
load_mix_data_script <- function(filename,iso_names,factors,fac_random,fac_nested,cont_effects){
X <- read.csv(filename) # raw consumer data
n.iso <- length(iso_names) # number of isotopes
Expand Down

0 comments on commit 21a4f9a

Please sign in to comment.