Difference between revisions of "Dynamic Documents And Word Clouds"

From Sean_Carver
Jump to: navigation, search
(Preliminaries (in class))
(Preliminaries (in class))
Line 45: Line 45:
 
* You need to associate your app with a website: http://www.seancarver.org/ is fine.
 
* You need to associate your app with a website: http://www.seancarver.org/ is fine.
  
* Leave "callbackURL" blank.
+
* Leave "Callback URL" blank.
  
* Now get the home page for your app.  Click on the tab at the top that says "Keys and Access Tokens."
+
* Agree to the "Developer Agreement."
 +
 
 +
* Click on "Create your twitter application"
 +
 
 +
* Now you get the home page for your app.  Click on the tab at the top that says "Keys and Access Tokens."

Revision as of 01:50, 15 November 2016

Dynamic Documents

In class, I pitched an idea for teaching you dynamic documents with word clouds.

What is a dynamic document? A dynamic document has text and possibly headings and other features, like bold and underline, lists, etc. But more importantly it accesses data (either by loading it from a file or in our case connecting to twitter and asking for it), then processes the data and derives summaries and figures to put in the document.

Dynamic documents are powerful.

Say you have data. You write a paper or report based on that data. Then you collect more data, or fix some problem with the data. If you write the dynamic document properly, when the data changes, all you have to do is press one button and all of the statistics and all of the figures get updated everywhere in the entire document.

If you had to update every statistic and every figure in the document, every time the data changed, this would take a long time and be prone to error. Dynamic documents are the way to go.

Word Clouds

I was inspired by the recent (2016) election to address the following question: what is going on with our culture? What better way to do that than to mine the twitter archive? There are many sophisticated techniques you could learn and it would take a whole career to stay on top of them. I wanted to create a dynamic document, easily customizable, which would graphically display some cultural information from twitter. After poking around with Google, I settled on a word cloud. A word cloud is a graphical display of the frequency of words, in this case, the frequency of words that appear in a random sample of tweets that satisfy certain search criteria. The more frequent the word, the larger it appears. Word clouds can code frequency with color, as well.

Preliminaries (before class)

  • If you haven't done so already, download and install the statistical software package "R". Some computers will say that R comes from a source that is untrusted. Don't worry about that. Millions of people have downloaded R with no problems.
  • Now download and install "R studio." Use the free desktop version.
  • Make sure R studio opens.

Preliminaries (in class)

  • You don't need this file, but in case you wanted to run a word cloud from the R console, you could use this file: Wcloud.R.
  • You do, however need the following file for both the dynamic document and the console program. My_access_template.R.
  • Once you have downloaded My_access_template.R, copy the file to a new file called my_access.R.
  • You need to edit my_access.R to put in the "passwords" that twitter gives you.
  • Click on "Create New App"
  • Put in a name for your application (no two people can have the application name).
  • Put in a description of your app: "Draws a word cloud!" is fine.
  • Leave "Callback URL" blank.
  • Agree to the "Developer Agreement."
  • Click on "Create your twitter application"
  • Now you get the home page for your app. Click on the tab at the top that says "Keys and Access Tokens."