# NOT RUN {
# Data on publications from U.S. institutions
data(us_pub_econ)
# 0) Let's set a dictionary for a better display of variables
setFplot_dict(c(institution = "U.S. Institution", jnl_top_25p = "Top 25% Pub.",
jnl_top_5p = "Top 5% Pub.", Frequency = "Publications"))
# 1) Let's plot the distribution of publications by institutions:
plot_distr(~institution, us_pub_econ)
# When there is only the variable, you can use a vector instead:
plot_distr(us_pub_econ$institution)
# 2) Now the production of institution weighted by journal quality
plot_distr(jnl_top_5p ~ institution, us_pub_econ)
# You can plot several variables:
plot_distr(1 + jnl_top_25p + jnl_top_5p ~ institution, us_pub_econ)
# 3) Let's plot the journal distribution for the top 3 institutions
# We can get the data from the previous graph
graph_data = plot_distr(jnl_top_5p ~ institution, us_pub_econ, plot = FALSE)
# And then select the top universities
top3_instit = graph_data$x[1:3]
top5_instit = graph_data$x[1:5] # we'll use it later
# Now the distribution of journals
plot_distr(~ journal | institution, us_pub_econ[institution %in% top3_instit])
# Alternatively, you can use the argument mod.select:
plot_distr(~ journal | institution, us_pub_econ, mod.select = top3_instit)
# 3') Same graph as before with "other" column, 5 institutions
plot_distr(~ journal | institution, us_pub_econ,
mod.select = top5_instit, other = TRUE)
#
# Example with continuous data
#
# regular histogram
plot_distr(iris$Sepal.Length)
# now splitting by species:
plot_distr(~ Sepal.Length | Species, iris)
# idem but the three distr. are separated:
plot_distr(~ Sepal.Length | Species, iris, mod.method = "split")
# Now the three are stacked
plot_distr(~ Sepal.Length | Species, iris, mod.method = "stack")
# }
Run the code above in your browser using DataLab