Articles by Johannes B. Gruber on Johannes B. Gruber

You R my Valentine!

February 13, 2019 | Johannes B. Gruber on Johannes B. Gruber

Today is Valentine’s Day. And since both I and my sweetheart are R enthusiasts, here is how to say “I love you” using a statistical programming language:
library("dplyr")
library("gganimate")
library("ggplot2")

hrt_dat <- data.frame(t = seq(0, 2 * pi, by = 0.01)) %>%
  bind_rows(data.frame(t = rep(max(.$t), 300))) %>% 
  mutate(xhrt = 16 * sin(t) ^ 3,
         yhrt = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t),
         frame = seq_along(t)) %>% 
  mutate(text = ifelse(frame > 300, "            J", "")) %>%
  mutate(text = ifelse(frame > 500, "A           J", text)) %>%
  mutate(text = ifelse(frame > 628, "A     +     J", text)) %>% 
  mutate(texty = 0, textx = 0)

ggplot(hrt_dat, aes(x = xhrt, y = yhrt)) +
  geom_line(colour = "#C8152B") +
  geom_polygon(fill = "#C8152B") +
  geom_text(aes(x = textx, y = texty, label = text), 
            size = 18, 
            colour = "white",
            vjust = "center") +
  theme_void() +
  transition_reveal(frame)
[Read more...]

You R my Valentine!

February 13, 2019 | Johannes B. Gruber on Johannes B. Gruber

Today is Valentine’s Day. And since both I and my sweetheart are R enthusiasts, here is how to say “I love you” using a statistical programming language:
library("dplyr")
library("gganimate")
library("ggplot2")

hrt_dat <- data.frame(t = seq(0, 2 * pi, by = 0.01)) %>%
  bind_rows(data.frame(t = rep(max(.$t), 300))) %>% 
  mutate(xhrt = 16 * sin(t) ^ 3,
         yhrt = 13 * cos(t) - 5 * cos(2 * t) - 2 * cos(3 * t) - cos(4 * t),
         frame = seq_along(t)) %>% 
  mutate(text = ifelse(frame > 300, "            J", "")) %>%
  mutate(text = ifelse(frame > 500, "A           J", text)) %>%
  mutate(text = ifelse(frame > 628, "A     +     J", text)) %>% 
  mutate(texty = 0, textx = 0)

ggplot(hrt_dat, aes(x = xhrt, y = yhrt)) +
  geom_line(colour = "#C8152B") +
  geom_polygon(fill = "#C8152B") +
  geom_text(aes(x = textx, y = texty, label = text), 
            size = 18, 
            colour = "white",
            vjust = "center") +
  theme_void() +
  transition_reveal(frame)
[Read more...]

Smarter Wordclouds

February 1, 2019 | Johannes B. Gruber on Johannes B. Gruber

Some time ago, I saw a presentation by Wouter van Atteveldt who showed that wordclouds aren’t necessarily stupid. I was amazed since wordclouds were one of the first things I ever did in R and they are still often shown in introductions to text analysis. But the way they ...
[Read more...]

Smarter Wordclouds

February 1, 2019 | Johannes B. Gruber on Johannes B. Gruber

Some time ago, I saw a presentation by Wouter van Atteveldt who showed that wordclouds aren’t necessarily stupid. I was amazed since wordclouds were one of the first things I ever did in R and they are still often shown in introductions to text analysis. But the way they ...
[Read more...]

Highly Similar Texts

May 16, 2018 | Johannes B. Gruber on Johannes B. Gruber

Available solutions: the accurate one Available solutions: the fast one Divide and conquer Implementation in LexisNexisTools A while ago I was building a database of newspaper articles retrieved from LexisNexis for a research project in which I was working as a research assistant. At some point we noticed that we ... [Read more...]

Highly Similar Texts

May 16, 2018 | Johannes B. Gruber on Johannes B. Gruber

A while ago I was building a database of newspaper articles retrieved from LexisNexis for a research project in which I was working as a research assistant. At some point we noticed that we seemed to have a lot of duplicates in our database. I had already removed the duplicates ... [Read more...]

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)