Search
 
SCRIPT & CODE EXAMPLE
 

R

r alluvial chart with NA

data(vaccinations)
levels(vaccinations$response) <- rev(levels(vaccinations$response))
ggplot(vaccinations,
       aes(x = survey, stratum = response, alluvium = subject,
           y = freq,
           fill = response, label = response)) +
  scale_x_discrete(expand = c(.1, .1)) +
  geom_flow() +
  geom_stratum(alpha = .5) +
  geom_text(stat = "stratum", size = 3) +
  theme(legend.position = "none") +
  ggtitle("vaccination survey responses at three points in time")
Comment

r alluvial chart with NA

ggplot(as.data.frame(Titanic),
       aes(y = Freq,
           axis1 = Survived, axis2 = Sex, axis3 = Class)) +
  geom_alluvium(aes(fill = Class),
                width = 0, knot.pos = 0, reverse = FALSE) +
  guides(fill = FALSE) +
  geom_stratum(width = 1/8, reverse = FALSE) +
  geom_text(stat = "stratum", aes(label = after_stat(stratum)),
            reverse = FALSE) +
  scale_x_continuous(breaks = 1:3, labels = c("Survived", "Sex", "Class")) +
  coord_flip() +
  ggtitle("Titanic survival by class and sex")
Comment

r alluvial chart with NA

data(majors)
majors$curriculum <- as.factor(majors$curriculum)
ggplot(majors,
       aes(x = semester, stratum = curriculum, alluvium = student,
           fill = curriculum, label = curriculum)) +
  scale_fill_brewer(type = "qual", palette = "Set2") +
  geom_flow(stat = "alluvium", lode.guidance = "frontback",
            color = "darkgray") +
  geom_stratum() +
  theme(legend.position = "bottom") +
  ggtitle("student curricula across several semesters")
Comment

PREVIOUS NEXT
Code Example
R :: r rename column 
Rust :: rust reverse range 
Rust :: rust get command line arguments 
Rust :: rust reverse for loop 
Rust :: bevy bundles 
Rust :: how to read from stdin rust 
Rust :: rust get items in a list with index and value 
Rust :: get length of string rust 
Rust :: rust setup in vim 
Rust :: rust string contains 
Rust :: read line rust 
Rust :: rust vec to array 
Rust :: armanriazi•rust•error 
Rust :: count matches with regex 
Rust :: string and str to string rust 
Rust :: armanriazi•rust•box•vs•refcell 
Rust :: armanriazi•rust•error•[E0040]: explicit use of destructor method 
Rust :: armanriazi•rust•error•E0502•cannot borrow `s` as mutable because it is also borrowed as immutable 
Rust :: armanriazi•rust•error•E0615•attempted to take value of method `collect` on type 
Rust :: armanriazi•rust•borrowchecker•lifetime•struct 
Rust :: rust error: failed to run custom build command for python3-sys 
Lua :: lua string.split 
Lua :: lua click detection 
Lua :: roblox loop players 
Lua :: roblox studio color randomizer 
Lua :: lua add 1 to a variable 
Lua :: What is transparency in roblox 
Lua :: roblox studio rain 
Lua :: ex: CFrame to vector3 roblox lua 
Lua :: roblox create part script 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =