0

I have a diabetes dataset which consist of different attributes that are labeled "Yes" and "No" etc. as shown in the picture

dataset example

enter image description here

Thus, how possibly generating a word cloud which represent the frequency of all the attributes could be done? appreciate your help!

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
  • 2
    Please don't post data as images. Take a look at how to make a [great reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for ways of showing data. – Martin Gal Aug 09 '21 at 21:26
  • 1
    Another question: "_a word cloud which represent the frequency_" Do you want a word cloud (with words with different sizes) or do you want a numerical representation of the frequency? – Martin Gal Aug 09 '21 at 21:42
  • I'm new to stack overflow; definitely there are better ways to show the data. I aim to represent the words with different sizes. thanks for your assist! – Mohammed Saeed Eshaq Aug 09 '21 at 21:56
  • You could use `dput(head(NameOfYourDataFrame))` and put the `structure()` output into your question. – Martin Gal Aug 09 '21 at 21:57

1 Answers1

0

You could try

library(wordcloud)
library(tidyr)
library(dplyr)

df %>%
  pivot_longer(-c(Age, Gender)) %>% 
  filter(value == "Yes") %>% 
  pull(name) %>% 
  wordcloud()

This should give a wordcloud. There are several arguments for formating (colors, fonts etc).

Martin Gal
  • 16,640
  • 5
  • 21
  • 39