An extrapolation of this blog post.
This file contains hidden or 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
crayola <- structure(c("#EFDECD", "#CD9575", "#FDD9B5", "#78DBE2", "#87A96B", | |
"#FFA474", "#FAE7B5", "#9F8170", "#FD7C6E", "#000000", "#ACE5EE", | |
"#1F75FE", "#A2A2D0", "#6699CC", "#0D98BA", "#7366BD", "#DE5D83", | |
"#CB4154", "#B4674D", "#FF7F49", "#EA7E5D", "#B0B7C6", "#FFFF99", | |
"#1CD3A2", "#FFAACC", "#DD4492", "#1DACD6", "#BC5D58", "#DD9475", | |
"#9ACEEB", "#FFBCD9", "#FDDB6D", "#2B6CC4", "#EFCDB8", "#6E5160", | |
"#CEFF1D", "#71BC78", "#6DAE81", "#C364C5", "#CC6666", "#E7C697", | |
"#FCD975", "#A8E4A0", "#95918C", "#1CAC78", "#1164B4", "#F0E891", | |
"#FF1DCE", "#B2EC5D", "#5D76CB", "#CA3767", "#3BB08F", "#FEFE22", | |
"#FCB4D5", "#FFF44F", "#FFBD88", "#F664AF", "#AAF0D1", "#CD4A4C", |
This file contains hidden or 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(boot) | |
r2 = function(f, d, i) { | |
d = d[i, ] | |
f = lm(f, data = d) | |
return(summary(f)$r.square) | |
} | |
br <- boot(COI, r2, 10000, formula = nb.publis ~ nb.liens) | |
br | |
plot(br) | |
boot.ci(br, .95, "bca") |
This file contains hidden or 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
require(downloader) | |
# PJ example. | |
link = "https://raw.github.com/pedroj/bipartite_plots/master/data/NCH_quant_bmatrix.txt" | |
file = "data/NCH_quant_bmatrix.txt" | |
if(!file.exists(file)) download(link, file, mode = "wb") | |
M <- read.table(file, sep = "\t", dec = ",", header = TRUE, row.names = 1) | |
# | |
# Bipartite network initialization, starting from an adjacency matrix. |
This file contains hidden or 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
> # Get data for 2011 | |
> query <- c("cbt" = "'cognitive behavior therapy' OR 'cognitive behavioral therapy' OR 'cognitive therapy' AND 2011[DP]") | |
> pub.efetch <- searchPubmed(query) | |
Searching (downloading 1718 articles) | |
Completed download from PubMed. | |
> cbt_2011 <- extractJournal() | |
XML declaration allowed only at the start of the document | |
StartTag: invalid element name | |
Error: 1: XML declaration allowed only at the start of the document | |
2: StartTag: invalid element name |
This file contains hidden or 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 { color: #264EC0; } | |
b { color: #D22310; } | |
c { color: #FC8608; } | |
d { color: #168713; } | |
e { color: #850086; } | |
f { color: #1086B9; } | |
g { color: #D22B63; } | |
h { color: #559D05; } | |
i { color: #A71B23; } | |
j { color: #21436F; } |
Here are little chunks of R code to quickly access survey datasets. Some of the linked datasets are provided on an "as-is" basis: typically, you might want to check the official ANES files rather than rely on the extracts linked to below. This also applies to data extracts bundled in packages.
The code occasionally calls the download
and foreign
packages, respectively to get files from HTTPS sources and to deal with foreign formats. The Gelman and Hill replication also uses plyr
and ggplot2
, but check the original code for identical functions written in base R.
- Anthony J. Damico's
usgsd
repository of scripts for survey microdata analysis; ref.; [how it compares](https://github.com/ajd
This Gist is used to create the variable indexes in this package:
- Stata do-file to extract the variable labels
- R script to convert the files to R data frames.
- R script to create the demo datasets.
The scripts all worked in early August 2013.
Exceptions corrected by the do-file:
This file contains hidden or 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
------------------------------------------------------------------------------------ | |
name: srqm_demo | |
log: /Users/fr/Documents/Teaching/SRQM/demo.log | |
log type: text | |
opened on: 17 Aug 2013, 18:28:28 | |
. | |
. * Check setup. This line appears in every course do-file. It makes sure that | |
. * you have the appropriate files and packages to successfully run the code. | |
. run setup/require fre lookfor_all |