-1

I am looking for coding examples in R or R-libraries to visualize words frequencies and relations in a network graph, very similar to this example: http://koaning.io/word-clouds.html (I refer not to the worldclouds, but to the network graph on the homepage)

So far I have cleaned the data and have about 1 million rows with clean text and calculated correlations and word frequencies.

I would highly appreciate if you can advise me and give me some tips on that.

All the best, René

Re Ne
  • 52
  • 5
  • Welcome to SO. Please hover over the R tag - it asks for a minimal reproducible example. [Here's a guide](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610); also look at the R help files (e.g. `?graph_from_edgelist`, _examples_ section). After that, edit & improve your question accordingly. A good one usually provides minimal input data, the desired output data, code tries incl required packages - all copy-paste-run'able in a new/clean R session. *Why?* It makes it easier for all to follow and participate without guesswork. – lukeA Jan 12 '17 at 09:37

1 Answers1

1

As a starter, consider for example:

library(quanteda)
library(igraph)
set.seed(1)
txt <- "I am looking for coding examples in R or R-libraries to visualize words frequencies and relations in a network graph, very similar to this example: http://koaning.io/word-clouds.html (I refer not to the worldclouds, but to the network graph on the homepage)

So far I have cleaned the data and have about 1 million rows with clean text and calculated correlations and word frequencies.

I would highly appreciate if you can advise me and give me some tips on that.

All the best, René"
plot(dfm(txt), min.freq=2L)

enter image description here

edges <- do.call(rbind, strsplit(tokenize(x=txt, ngrams=2L, conc="_")[[1]], "_"))
g <- graph_from_edgelist(edges, directed = FALSE)
g <- simplify(g)
plot(g, vertex.size=degree(g))

enter image description here

lukeA
  • 53,097
  • 5
  • 97
  • 100
  • Wow that is great. Thanks so much for your help lukeA! Much appreciated. Have a great day! – Re Ne Jan 14 '17 at 15:01