In is_lodes_form( : Missing id-axis pairings.

# Assume 'g' is the previous plot object saved under a variable
newdat <- layer_data(g)
newdat <- newdat[newdat$side == "start", ]
split <- split(newdat, interaction(newdat$stratum, newdat$x))
split <- lapply(split, function(dat) {
  dat$label <- dat$label / sum(dat$label)
  dat
})
newdat <- do.call(rbind, split)

ggplot(vaccinations,
       aes(x = survey, stratum = response, alluvium = subject,
           y = freq,
           fill = response, label = freq)) +
  scale_x_discrete(expand = c(.1, .1)) +
  geom_flow() +
  geom_stratum(alpha = .5) +
  geom_text(stat = "stratum", size = 3) +
  geom_text(data = newdat, aes(x = xmin + 0.4, y = y, label = format(label, digits = 1)),
            inherit.aes = FALSE) +
  theme(legend.position = "bottom") +
  ggtitle("vaccination survey responses at three points in time")

4
7
Bloodrust 100 points

                                    A_col &lt;- &quot;firebrick3&quot;
B_col &lt;- &quot;darkorange&quot;
C_col &lt;- &quot;deepskyblue3&quot;
alpha &lt;- 0.7

ggplot(fb_ad_3d,
       aes(weight = freq, axis1 = Category, axis2 = Response)) +
  geom_alluvium(aes(fill = Response, color = Response), 
                width = 1/12, alpha = alpha, knot.pos = 0.4) +
  geom_stratum(width = 1/6, color = &quot;grey&quot;) +
  geom_label(stat = &quot;stratum&quot;, label.strata = TRUE) +
  scale_x_continuous(breaks = 1:2, labels = c(&quot;Category&quot;, &quot;Response&quot;))     +
  scale_fill_manual(values  = c(A_col, B_col, C_col)) +
  scale_color_manual(values = c(A_col, B_col, C_col)) +
  ggtitle(&quot;Relevance of Facebook Custom List Advertising&quot;) +
  theme_minimal() +
  theme(
   axis.text.x = element_text(size = 12, face = &quot;bold&quot;)
  )

4 (8 Votes)
0
4.3
10
Nadia132 80 points

                                    library(dplyr)                                          # to manipulate data
library(alluvial)
allu &lt;- data %&gt;% 
        group_by(Diagnose1, Diagnose2, Diagnose3) %&gt;%   # grouping
        summarise(Freq = n())                           # adding frequencies

# here the plot
alluvial(allu[,1:3], freq=allu$Freq)

4.3 (10 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source