Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Title: Back to basics: High quality plots using base R graphics | |
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015 | |
### | |
### Date created: 20150418 | |
### Last updated: 20150423 | |
### | |
### Author: Michael Koontz | |
### Email: mikoontz@gmail.com | |
### Twitter: @michaeljkoontz | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A FIRST LOOK AT LAVAAN | |
## By Grace Charles, presented at Davis R Users' Group on May 15, 2015 | |
## adapted from Jim Grace's SEM workshop and Lavaan tutorials | |
# Set your working directory | |
setwd("~/Desktop/DAVIS/sem workshop") | |
###Load Libraries | |
library(lavaan) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myfunc <- function(x) { | |
x + 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(twitteR) | |
library(rlist) | |
library(pipeR) | |
library(stringi) | |
# Authenticate with twitter | |
# consumer/access keys and secrets for the twitter API must be defined elsewhere | |
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret) | |
# Get all my followers and followees |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conn <- textConnection("printed_output", "w", local = TRUE) | |
sink(conn, type=c("output")) | |
sink(conn, type=c("message")) | |
install.packages("ggplot2") | |
sink(NULL) | |
printed_output | |
# This will append the text to the printed_output variable, so clear it beforehand. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Install the Stylish extension for your browser, add this code | |
as a new Style, and apply it to the domain 'tweetdeck.twitter.com' */ | |
/* You can get Stylish here: */ | |
/* Safari - http://sobolev.us/stylish/ */ | |
/* Chrome - https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe */ | |
/* Tweet improvements, comments, or corrections to @mcnees. */ | |
/* ------------------------------------------------------------- */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Source the R code from an knitr file, optionally skipping plots | |
#' | |
#' @param file the knitr file to source | |
#' @param skip_plots whether to make plots. If TRUE (default) sets a null graphics device | |
#' | |
#' @return This function is called for its side effects | |
#' @export | |
source_rmd = function(file, skip_plots = TRUE) { | |
temp = tempfile(fileext=".R") | |
knitr::purl(file, output=temp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### Visualizing keystrokes using ggplot2 ##### | |
library(ggplot2) | |
# a character string to visualize: | |
string <- 'R is an integrated suite of software facilities for data manipulation, calculation and graphical display.' | |
# a data.frame representing the keys of a qwerty keyboard | |
qwerty <- data.frame( | |
id = 1:47, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpg | cyl | disp | hp | drat | wt | qsec | vs | am | gear | carb | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Mazda RX4 | 21 | 6 | 160 | 110 | 3.9 | 2.62 | 16.46 | 0 | 1 | 4 | 4 | |
Mazda RX4 Wag | 21 | 6 | 160 | 110 | 3.9 | 2.875 | 17.02 | 0 | 1 | 4 | 4 | |
Datsun 710 | 22.8 | 4 | 108 | 93 | 3.85 | 2.32 | 18.61 | 1 | 1 | 4 | 1 | |
Hornet 4 Drive | 21.4 | 6 | 258 | 110 | 3.08 | 3.215 | 19.44 | 1 | 0 | 3 | 1 | |
Hornet Sportabout | 18.7 | 8 | 360 | 175 | 3.15 | 3.44 | 17.02 | 0 | 0 | 3 | 2 | |
Valiant | 18.1 | 6 | 225 | 105 | 2.76 | 3.46 | 20.22 | 1 | 0 | 3 | 1 | |
Duster 360 | 14.3 | 8 | 360 | 245 | 3.21 | 3.57 | 15.84 | 0 | 0 | 3 | 4 | |
Merc 240D | 24.4 | 4 | 146.7 | 62 | 3.69 | 3.19 | 20 | 1 | 0 | 4 | 2 | |
Merc 230 | 22.8 | 4 | 140.8 | 95 | 3.92 | 3.15 | 22.9 | 1 | 0 | 4 | 2 |