Open akrowe20 opened 1 year ago
This is (probably) standard R – you don't give details which prediction plots you have. However, the R default is to order factor levels alphabetically. You can change this default using argument levels
in factor()
command:
> fact <- factor(rep(c("bad","good"), 3))
> fact
[1] bad good bad good bad good
Levels: bad good # alphabetical
> fact <- factor(fact, levels=c("good","bad"))
> fact
[1] bad good bad good bad good
Levels: good bad # order changed with levels argument, data unchanged
For temporal factor, you may also consider ordered factors which you can get with argument ordered = TRUE
in factor()
. There are a plenty of examples in help(factor)
and R introductory guides. However, changing temporal factor to ordered will display the presentation of results: instead of single factor levels, the results will be given as a linear trend + quadratic + cubic + more complex. You may not want this, but in some cases this can be useful.
Thank you. I am working in this part of the code. Is there a way to change this in the prediction code, or do I have to go back to the defining models step to change this? For example, I am working in this part of the code. Can I change the order in the env.list settings?
trait.list = NULL #community weighted mean shown for all traits
##################################################################################################
##################################################################################################
##################################################################################################
##################################################################################################
species.list = list(1,2,3, 4, 5, 6) species.list[[1]] = 1:5 #options for selecting all species in results species.list[[2]] = 1:5 species.list[[3]]=1:5 species.list[[4]]=1:5 species.list[[5]]=1:5 species.list[[6]]=1:5
env.list = list(1,2,3,4,5,6) env.list[[1]] = c("month", "humidity", "transectid","month"= relevel("month","december", "january", "february", "march", "april", "may", "june")) env.list[[2]] = c("month", "humidity", "transectid","month"= relevel("month","december", "january", "february", "march", "april", "may", "june")) env.list[[3]] = c("month", "temp", "transectid", "month"= relevel("month","december", "january", "february", "march", "april", "may", "june")) env.list[[4]] = c("month", "temp", "transectid", "month"= relevel("month","december", "january", "february", "march", "april", "may", "june")) env.list[[5]] =c("month", "lumavg", "transectid", "month"= relevel("month","december", "january", "february", "march", "april", "may", "june")) env.list[[6]] = c("month", "lumavg", "transectid", "month"= relevel("month","december", "january", "february", "march", "april", "may", "june"))
Hello, I am working off of the scripts provided in the courses. Is there a way to change the order that categories are listed in the x axis of the prediction plots? One of my fixed effects is month, and I would like my prediction plots to show the temporal order, whereas right now it is showing alphabetical order. Thanks! Amanda