<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;D0MDQX09eCp7ImA9WhVbE0k.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680</id><updated>2012-05-30T12:37:50.360+10:00</updated><category term="qualitative research" /><category term="mediation" /><category term="data mining" /><category term="reproducible research" /><category term="path analysis" /><category term="general advice" /><category term="version_control" /><category term="measurement" /><category term="matrix algebra" /><category term="ggplot2" /><category term="method" /><category term="bayesian" /><category term="summary post" /><category term="make" /><category term="Australia" /><category term="academia" /><category term="psychology" /><category term="RSS" /><category term="binary variable" /><category term="multilevel" /><category term="I/O Psych" /><category term="Sweave" /><category term="personality" /><category term="reliability" /><category term="meta-analysis" /><category term="CFA" /><category term="vim" /><category term="normality" /><category term="data sharing" /><category term="probability" /><category term="repeated measures" /><category term="market research" /><category term="Beamer" /><category term="outliers" /><category term="experiments" /><category term="formatting" /><category term="moderation" /><category term="scales" /><category term="Word" /><category term="computers" /><category term="opinion" /><category term="software" /><category term="Eclipse" /><category term="APAStyle" /><category term="book review" /><category term="tetrachoric" /><category term="power" /><category term="job satisfaction" /><category term="interviews" /><category term="design" /><category term="regular expressions" /><category term="fun" /><category term="statistics" /><category term="validity" /><category term="social network analysis" /><category term="correlation" /><category term="blogging" /><category term="GEE" /><category term="reaction time" /><category term="Excel" /><category term="Twitter" /><category term="introduction" /><category term="cluster analysis" /><category term="discriminant function analysis" /><category term="BibTeX" /><category term="OpenMX" /><category term="bootstrapping" /><category term="polychoric" /><category term="factor analysis" /><category term="Inquisit" /><category term="jags" /><category term="tables" /><category term="SPSS" /><category term="Endnote" /><category term="SEM" /><category term="results" /><category term="nonlinear regression" /><category term="internet" /><category term="modelling" /><category term="causation" /><category term="JabRef" /><category term="Writing" /><category term="focus groups" /><category term="markup" /><category term="teaching" /><category term="ability" /><category term="skill acquisition" /><category term="presentations" /><category term="thinking" /><category term="linux" /><category term="dyads" /><category term="logistic regression" /><category term="descriptive statistics" /><category term="statistical consulting" /><category term="multiple regression" /><category term="Literate programming" /><category term="selection and recruitment" /><category term="programming" /><category term="random" /><category term="videos" /><category term="calculus" /><category term="WinEdt" /><category term="publishing" /><category term="basic analyses" /><category term="Jing" /><category term="literature review" /><category term="tests" /><category term="ordinal variables" /><category term="surveys" /><category term="Article Deconstruction" /><category term="StatET" /><category term="mathematics" /><category term="missing data" /><category term="references" /><category term="difference scores" /><category term="metadata" /><category term="LaTeX" /><category term="stackexchange" /><category term="sampling" /><category term="R" /><title>Jeromy Anglim's Blog: Psychology and Statistics</title><subtitle type="html">Posts on statistics, study design, statistical computing, R, and more with a focus on research applications in psychology.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://jeromyanglim.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>184</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/jeromyanglim" /><feedburner:info uri="jeromyanglim" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>jeromyanglim</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;AkUNQHg9eip7ImA9WhVUFE0.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-2816864127561801354</id><published>2012-05-18T21:22:00.000+10:00</published><updated>2012-05-19T16:18:11.662+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-19T16:18:11.662+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="reproducible research" /><category scheme="http://www.blogger.com/atom/ns#" term="markup" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Example Reproducible Report using R Markdown:  Analysis of California Schools Test Data</title><content type="html">&lt;p&gt;This is a quick set of analyses of the California Test Score dataset.  The post was produced using R Markdown in RStudio 0.96.  The main purpose of this post is to provide a case study of using R Markdown to prepare a quick reproducible report.  It provides examples of using plots, output, in-line R code, and markdown. The post is designed to be read along side the &lt;a href="https://gist.github.com/2724711"&gt;R Markdown source code, which is available as a gist on github&lt;/a&gt;. &lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Preliminaries&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;This post builds on my earlier post which provided a guide for &lt;a href="http://jeromyanglim.blogspot.com/2012/05/getting-started-with-r-markdown-knitr.html"&gt;Getting Started with R Markdown, knitr, and RStudio 0.96&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The dataset analysed comes from the &lt;code&gt;AER&lt;/code&gt; package which is an accompaniment to the book &lt;a href="http://www.amazon.com/Applied-Econometrics-R-Use/dp/0387773169"&gt;Applied Econometrics with R&lt;/a&gt; written by &lt;a href="http://wwz.unibas.ch/personen/profil/person/kleiber/"&gt;Christian Kleiber&lt;/a&gt; and &lt;a href="http://eeecon.uibk.ac.at/%7Ezeileis/"&gt;Achim Zeileis&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Load packages and data&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;# if necessary uncomment and install packages.  install.packages(&amp;#39;AER&amp;#39;)
# install.packages(&amp;#39;psych&amp;#39;) install.packages(&amp;#39;Hmisc&amp;#39;)
# install.packages(&amp;#39;ggplot2&amp;#39;) install.packages(&amp;#39;relaimpo&amp;#39;)
library(AER)  # interesting datasets
library(psych)  # describe and psych.panels
library(Hmisc)  # describe
library(ggplot2)  # plots: ggplot and qplot
library(relaimpo)  # relative importance in regression
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;# load the California Schools Dataset and give the dataset a shorter name
data(CASchools)
cas &amp;lt;- CASchools

# Convert grade to numeric

# table(cas$grades)
cas$gradesN &lt;- cas$grades == &amp;quot;KK-08&amp;quot;

# Get the set of numeric variables
v &amp;lt;- setdiff(names(cas), c(&amp;quot;district&amp;quot;, &amp;quot;school&amp;quot;, &amp;quot;county&amp;quot;, &amp;quot;grades&amp;quot;))
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Q 1 What does the CASchools dataset involve?&lt;/h3&gt;

&lt;p&gt;Quoting the help (i.e., &lt;code&gt;?CASchools&lt;/code&gt;), the data is &amp;ldquo;from all 420 K-6 and K-8 districts in California with data available for 1998 and 1999&amp;rdquo; and the variables are:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;* district: character. District code.
* school: character. School name.
* county: factor indicating county.
* grades: factor indicating grade span of district.
* students: Total enrollment.
* teachers: Number of teachers.
* calworks: Percent qualifying for CalWorks (income assistance).
* lunch: Percent qualifying for reduced-price lunch.
* computer: Number of computers.
* expenditure: Expenditure per student.
* income: District average income (in USD 1,000).
* english: Percent of English learners.
* read: Average reading score.
* math: Average math score.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let&amp;#39;s look at the basic structure of the data frame. i.e., the number of observations and the types of values:&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;str(cas)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## &amp;#39;data.frame&amp;#39;:    420 obs. of  15 variables:
##  $ district   : chr  &amp;quot;75119&amp;quot; &amp;quot;61499&amp;quot; &amp;quot;61549&amp;quot; &amp;quot;61457&amp;quot; ...
##  $ school     : chr  &amp;quot;Sunol Glen Unified&amp;quot; &amp;quot;Manzanita Elementary&amp;quot; &amp;quot;Thermalito Union Elementary&amp;quot; &amp;quot;Golden Feather Union Elementary&amp;quot; ...
##  $ county     : Factor w/ 45 levels &amp;quot;Alameda&amp;quot;,&amp;quot;Butte&amp;quot;,..: 1 2 2 2 2 6 29 11 6 25 ...
##  $ grades     : Factor w/ 2 levels &amp;quot;KK-06&amp;quot;,&amp;quot;KK-08&amp;quot;: 2 2 2 2 2 2 2 2 2 1 ...
##  $ students   : num  195 240 1550 243 1335 ...
##  $ teachers   : num  10.9 11.1 82.9 14 71.5 ...
##  $ calworks   : num  0.51 15.42 55.03 36.48 33.11 ...
##  $ lunch      : num  2.04 47.92 76.32 77.05 78.43 ...
##  $ computer   : num  67 101 169 85 171 25 28 66 35 0 ...
##  $ expenditure: num  6385 5099 5502 7102 5236 ...
##  $ income     : num  22.69 9.82 8.98 8.98 9.08 ...
##  $ english    : num  0 4.58 30 0 13.86 ...
##  $ read       : num  692 660 636 652 642 ...
##  $ math       : num  690 662 651 644 640 ...
##  $ gradesN    : logi  TRUE TRUE TRUE TRUE TRUE TRUE ...
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;# Hmisc::describe(cas) # For more extensive summary statistics
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Q. 2  To what extent does expenditure per student vary?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;qplot(expenditure, data = cas) + xlim(0, 8000) + xlab(&amp;quot;Money spent per student ($)&amp;quot;) + 
    ylab(&amp;quot;Count of schools&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/EVAg2.png" alt="plot of chunk cas2"/&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;
round(t(psych::describe(cas$expenditure)), 1)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##            [,1]
## var         1.0
## n         420.0
## mean     5312.4
## sd        633.9
## median   5214.5
## trimmed  5252.9
## mad       487.2
## min      3926.1
## max      7711.5
## range    3785.4
## skew        1.1
## kurtosis    1.9
## se         30.9
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The greatest expenditure per student is around double that of the least expenditure  per student.&lt;/p&gt;

&lt;h3&gt;Q. 3a  What predicts expenditure per student?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;# Compute and format set of correlations
corExp &amp;lt;- cor(cas[&amp;quot;expenditure&amp;quot;], cas[setdiff(v, &amp;quot;expenditure&amp;quot;)])
corExp &amp;lt;- round(t(corExp), 2)
corExp[order(corExp[, 1], decreasing = TRUE), , drop = FALSE]
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##          expenditure
## income          0.31
## read            0.22
## math            0.15
## calworks        0.07
## lunch          -0.06
## computer       -0.07
## english        -0.07
## teachers       -0.10
## students       -0.11
## gradesN        -0.17
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;More is spent per student in schools :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;where people with greater incomes live&lt;/li&gt;
&lt;li&gt;reading scores are higher&lt;/li&gt;
&lt;li&gt;that are K-6&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Q. 4  what is the relationship between district level maths and reading scores?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;ggplot(cas, aes(read, math)) + geom_point() + geom_smooth()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/RDniX.png" alt="plot of chunk cas4"/&gt; &lt;/p&gt;

&lt;p&gt;At the district level, the correlation is very strong (r = The correlation is &lt;code&gt;0.92&lt;/code&gt;). From prior experience I&amp;#39;d expect correlations at the individual-level in the .3 to .6 range.  Thus, these results are consistent with group-level relationships  being much larger than individual-level relationships.&lt;/p&gt;

&lt;h3&gt;Q. 5 What is the relationship between maths and reading after partialling out other effects?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;# command has strange syntax requiring column numbers rather than variable
# names
partial.r(cas[v], c(which(names(cas[v]) == &amp;quot;read&amp;quot;), which(names(cas[v]) == 
    &amp;quot;math&amp;quot;)), which(!names(cas[v]) %in% c(&amp;quot;read&amp;quot;, &amp;quot;math&amp;quot;)))
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## partial correlations 
##      read math
## read 1.00 0.72
## math 0.72 1.00
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The partial correlation is still very strong but is substantially reduced.&lt;/p&gt;

&lt;h3&gt;Q. 6 What fraction of a computer does each student have?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;cas$compstud &lt;- cas$computer/cas$students
describe(cas$compstud)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## cas$compstud 
##       n missing  unique    Mean     .05     .10     .25     .50     .75 
##     420       0     412  0.1359 0.05471 0.06654 0.09377 0.12546 0.16447 
##     .90     .95 
## 0.22494 0.24906 
## 
## lowest : 0.00000 0.01455 0.02266 0.02548 0.04167
## highest: 0.32770 0.34359 0.34979 0.35897 0.42083 
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;qplot(compstud, data = cas)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## stat_bin: binwidth defaulted to range/30. Use &amp;#39;binwidth = x&amp;#39; to adjust this.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/SEbj0.png" alt="plot of chunk unnamed-chunk-4"/&gt; &lt;/p&gt;

&lt;p&gt;The mean number of computers per student is &lt;code&gt;0.136&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;Q. 7 What is a good model of the combined effect of other variables on academic performance (i.e., math and read)?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;# Examine correlations between variables
psych::pairs.panels(cas[v])
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/FeULR.png" alt="plot of chunk cas7"/&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;pairs.panels&lt;/code&gt; shows correlations in the upper triangle, scatterplots in the lower triangle, and variable names and distributions on the main diagonal.&lt;br/&gt;
After examining the plot several ideas emerge.&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;# (a) students is a count and could be log transformed
cas$studentsLog &lt;- log(cas$students)

# (b) teachers is not the variable of interest:
#   it is the number of students per teacher
cas$studteach &lt;- cas$students /cas$teachers
# (c) computers is not the variable of interest:
#  it is the ratio of computers to students
# table(cas$computer==0) 
# Note some schools have no computers so ratio would be problematic.
# Take percentage of a computer instead
cas$compstud &lt;- cas$computer / cas$students 

# (d) math and reading are correlated highly, reduce to one variable
cas$performance &amp;lt;- as.numeric(
        scale(scale(cas$read) + scale(cas$math)))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Normally, I&amp;#39;d add all these transformations to an initial data transformation file that I call in the first block, but for the sake of the narrative, I&amp;#39;ll leave them here.&lt;/p&gt;

&lt;p&gt;Let&amp;#39;s examine correlations between predictors and outcome.&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;m1cor &amp;lt;- cor(cas$performance, cas[c(&amp;quot;studentsLog&amp;quot;, &amp;quot;studteach&amp;quot;, &amp;quot;calworks&amp;quot;, 
    &amp;quot;lunch&amp;quot;, &amp;quot;compstud&amp;quot;, &amp;quot;income&amp;quot;, &amp;quot;expenditure&amp;quot;, &amp;quot;gradesN&amp;quot;)])
t(round(m1cor, 2))
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##              [,1]
## studentsLog -0.12
## studteach   -0.23
## calworks    -0.63
## lunch       -0.87
## compstud     0.27
## income       0.71
## expenditure  0.19
## gradesN     -0.16
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let&amp;#39;s examine the multiple regression.&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;m1 &amp;lt;- lm(performance ~ studentsLog + studteach + calworks + lunch + 
    compstud + income + expenditure + grades, data = cas)
summary(m1)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## 
## Call:
## lm(formula = performance ~ studentsLog + studteach + calworks + 
##     lunch + compstud + income + expenditure + grades, data = cas)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8107 -0.2963 -0.0118  0.2712  1.5662 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(&amp;gt;|t|)    
## (Intercept)  8.99e-01   4.98e-01    1.80    0.072 .  
## studentsLog -3.83e-02   1.91e-02   -2.01    0.045 *  
## studteach   -1.11e-02   1.59e-02   -0.70    0.487    
## calworks     1.96e-03   2.96e-03    0.66    0.508    
## lunch       -2.65e-02   1.48e-03  -17.97  &amp;lt; 2e-16 ***
## compstud     7.88e-01   3.86e-01    2.04    0.042 *  
## income       2.82e-02   4.89e-03    5.77  1.6e-08 ***
## expenditure  5.87e-05   4.90e-05    1.20    0.232    
## gradesKK-08 -1.21e-01   6.49e-02   -1.87    0.062 .  
## ---
## Signif. codes:  0 &amp;#39;***&amp;#39; 0.001 &amp;#39;**&amp;#39; 0.01 &amp;#39;*&amp;#39; 0.05 &amp;#39;.&amp;#39; 0.1 &amp;#39; &amp;#39; 1 
## 
## Residual standard error: 0.457 on 411 degrees of freedom
## Multiple R-squared: 0.795,   Adjusted R-squared: 0.791 
## F-statistic:  199 on 8 and 411 DF,  p-value: &amp;lt;2e-16 
## 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And some indicators of predictor relative importance.&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;# calc.relimp from relaimpo package.
(m1relaimpo &amp;lt;- calc.relimp(m1, type = &amp;quot;lmg&amp;quot;, rela = TRUE))
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## Response variable: performance 
## Total response variance: 1 
## Analysis based on 420 observations 
## 
## 8 Regressors: 
## studentsLog studteach calworks lunch compstud income expenditure grades 
## Proportion of variance explained by model: 79.48%
## Metrics are normalized to sum to 100% (rela=TRUE). 
## 
## Relative importance metrics: 
## 
##                  lmg
## studentsLog 0.009973
## studteach   0.016695
## calworks    0.177666
## lunch       0.492866
## compstud    0.025815
## income      0.251769
## expenditure 0.014785
## grades      0.010432
## 
## Average coefficients for different model sizes: 
## 
##                   1X        2Xs        3Xs        4Xs        5Xs
## studentsLog -0.08771 -0.0650133 -0.0558756 -0.0519312 -4.926e-02
## studteach   -0.11918 -0.0861199 -0.0629499 -0.0462155 -3.372e-02
## calworks    -0.05473 -0.0427576 -0.0324658 -0.0233760 -1.535e-02
## lunch       -0.03199 -0.0310310 -0.0301497 -0.0293300 -2.856e-02
## compstud     4.15870  3.0673338  2.2639604  1.6844348  1.287e+00
## income       0.09860  0.0850555  0.0726892  0.0614726  5.140e-02
## expenditure  0.00030  0.0001986  0.0001374  0.0001013  8.061e-05
## grades      -0.45677 -0.3345683 -0.2529014 -0.1981200 -1.628e-01
##                    6Xs        7Xs        8Xs
## studentsLog -4.626e-02 -4.252e-02 -3.833e-02
## studteach   -2.418e-02 -1.687e-02 -1.109e-02
## calworks    -8.399e-03 -2.612e-03  1.962e-03
## lunch       -2.785e-02 -2.718e-02 -2.654e-02
## compstud     1.034e+00  8.828e-01  7.884e-01
## income       4.250e-02  3.477e-02  2.821e-02
## expenditure  6.882e-05  6.206e-05  5.871e-05
## grades      -1.414e-01 -1.291e-01 -1.215e-01
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Thus, we can conclude that:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Income and indicators of income (e.g., low levels of lunch vouchers) are the two main predictors. Thus, schools with greater average income tend to have better student performance.&lt;/li&gt;
&lt;li&gt;Schools with more computers per student have better student performance.&lt;/li&gt;
&lt;li&gt;Schools with fewer students per teacher have better student performance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For more information about relative importance and the &lt;code&gt;relaimpo&lt;/code&gt; package measures check out &lt;a href="http://prof.beuth-hochschule.de/groemping/relaimpo/"&gt;Ulrike Grömping&amp;#39;s website&lt;/a&gt;.&lt;br/&gt;
Of course this is all observational data with the usual caveats regarding causal interpretation.&lt;/p&gt;

&lt;h2&gt;Now, let&amp;#39;s look at some weird stuff.&lt;/h2&gt;

&lt;h3&gt;Q. 8.1 What are common words in Californian School names?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;# create a vector of the words that occur in school names
lw &amp;lt;- unlist(strsplit(cas$school, split = &amp;quot; &amp;quot;))

# create a table of the frequency of school names
tlw &amp;lt;- table(lw)

# extract cells of table with count greater than 3
tlw2 &amp;lt;- tlw[tlw &amp;gt; 3]

# sorted in decreasing order
tlw2 &amp;lt;- sort(tlw2, decreasing = TRUE)

# values as proporitions
tlw2p &amp;lt;- round(tlw2/nrow(cas), 3)

# show this in a bar graph
tlw2pdf &amp;lt;- data.frame(word = names(tlw2p), prop = as.numeric(tlw2p), 
    stringsAsFactors = FALSE)
ggplot(tlw2pdf, aes(word, prop)) + geom_bar() + coord_flip()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/eqxKN.png" alt="plot of chunk unnamed-chunk-8"/&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;# make it log counts
ggplot(tlw2pdf, aes(word, log(prop * nrow(cas)))) + geom_bar() + 
    coord_flip()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/NJPiK.png" alt="plot of chunk unnamed-chunk-9"/&gt; &lt;/p&gt;

&lt;p&gt;The word &amp;ldquo;Elementary&amp;rdquo; appears in almost all school names (&lt;code&gt;98.3&lt;/code&gt;%).  The word &amp;ldquo;Union&amp;rdquo; appears in around half (&lt;code&gt;43.3&lt;/code&gt;%).&lt;/p&gt;

&lt;p&gt;Other common words pertain to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Directions (e.g., South, West), &lt;/li&gt;
&lt;li&gt;Features of the environment 
(e.g., Creek, Vista, View, Valley)&lt;/li&gt;
&lt;li&gt;Spanish words (e.g., rio for river; san for saint)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Q. 8.2 Is the number of letters in the school&amp;#39;s name related to academic performance?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;cas$namelen &lt;- nchar(cas$school)
table(cas$namelen)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## 
## 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 37 38 39 
##  1  4  9 26 28 31 33 27 30 45 38 28 36 30 18 10  5  4  6  3  1  2  2  2  1 
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;round(cor(cas$namelen, cas[, c(&amp;quot;read&amp;quot;, &amp;quot;math&amp;quot;)]), 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##      read math
## [1,] 0.03    0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The answer appears to be &amp;ldquo;no&amp;rdquo;.&lt;/p&gt;

&lt;h3&gt;Q.  8.3 Is the number of words in the school name related to academic performance?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;cas$nameWordCount &lt;- sapply(strsplit(cas$school, &amp;quot; &amp;quot;), length)
table(cas$nameWordCount)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## 
##   2   3   4   5 
## 140 202  72   6 
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;round(cor(cas$nameWordCount, cas[, c(&amp;quot;read&amp;quot;, &amp;quot;math&amp;quot;)]), 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##      read math
## [1,] 0.05 0.01
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The answer appears to be &amp;ldquo;no&amp;rdquo;.&lt;/p&gt;

&lt;h3&gt;Q. 8.4 Are schools with nice popular nature words in their name doing better academically?&lt;/h3&gt;

&lt;pre&gt;&lt;code class="r"&gt;tlw2p  #recall the list of popular names
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;## lw
## Elementary      Union       City     Valley      Joint       View 
##      0.983      0.433      0.060      0.040      0.031      0.019 
##   Pleasant        San      Creek        Oak      Santa       Lake 
##      0.017      0.017      0.014      0.014      0.014      0.012 
##   Mountain       Park        Rio      Vista      Grove   Lakeside 
##      0.012      0.012      0.012      0.012      0.010      0.010 
##      South    Unified       West 
##      0.010      0.010      0.010 
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;# Create a quick and dirty list of popular nature names
naturenames &amp;lt;- c(&amp;quot;Valley&amp;quot;, &amp;quot;View&amp;quot;, &amp;quot;Creek&amp;quot;, &amp;quot;Lake&amp;quot;, &amp;quot;Mountain&amp;quot;, &amp;quot;Park&amp;quot;, 
    &amp;quot;Rio&amp;quot;, &amp;quot;Vista&amp;quot;, &amp;quot;Grove&amp;quot;, &amp;quot;Lakeside&amp;quot;)

# work out whether the word is in the school name
schsplit &amp;lt;- strsplit(cas$school, &amp;quot; &amp;quot;)
cas$hasNature &amp;lt;- sapply(schsplit, function(X) length(intersect(X, 
    naturenames)) &amp;gt; 0)
round(cor(cas$hasNature, cas[, c(&amp;quot;read&amp;quot;, &amp;quot;math&amp;quot;)]), 2)
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##      read math
## [1,] 0.09 0.08
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So we&amp;#39;ve found a small correlation.&lt;br/&gt;&lt;br/&gt;
Let&amp;#39;s graph the data to see what it means:&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;ggplot(cas, aes(hasNature, read)) + geom_boxplot() + geom_jitter(position = position_jitter(width = 0.1)) + 
    xlab(&amp;quot;Has a nature name&amp;quot;) + ylab(&amp;quot;Mean student reading score&amp;quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/TyyL3.png" alt="plot of chunk unnamed-chunk-14"/&gt; &lt;/p&gt;

&lt;p&gt;So in the sample nature schools have slightly better reading score (and if we were to graph it, maths scores). However, the number of schools having nature names is actually somewhat small (n= &lt;code&gt;61&lt;/code&gt;) despite the overall quite large sample size.&lt;/p&gt;

&lt;p&gt;But is it statistically significant?&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;t.read &amp;lt;- t.test(cas[cas$hasNature, "read"], cas[!cas$hasNature, 
    &amp;quot;read&amp;quot;])
t.math &amp;lt;- t.test(cas[cas$hasNature, "math"], cas[!cas$hasNature, 
    &amp;quot;math&amp;quot;])
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, the p-value is less than .05 for reading (p = &lt;code&gt;0.046&lt;/code&gt;) but not quite for maths (p = &lt;code&gt;0.083&lt;/code&gt;).  Bingo!  After a little bit of data fishing we have found that reading scores are &amp;ldquo;significantly&amp;rdquo; greater for those schools with the listed nature names.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But wait&lt;/strong&gt;: I&amp;#39;ve asked three separate exploratory questions or perhaps six if we take maths into account.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$\frac{.05}{3} =$ &lt;code&gt;0.0167&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;$\frac{.05}{6} =$ &lt;code&gt;0.0083&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At these Bonferonni corrected p-values,  the result is non-significant. Oh well&amp;hellip;&lt;/p&gt;

&lt;h2&gt;Review&lt;/h2&gt;

&lt;p&gt;Anyway, the aim of this post was not to make profound statements about California schools. Rather the aim was to show how easy it is to produce quick reproducible reports with R Markdown. If you haven&amp;#39;t already, you may want to open up &lt;a href="https://gist.github.com/2724711"&gt;the R Markdown file used to produce this post&lt;/a&gt; in RStudio, and compile the report yourself.&lt;/p&gt;

&lt;p&gt;In particular, I can see R Markdown being my tool of choice for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blog posts&lt;/li&gt;
&lt;li&gt;Posts to StackExchange sites&lt;/li&gt;
&lt;li&gt;Materials for training workshops&lt;/li&gt;
&lt;li&gt;Short consulting reports, and&lt;/li&gt;
&lt;li&gt;Exploratory analyses as part of a larger project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The real question is how far I can push Markdown before I start to miss the control of LaTeX.  Markdown does permit arbitrary HTML. Anyway, if you have any thoughts about the scope of R Markdown, feel free to add a comment.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-2816864127561801354?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=FFTRZL7ZCb4:YH1N5WfhkMQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=FFTRZL7ZCb4:YH1N5WfhkMQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=FFTRZL7ZCb4:YH1N5WfhkMQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=FFTRZL7ZCb4:YH1N5WfhkMQ:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=FFTRZL7ZCb4:YH1N5WfhkMQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=FFTRZL7ZCb4:YH1N5WfhkMQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=FFTRZL7ZCb4:YH1N5WfhkMQ:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=FFTRZL7ZCb4:YH1N5WfhkMQ:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=FFTRZL7ZCb4:YH1N5WfhkMQ:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/FFTRZL7ZCb4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/2816864127561801354/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2012/05/example-reproducile-report-using-r.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2816864127561801354?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2816864127561801354?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/FFTRZL7ZCb4/example-reproducile-report-using-r.html" title="Example Reproducible Report using R Markdown:  Analysis of California Schools Test Data" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2012/05/example-reproducile-report-using-r.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEYBQHoyfip7ImA9WhVUEks.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-9141855655749942892</id><published>2012-05-17T14:31:00.000+10:00</published><updated>2012-05-17T23:42:31.496+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-17T23:42:31.496+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="reproducible research" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Getting Started with R Markdown, knitr, and Rstudio 0.96</title><content type="html">&lt;p&gt;This post examines the features of &lt;a href="http://www.rstudio.org/docs/authoring/using_markdown"&gt;R Markdown&lt;/a&gt; 
using &lt;a href="http://yihui.name/knitr/"&gt;knitr&lt;/a&gt; in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for 
&lt;a href="http://stats.stackexchange.com/a/15006/183"&gt;reproducible analysis&lt;/a&gt;.
Specifically, this post 
(1) discusses getting started with R Markdown and &lt;code&gt;knitr&lt;/code&gt; in  Rstudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and 
(5) discusses the implications of R Markdown.
This post was produced with R Markdown. The &lt;a href="https://gist.github.com/2716336"&gt;source code is available here as a gist&lt;/a&gt;. 
The post may be most useful if the source code and displayed post are viewed side by side. 
In some instances, I include a copy of the R Markdown in the displayed HTML, but most of the time I assume you are reading the source and post side by side.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h2&gt;Getting started&lt;/h2&gt;

&lt;p&gt;To work with R Markdown, if necessary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="http://www.r-project.org/"&gt;R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the lastest version of &lt;a href="http://rstudio.org/download/"&gt;RStudio&lt;/a&gt; (at time of posting, this is 0.96)&lt;/li&gt;
&lt;li&gt;Install the latest version of the &lt;code&gt;knitr&lt;/code&gt; package: &lt;code&gt;install.packages(&amp;quot;knitr&amp;quot;)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To run the basic working example that produced this blog post:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open R Studio, and go to File - New - R Markdown&lt;/li&gt;
&lt;li&gt;If necessary install &lt;code&gt;ggplot2&lt;/code&gt; and &lt;code&gt;lattice&lt;/code&gt; packages: &lt;code&gt;install.packages(&amp;quot;ggplot2&amp;quot;); install.packages(&amp;quot;lattice&amp;quot;)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Paste in the contents of &lt;a href="https://gist.github.com/2716336"&gt;the gist (which contains the R Markdown file used to produce this post)&lt;/a&gt; and save the file with an &lt;code&gt;.rmd&lt;/code&gt; extension&lt;/li&gt;
&lt;li&gt;Click Knit HTML&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;&lt;code class="r"&gt;opts_knit$set(upload.fun = imgur_upload)  # upload all images to imgur.com
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Prepare for analyses&lt;/h2&gt;

&lt;pre&gt;&lt;code class="r"&gt;set.seed(1234)
library(ggplot2)
library(lattice)
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Basic console output&lt;/h2&gt;

&lt;p&gt;To insert an R code chunk, you can type it manually or just press &lt;code&gt;Chunks - Insert chunks&lt;/code&gt; or use the shortcut key. This will produce the following code chunk:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r}

```
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Pressing tab when inside the braces will bring up code chunk options.&lt;/p&gt;

&lt;p&gt;The following R code chunk labelled &lt;code&gt;basicconsole&lt;/code&gt; is as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r basicconsole}
x &amp;lt;- 1:10
y &amp;lt;- round(rnorm(10, x, 1), 2)
df &amp;lt;- data.frame(x, y)
df
```
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The code chunk input and output is then displayed as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;x &amp;lt;- 1:10
y &amp;lt;- round(rnorm(10, x, 1), 2)
df &amp;lt;- data.frame(x, y)
df
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;##     x    y
## 1   1 1.31
## 2   2 2.31
## 3   3 3.36
## 4   4 3.27
## 5   5 5.04
## 6   6 6.11
## 7   7 8.43
## 8   8 8.98
## 9   9 8.38
## 10 10 9.27
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Plots&lt;/h2&gt;

&lt;p&gt;Images generated by &lt;code&gt;knitr&lt;/code&gt; are saved in a figures folder. However, they also appear to be represented in the HTML output using a &lt;a href="http://en.wikipedia.org/wiki/Data_URI_scheme"&gt;data URI scheme&lt;/a&gt;. This means that you can paste the HTML into a blog post or discussion forum and you don&amp;#39;t have to worry about finding a place to store the images; they&amp;#39;re embedded in the HTML.&lt;/p&gt;

&lt;h3&gt;Simple plot&lt;/h3&gt;

&lt;p&gt;Here is a basic plot using base graphics:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r simpleplot}
plot(x)
```
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;plot(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/JRrm8.png" alt="plot of chunk simpleplot"/&gt; &lt;/p&gt;

&lt;p&gt;Note that unlike traditional Sweave, there is no need to write &lt;code&gt;fig=TRUE&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;Multiple plots&lt;/h3&gt;

&lt;p&gt;Also, unlike traditional Sweave, you can include multiple plots in one code chunk:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r multipleplots}
boxplot(1:10~rep(1:2,5))
plot(x, y)
```
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;boxplot(1:10 ~ rep(1:2, 5))
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/TW0G1.png" alt="plot of chunk multipleplots"/&gt; &lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;plot(x, y)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/36WWn.png" alt="plot of chunk multipleplots"/&gt; &lt;/p&gt;

&lt;h3&gt;&lt;code&gt;ggplot2&lt;/code&gt; plot&lt;/h3&gt;

&lt;p&gt;Ggplot2 plots work well:&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;qplot(x, y, data = df)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/s5mct.png" alt="plot of chunk ggplot2ex"/&gt; &lt;/p&gt;

&lt;h3&gt;&lt;code&gt;lattice&lt;/code&gt; plot&lt;/h3&gt;

&lt;p&gt;As do lattice plots:&lt;/p&gt;

&lt;pre&gt;&lt;code class="r"&gt;xyplot(y ~ x)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/qXKUO.png" alt="plot of chunk latticeex"/&gt; &lt;/p&gt;

&lt;p&gt;Note that unlike traditional Sweave, there is no need to print lattice plots directly.&lt;/p&gt;

&lt;h2&gt;R Code chunk features&lt;/h2&gt;

&lt;h3&gt;Create Markdown code from R&lt;/h3&gt;

&lt;p&gt;The following code hides the command input (i.e., &lt;code&gt;echo=FALSE&lt;/code&gt;), and outputs the content directly as code (i.e., &lt;code&gt;results=asis&lt;/code&gt;, which is similar to &lt;code&gt;results=tex&lt;/code&gt; in Sweave).&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r dotpointprint, results=&amp;#39;asis&amp;#39;, echo=FALSE}
cat(&amp;quot;Here are some dot points\n\n&amp;quot;)
cat(paste(&amp;quot;* The value of y[&amp;quot;, 1:3, &amp;quot;] is &amp;quot;, y[1:3], sep=&amp;quot;&amp;quot;, collapse=&amp;quot;\n&amp;quot;))
```
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here are some dot points&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The value of y[1] is 1.31&lt;/li&gt;
&lt;li&gt;The value of y[2] is 2.31&lt;/li&gt;
&lt;li&gt;The value of y[3] is 3.36&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Create Markdown table code from R&lt;/h3&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r createtable, results=&amp;#39;asis&amp;#39;, echo=FALSE}
cat(&amp;quot;x | y&amp;quot;, &amp;quot;--- | ---&amp;quot;, sep=&amp;quot;\n&amp;quot;)
cat(apply(df, 1, function(X) paste(X, collapse=&amp;quot; | &amp;quot;)), sep = &amp;quot;\n&amp;quot;)
```
&lt;/code&gt;&lt;/pre&gt;

&lt;table&gt;&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;x&lt;/th&gt;
&lt;th&gt;y&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;1.31&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;2.31&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;3.36&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;3.27&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;5.04&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;6.11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;8.43&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;8.98&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;8.38&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;9.27&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;Control output display&lt;/h3&gt;

&lt;p&gt;The folllowing code supresses display of R input commands (i.e., &lt;code&gt;echo=FALSE&lt;/code&gt;)
and removes any preceding text from console output (&lt;code&gt;comment=&amp;quot;&amp;quot;&lt;/code&gt;; the default is &lt;code&gt;comment=&amp;quot;##&amp;quot;&lt;/code&gt;).&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r echo=FALSE, comment=&amp;quot;&amp;quot;, echo=FALSE}
head(df)
```
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;  x    y
1 1 1.31
2 2 2.31
3 3 3.36
4 4 3.27
5 5 5.04
6 6 6.11
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Control figure size&lt;/h3&gt;

&lt;p&gt;The following is an example of a smaller figure using &lt;code&gt;fig.width&lt;/code&gt; and &lt;code&gt;fig.height&lt;/code&gt; options.&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r smallplot, fig.width=3, fig.height=3}
plot(x)
```
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="r"&gt;plot(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/fg18e.png" alt="plot of chunk smallplot"/&gt; &lt;/p&gt;

&lt;h3&gt;Cache analysis&lt;/h3&gt;

&lt;p&gt;Caching analyses is straightforward.
Here&amp;#39;s example code. 
On the first run on my computer, this took about 10 seconds.
On subsequent runs, this code was not run. &lt;/p&gt;

&lt;p&gt;If you want to rerun cached code chunks, just &lt;a href="http://stackoverflow.com/a/10629121/180892"&gt;delete the contents of the &lt;code&gt;cache&lt;/code&gt; folder&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r longanalysis, cache=TRUE}
for (i in 1:5000) {
    lm((i+1)~i)
}
```
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Basic markdown functionality&lt;/h2&gt;

&lt;p&gt;For those not familiar with standard &lt;a href="http://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt;, the following may be useful.
See the source code for how to produce such points. However, RStudio does include a Markdown quick reference button that adequatly covers this material.&lt;/p&gt;

&lt;h3&gt;Dot Points&lt;/h3&gt;

&lt;p&gt;Simple dot points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Point 1&lt;/li&gt;
&lt;li&gt;Point 2&lt;/li&gt;
&lt;li&gt;Point 3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and numeric dot points:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Number 1&lt;/li&gt;
&lt;li&gt;Number 2&lt;/li&gt;
&lt;li&gt;Number 3&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;and nested dot points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A

&lt;ul&gt;
&lt;li&gt;A.1&lt;/li&gt;
&lt;li&gt;A.2&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;B

&lt;ul&gt;
&lt;li&gt;B.1&lt;/li&gt;
&lt;li&gt;B.2&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Equations&lt;/h3&gt;

&lt;p&gt;Equations are included by using LaTeX notation and including them either between single dollar signs (inline equations) or double dollar signs (displayed equations).
If you hang around the Q&amp;amp;A site &lt;a href="http://stats.stackexchange.com"&gt;CrossValidated&lt;/a&gt; you&amp;#39;ll be familiar with this idea.&lt;/p&gt;

&lt;p&gt;There are inline equations such as $y_i = \alpha + \beta x_i + e_i$.&lt;/p&gt;

&lt;p&gt;And displayed formulas:&lt;/p&gt;

&lt;p&gt;$$\frac{1}{1+\exp(-x)}$$&lt;/p&gt;

&lt;p&gt;knitr provides self-contained HTML code that calls a Mathjax script to display formulas.
However, in order to include the script in my blog posts I &lt;a href="https://gist.github.com/2716053"&gt;took the script&lt;/a&gt; and incorporated it into my blogger template.
If you are viewing this post through syndication or an RSS reader, this may not work.
You may need to view this post on my website. &lt;/p&gt;

&lt;h3&gt;Tables&lt;/h3&gt;

&lt;p&gt;Tables can be included using the following notation&lt;/p&gt;

&lt;table&gt;&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;A&lt;/th&gt;
&lt;th&gt;B&lt;/th&gt;
&lt;th&gt;C&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;Blue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;Pink&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;h3&gt;Hyperlinks&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you like this post, you may wish to subscribe to &lt;a href="http://feeds.feedburner.com/jeromyanglim"&gt;my RSS feed&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Images&lt;/h3&gt;

&lt;p&gt;Here&amp;#39;s an example image:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/RVNmr.jpg" alt="image from redmond barry building unimelb"/&gt;&lt;/p&gt;

&lt;h3&gt;Code&lt;/h3&gt;

&lt;p&gt;Here is Markdown R code chunk displayed as code:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;```{r}
x &amp;lt;- 1:10
x
```
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then there&amp;#39;s inline code such as &lt;code&gt;x &amp;lt;- 1:10&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;Quote&lt;/h3&gt;

&lt;p&gt;Let&amp;#39;s quote some stuff:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To be, or not to be, that is the question:
Whether &amp;#39;tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;R Markdown is awesome. 

&lt;ul&gt;
&lt;li&gt;The ratio of markup to content is excellent. &lt;/li&gt;
&lt;li&gt;For exploratory analyses, blog posts, and the like R Markdown will be a powerful productivity booster. &lt;/li&gt;
&lt;li&gt;For journal articles, LaTeX will presumably still be required.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;The RStudio team have made the whole process very user friendly.

&lt;ul&gt;
&lt;li&gt;RStudio provides useful shortcut keys for compiling to HTML, and running code chunks. These shortcut keys are presented in a clear way.&lt;/li&gt;
&lt;li&gt;The incorporated extensions to Markdown, particularly formula and table support, are particularly useful.&lt;/li&gt;
&lt;li&gt;Jump-to-chunk feature facilitates navigation. It helps if your code chunks have informative names.&lt;/li&gt;
&lt;li&gt;Code completion on R code chunk options is really helpful. See also &lt;a href="http://yihui.name/knitr/options"&gt;chunk options documentation on the knitr website&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Other recent posts on R markdown include those by :

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://christophergandrud.blogspot.com.au/2012/05/dynamic-content-with-rstudio-markdown.html"&gt;Christopher Gandrud&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://lamages.blogspot.com.au/2012/05/interactive-reports-in-r-with-knitr-and.html"&gt;Markcus Gesmann&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://rstudio.org/docs/authoring/using_markdown"&gt;Rstudio on R Markdown&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://yihui.name/knitr/"&gt;Yihui Xie&lt;/a&gt;: I really want to thank him for developing &lt;code&gt;knitr&lt;/code&gt;. 
He has also posted &lt;a href="https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rmd"&gt;this example of R Markdown&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Questions&lt;/h2&gt;

&lt;p&gt;The following are a few questions I encountered along the way that might interest others.&lt;/p&gt;

&lt;h3&gt;Annoying &lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt;&amp;#39;s&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I asked on the Rstudio discussion site:
&lt;a href="http://support.rstudio.org/help/discussions/problems/2329-why-does-r-markdown-to-html-insert-br-when-there-is-a-new-line-of-text"&gt;Why does Markdown to HTML insert &lt;code&gt;&amp;lt;br/&amp;gt;&lt;/code&gt; on new lines?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; I just do a find and delete on this text for now.
Specifically, I have a sed command that extracts just the content between the &lt;code&gt;body&lt;/code&gt; tags and removes &lt;code&gt;br&lt;/code&gt; tags.
I can then, readily incorporate the result into my blogposts.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sed -i -e '1,/&amp;lt;body&amp;gt;/d' -e'/^&amp;lt;\/body&amp;gt;/,$d' -e 's/&amp;lt;br\/&amp;gt;$//' filename.html
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Temporarily disable caching&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I asked on StackOverflow about 
&lt;a href="http://stackoverflow.com/q/10628665/180892"&gt;How to set cache=FALSE for a knitr markdown document and override code chunk settings?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;  Delete the cache folder. But there are other possible workflows.&lt;/p&gt;

&lt;h3&gt;Equivalent of Sexpr&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I asked on Stack Overvlow about &lt;a href="http://stackoverflow.com/q/10629416/180892"&gt;whether there an R Markdown equivalent to Sexpr in Sweave?&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; Include the code between brackets of &amp;ldquo;backtick r space&amp;rdquo; and &amp;ldquo;backtick&amp;rdquo;. 
E.g., in the source code I have calculated 2 + 2 = &lt;code&gt;4&lt;/code&gt; .&lt;/p&gt;

&lt;h3&gt;Image format&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; When using the URI scheme images don&amp;#39;t appear to display in RSS feeds of my blog.
What&amp;#39;s a good strategy?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; One strategy is to upload to imgur.
The &lt;a href="https://raw.github.com/yihui/knitr/master/inst/examples/knitr-upload.Rmd"&gt;following provides&lt;/a&gt; an example of exporting to imgur.&lt;/p&gt;

&lt;p&gt;Add the following lines of code near the top of the file:&lt;/p&gt;

&lt;pre&gt;&lt;code class="no-highlight"&gt;``` {r optsknit}
opts_knit$set(upload.fun = imgur_upload) # upload all images to imgur.com
```
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I found that the function failed when I was at work behind a firewall, but worked at home.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-9141855655749942892?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=LcxgogcYlPE:H8JBOWmDWMM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=LcxgogcYlPE:H8JBOWmDWMM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=LcxgogcYlPE:H8JBOWmDWMM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=LcxgogcYlPE:H8JBOWmDWMM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=LcxgogcYlPE:H8JBOWmDWMM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=LcxgogcYlPE:H8JBOWmDWMM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=LcxgogcYlPE:H8JBOWmDWMM:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=LcxgogcYlPE:H8JBOWmDWMM:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=LcxgogcYlPE:H8JBOWmDWMM:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/LcxgogcYlPE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/9141855655749942892/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2012/05/getting-started-with-r-markdown-knitr.html#comment-form" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/9141855655749942892?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/9141855655749942892?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/LcxgogcYlPE/getting-started-with-r-markdown-knitr.html" title="Getting Started with R Markdown, knitr, and Rstudio 0.96" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>10</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2012/05/getting-started-with-r-markdown-knitr.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYDSX09fyp7ImA9WhVVEEU.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-4693518112289819334</id><published>2012-05-03T22:31:00.000+10:00</published><updated>2012-05-04T09:19:38.367+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-04T09:19:38.367+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ggplot2" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>How to plot three categorical variables and one continuous variable using ggplot2</title><content type="html">&lt;p&gt;This post shows how to produce a plot involving three categorical variables
and one continuous variable using &lt;code&gt;ggplot2&lt;/code&gt; in R.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;p&gt;The &lt;a href="https://gist.github.com/2585249"&gt;following code is also available as a gist on github&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;1. Create Data&lt;/h5&gt;

&lt;p&gt;First, let's load &lt;code&gt;ggplot2&lt;/code&gt; and create some data to work with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;library(ggplot2)

set.seed(4444)
Data &amp;lt;- expand.grid(group=c("Apples", "Bananas", "Carrots", "Durians", 
            "Eggplants"),
            year=c("2000", "2001", "2002"),
            quality=c("Grade A", "Grade B", "Grade C", "Grade D", 
            "Grade E"))
Group.Weight &amp;lt;- data.frame(
    group=c("Apples", "Bananas", "Carrots", "Durians", "Eggplants"),
    group.weight=c(1,1,-1,0.5, 0))
Quality.Weight &amp;lt;- data.frame(
    quality=c("Grade A", "Grade B", "Grade C", "Grade D", "Grade E"),
    quality.weight = c(1,0.5,0,-0.5,-1))
Data &amp;lt;- merge(Data, Group.Weight)
Data &amp;lt;- merge(Data, Quality.Weight)
Data$score &amp;lt;- Data$group.weight + Data$quality.weight + 
    rnorm(nrow(Data), 0, 0.2)
Data$proportion.tasty &amp;lt;- exp(Data$score)/(1 + exp(Data$score))
&lt;/code&gt;&lt;/pre&gt;

&lt;h5&gt;2. Produce Plot&lt;/h5&gt;

&lt;p&gt;And here's the code to produce the plot.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ggplot(data=Data, 
       aes(x=factor(year), y=proportion.tasty, 
           group=group,
           shape=group,
           color=group)) + 
               geom_line() + 
               geom_point() +
               opts(title = 
               "Proportion Tasty by Year, Quality, and Group") +
               scale_x_discrete("Year") +
               scale_y_continuous("Proportion Tasty") + 
        facet_grid(.~quality )
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And here's what it looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://imgur.com/UWZgd"&gt;&lt;img src="http://i.imgur.com/UWZgd.png" 
title="three categorical variables ggplot2" width=520 alt="three categorical variables ggplot2" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-4693518112289819334?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OIZwqau-Kaw:SHQnWM5BSyI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OIZwqau-Kaw:SHQnWM5BSyI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OIZwqau-Kaw:SHQnWM5BSyI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OIZwqau-Kaw:SHQnWM5BSyI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OIZwqau-Kaw:SHQnWM5BSyI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OIZwqau-Kaw:SHQnWM5BSyI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OIZwqau-Kaw:SHQnWM5BSyI:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OIZwqau-Kaw:SHQnWM5BSyI:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OIZwqau-Kaw:SHQnWM5BSyI:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/OIZwqau-Kaw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/4693518112289819334/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2012/05/how-to-plot-three-categorical-variables.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/4693518112289819334?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/4693518112289819334?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/OIZwqau-Kaw/how-to-plot-three-categorical-variables.html" title="How to plot three categorical variables and one continuous variable using ggplot2" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2012/05/how-to-plot-three-categorical-variables.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUHQ34_eyp7ImA9WhVXEkQ.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-2161909575284784854</id><published>2012-04-11T15:50:00.001+10:00</published><updated>2012-04-13T15:17:12.043+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-13T15:17:12.043+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="bayesian" /><category scheme="http://www.blogger.com/atom/ns#" term="jags" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Getting Started with JAGS, rjags, and Bayesian Modelling</title><content type="html">&lt;p&gt;This post provides links to various resources on getting started with Bayesian
modelling using JAGS and R.
It discusses: 
(1) what is JAGS;
(2) why you might want to perform Bayesian modelling using JAGS;
(3) how to install JAGS;
(4) where to find further information on JAGS;
(5) where to find examples of JAGS scripts in action;
(6) where to ask questions; and
(7) some interesting psychological applications of Bayesian modelling.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;What is JAGS?&lt;/h3&gt;

&lt;p&gt;JAGS stands for Just Another Gibbs Sampler.
To quote the program author, Martyn Plummer, "It is a program for analysis of
Bayesian hierarchical models using Markov Chain Monte Carlo (MCMC) simulation..." 
It uses a dialect of the BUGS language, similar but a little different to OpenBUGS and WinBUGS.&lt;/p&gt;

&lt;h3&gt;Why JAGS?&lt;/h3&gt;

&lt;p&gt;The question of why you might want to use JAGS can be approached in several different ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why Bayesian rather than Null Hypothesis Significance Testing (&lt;a href="http://yatani.jp/HCIstats/NHST"&gt;NHST&lt;/a&gt;) approaches?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To quote John D. Cook quoting Anthony O'Hagan, the benefits of "the bayesian
approach are that it is 1. fundamentally sound, 2. very flexible, 3.
produces clear and direct inferences, and 4. makes use of all available
information." (see &lt;a href="http://www.johndcook.com/blog/2009/04/28/reasons-to-use-bayesian-inference/"&gt;John's blog post for
elaboration&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;John K. Kruschke made a similar argument in an &lt;a href="http://www.indiana.edu/~kruschke/AnOpenLetter.htm"&gt;Open Letter extolling the
benefits of the bayesian
approach&lt;/a&gt; summarised
as: "(1)  Scientific disciplines from astronomy to zoology are moving to
Bayesian data analysis. We should be leaders of the move, 
not followers.  (2) Modern Bayesian methods provide richer information,
with greater flexibility and broader applicability than 20th century
methods.  Bayesian methods are intellectually coherent and intuitive.
Bayesian analyses are readily computed with modern software and hardware.
(3)  Null-hypothesis significance testing (NHST), with its reliance on p
values, has many problems. There is little reason to persist with NHST now
that Bayesian methods are accessible to everyone."&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why JAGS/BUGS rather than coding in a low-level language?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's simpler; for models that BUGS can handle, BUGS can shield you from
some of the thorny details related to numeric integration.&lt;/li&gt;
&lt;li&gt;There are simple interfaces with R.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Why JAGS rather than WinBUGS or OpenBUGS?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I'm using JAGS because it works well on Ubuntu. WinBUGS is broadly Windows
specific, although I've read that it may work with the emulation software Wine.&lt;/li&gt;
&lt;li&gt;JAGS interfaces well with R. I'm comfortable writing
scripts. Thus, I don't personally see the benefits of using a dedicated
GUI like WinBUGS. I can leverage what I know about R. &lt;/li&gt;
&lt;li&gt;However, ultimately converting code between different flavours of BUGS
is not that difficult. &lt;/li&gt;
&lt;li&gt;For further discussion of the issue, see this &lt;a href="http://r.789695.n4.nabble.com/R-vs-Bugs-td857751.html"&gt;r-help
discussion&lt;/a&gt; and
&lt;a href="
http://stats.stackexchange.com/questions/9202/openbugs-vs-jags"&gt;this discussion on CrossValidated&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More than anything I found that JAGS provided a useful entry point into the world of
Bayesian modelling. This in turn appealed to me for several reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Even when I perform analyses using an NHST approach I often intuitively think
of empirical research questions in terms of probability densities on a
parameter of interest that changes as empirical and theoretical evidence is
accumulated. See for example Thompson's (2002) concept of
&lt;a href="http://www.reference.com/browse/meta-analytic_thinking"&gt;meta-analytic thinking&lt;/a&gt;.
Bayesian analysis provides tools for formalising this orientation. &lt;/li&gt;
&lt;li&gt;More broadly, I appreciate the explicitness that a Bayesian approach
requires and encourages. E.g., specifying the distribution of the error term,
specifying a prior, specifying the distribution of parameters in a mixed
effects model, and so on.&lt;/li&gt;
&lt;li&gt;There are several modelling challenges that I'm currently working through
where a Bayesian approach offers substantial flexibility and applicability. 
In particular, I'm interested in modelling individual differences in the
effect of practice on strategy use and task performance and then relating
these individual differences to factors like intelligence, prior experience,
and personality.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;JAGS Installation&lt;/h3&gt;

&lt;p&gt;JAGS runs on Linux, Mac, and Windows.
I run JAGS on Ubuntu through an interface with R called &lt;code&gt;rjags&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The following sets out a basic installation process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If necessary &lt;a href="http://www.r-project.org/"&gt;Download and install R&lt;/a&gt; and
potentially a user interface to R like &lt;a href="http://rstudio.org/"&gt;R Studio&lt;/a&gt;
(see &lt;a href="http://jeromyanglim.blogspot.com.au/2009/06/learning-r-for-researchers-in.html"&gt;here for tips on getting started with
R&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mcmc-jags.sourceforge.net/"&gt;Download and install JAGS&lt;/a&gt; as per
operating system requriements. &lt;/li&gt;
&lt;li&gt;Install additional R packages: e.g., in R &lt;code&gt;install.packages("rjags")&lt;/code&gt; .
In particular, I use the packages &lt;code&gt;rjags&lt;/code&gt; to interface with JAGS and
&lt;code&gt;coda&lt;/code&gt; to process MCMC output.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Information on JAGS&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;a href="http://sourceforge.net/projects/mcmc-jags/files/Manuals/"&gt;manual for different versions of JAGS is located
here&lt;/a&gt;.
e.g., &lt;a href="http://ftp.iinet.net.au/pub/FreeBSD/distfiles/mcmc-jags/jags_user_manual.pdf"&gt;the pdf of the manual for 3.1.0&lt;/a&gt;.
Several particularly relevant sections include:
&lt;ul&gt;
&lt;li&gt;the list of supported distributions and how they are parameterised. This is
often important given that the code looks similar to R but often 
uses different parameterisation (e.g., precision is used instead of
standard deviation for a normal distribution).&lt;/li&gt;
&lt;li&gt;It summarises differences between WinBUGS and JAGS. &lt;/li&gt;
&lt;li&gt;It sets out available functions and operators.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;The &lt;a href="http://cran.r-project.org/web/packages/rjags/rjags.pdf"&gt;&lt;code&gt;rjags&lt;/code&gt; help pdf&lt;/a&gt;
for information about how to interface with JAGS from R.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://martynplummer.wordpress.com/"&gt;Martin Plummer has a blog called JAGS NEWS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;The &lt;a href="
http://cran.r-project.org/web/views/Bayesian.html"&gt;Bayesian Task View on CRAN&lt;/a&gt; lists and briefly
describes the many R packages related to Bayesian statistics. &lt;/li&gt;
&lt;li&gt;Lunn and colleagues have a 2009 article called
&lt;a href="
http://www.stat.columbia.edu/~gelman/bayescomputation/lunnbugswithcomments.pdf"&gt;The BUGS project: Evolution, critique and future directions&lt;/a&gt;.
It provides a useful historical perspective on the broader BUGS project,
although it does not mention much about JAGS specifically.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Examples JAGS Scripts&lt;/h3&gt;

&lt;p&gt;I find it easier to pick up a new language by playing with examples.
The following provides links to example JAGS code, often with accompanying
explanations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;John Myles White 
&lt;ul&gt;
&lt;li&gt;A course on statistical models that is under development with &lt;a href="https://github.com/johnmyleswhite/JAGSExamples"&gt;JAGS scripts on github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A &lt;a href="http://www.johnmyleswhite.com/notebook/2011/03/16/canabalt-revisited-gamma-distributions-multinomial-distributions-and-more-jags-goodness/"&gt;model of Cannabalt scores using a gamma
distribution&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.johnmyleswhite.com/notebook/2010/08/20/using-jags-in-r-with-the-rjags-package/"&gt;Simple introductory examples of fitting a normal distribution, linear
regression, and logistic
regression&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A follow-up post demonstrating the use of the &lt;code&gt;coda&lt;/code&gt; package with &lt;code&gt;rjags&lt;/code&gt;
to &lt;a href="http://www.johnmyleswhite.com/notebook/2010/08/29/mcmc-diagnostics-in-r-with-the-coda-package/"&gt;perform MCMC
diagnostics&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;John K. Kruschke
&lt;ul&gt;
&lt;li&gt;John Krushke wrote a book called &lt;em&gt;Doing Bayesian Data Analysis: A Tutorial with R
and BUGS&lt;/em&gt;. It's an excellent entry point into the world of Bayesian
statistics for the social and behavioural scientist who has
reasonable quantiative training, but is not necessarily ready to absorb
the kinds of books that are used in graduate-level statistics courses.&lt;/li&gt;
&lt;li&gt;The &lt;a href="http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis/"&gt;book has a
website&lt;/a&gt; that
provides all the examples used in the book all the examples used in the
book. See this &lt;a href="http://doingbayesiandataanalysis.blogspot.com.au/2012/01/complete-steps-for-installing-software.html"&gt;blog post for a link to the zip file containing the JAGS
code&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;BUGS Project
&lt;ul&gt;
&lt;li&gt;BUGS is well known for the large set of examples that accompany the project.&lt;/li&gt;
&lt;li&gt;The PDF providing documentation for Volume 1 and 2 of the examples is &lt;a href="http://www.mrc-bsu.cam.ac.uk/bugs/documentation/contents.shtml"&gt;available
here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;You can see the &lt;a href="http://sourceforge.net/projects/mcmc-jags/files/Examples/2.x/"&gt;JAGS code used to run these examples
here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Patrick J Mineault&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;a href="http://xcorr.net/2011/07/13/gibbs-sampling-made-easy-jags-rkward-coda/"&gt;example from Gelman et al examining the effect of training programs on
SAT
scores&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Miguel Lobo&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://sousalobo.com/aom2011pdw/JAGS_tutorial_Lobo.pdf
"&gt;A short tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Simon Jackman
&lt;ul&gt;
&lt;li&gt;Simon Jackman wrote the book &lt;em&gt;Bayesian Analysis for the Social Sciences&lt;/em&gt;
that has accompanying JAGS code.&lt;/li&gt;
&lt;li&gt;The &lt;a href="http://jackman.stanford.edu/MCMC/"&gt;book's website&lt;/a&gt;  has several
useful resources including example papers using Bayesian methods.&lt;/li&gt;
&lt;li&gt;An &lt;a href="http://jackman.stanford.edu/classes/BASS/index.php"&gt;associated course&lt;/a&gt;
that uses the book as a text book has slides and many examples of using
and R and JAGS.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Johannes Karreth&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;a href="http://jkarreth.myweb.uga.edu/bayes2011.htm"&gt;course on applied bayesian modelling&lt;/a&gt; 
with examples of data, and code using the &lt;code&gt;R2jags&lt;/code&gt; interface.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Myself&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I also plan to post a few examples in upcoming blog posts.  I typically
will share the code for these on my &lt;a href="https://github.com/jeromyanglim"&gt;github account:
&lt;code&gt;jeromyanglim&lt;/code&gt;&lt;/a&gt;.  If you are reading this
through syndication you may wish to &lt;a href="http://feeds.feedburner.com/jeromyanglim"&gt;subscribe to the RSS feed of the
source blog jeromyanglim.blogspot.com&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More broadly, examples and tutorials designed for WinBUGS can generally be
adapted to be useful for JAGS.  So for example, you can explore these WinBUGS
examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Michael Lee and Eric-Jan Wagemakers have a free online book called &lt;em&gt;A Course in Bayesian Graphical Modeling
for Cognitive Science&lt;/em&gt;: see &lt;a href="http://www.ejwagenmakers.com/BayesCourse/BayesBookWeb.pdf"&gt;PDF&lt;/a&gt; and
&lt;a href="http://www.ejwagenmakers.com/BayesCourse/BayesBook.html"&gt;website&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The website for the book &lt;a href="http://www.dme.ufrj.br/mcmc/"&gt;Markov Chain Monte
Carlo&lt;/a&gt; has several WinBUGS examples.&lt;/li&gt;
&lt;li&gt;There is an &lt;a href="http://www.mrc-bsu.cam.ac.uk/bugs/weblinks/webresource.shtml"&gt;extensive list of BUGS
resources&lt;/a&gt; on
the BUGS project website.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Asking questions&lt;/h3&gt;

&lt;p&gt;There are several places to ask questions about JAGS, R, and Bayesian
statistics.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stats.stackexchange.com/questions/tagged/jags"&gt;JAGS&lt;/a&gt;, 
&lt;a href="http://stats.stackexchange.com/questions/tagged/bugs"&gt;BUGS&lt;/a&gt;, and 
&lt;a href="http://stats.stackexchange.com/questions/tagged/bayesian"&gt;bayesian&lt;/a&gt; questions
on &lt;a href="http://stats.stackexchange.com/"&gt;stats.stackexchange.com&lt;/a&gt; (aka CrossValidated). &lt;/li&gt;
&lt;li&gt;&lt;a href="http://sourceforge.net/projects/mcmc-jags/forums/"&gt;JAGS discussion forum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;There's also a &lt;a href="http://www.mrc-bsu.cam.ac.uk/bugs/overview/list.shtml"&gt;BUGS discussion
list&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In general, I prefer the Stack Exchange model for asking and answering questions
on the internet, although the most important issue is typically where the
experts are located.&lt;/p&gt;

&lt;h3&gt;Interesting Psychological Applications of Bayesian Modelling&lt;/h3&gt;

&lt;p&gt;If you want to see some examples of Bayesian modelling applied to psychological
data, I found the following articles quite interesting. 
PDFs are available online.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://homepage.psy.utexas.edu/homepage/group/loveLAB/love/classes/CompCogsci/2010/hierarchicalReview.pdf"&gt;Shiffrin, Lee, Kim, and Wagenmakers (2008, PDF)&lt;/a&gt; present a tutorial on hierarchical bayesian methods in the context of cognitive science.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cear.gsu.edu/workshops/8/CEAR%20dec%201-2%20papers/Lee/Lee2011.pdf"&gt;Michael Lee (2011, PDF) in Journal of Mathematical Psychology&lt;/a&gt;
discusses the benefits of hiearchical Bayesian methods to modelling
psychological data and provides several example applications.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.newcl.org/docs/2011/averell_heathcote_2011.pdf"&gt;Lee Averell and Andrew Heathcote (2010,
PDF)&lt;/a&gt; in Journal of
Mathematical Psychology analyse individual differences in the forgetting curve
using a hierarchical Bayesian approach.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you know of any other interesting JAGS resources or have any comments about my
choice of software for Bayesian data analysis, feel free to post a comment.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-2161909575284784854?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=6XpJ248trHA:2twRalQbmxM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=6XpJ248trHA:2twRalQbmxM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=6XpJ248trHA:2twRalQbmxM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=6XpJ248trHA:2twRalQbmxM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=6XpJ248trHA:2twRalQbmxM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=6XpJ248trHA:2twRalQbmxM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=6XpJ248trHA:2twRalQbmxM:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=6XpJ248trHA:2twRalQbmxM:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=6XpJ248trHA:2twRalQbmxM:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/6XpJ248trHA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/2161909575284784854/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2012/04/getting-started-with-jags-rjags-and.html#comment-form" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2161909575284784854?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2161909575284784854?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/6XpJ248trHA/getting-started-with-jags-rjags-and.html" title="Getting Started with JAGS, rjags, and Bayesian Modelling" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>8</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2012/04/getting-started-with-jags-rjags-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkYFR348eip7ImA9WhRaFEo.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-3324860562942638158</id><published>2012-02-17T21:21:00.000+11:00</published><updated>2012-02-17T21:21:56.072+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-17T21:21:56.072+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="psychology" /><category scheme="http://www.blogger.com/atom/ns#" term="stackexchange" /><title>New Psychology and Cognitive Science Question and Answer Site: COGSCI.SE</title><content type="html">&lt;p&gt;There is now a new website for researchers to ask and answer
questions on topics related to psychology and cognitive science.
The site is &lt;a href="http://cogsci.stackexchange.com/"&gt;cogsci.stackexchange.com&lt;/a&gt;.
From the success of earlier released &lt;a href="http://stackexchange.com/sites"&gt;sites in the Stack Exchange
network&lt;/a&gt; such as those on 
&lt;a href="http://stackoverflow.com/"&gt;programming&lt;/a&gt;, 
&lt;a href="http://stats.stackexchange.com/"&gt;statistics&lt;/a&gt;, 
and &lt;a href="http://tex.stackexchange.com/"&gt;latex&lt;/a&gt;,
the site for psychology and cognitive science has the potential be a great
resource for researchers.
&lt;a href="http://cogsci.stackexchange.com/users/52/jeromy-anglim"&gt;I'm actively
contributing&lt;/a&gt; on the site.
So, if you are a researcher in psychology, I hope you'll &lt;a href="http://cogsci.stackexchange.com/"&gt;check it
out&lt;/a&gt;.
The rest of this post sets out 
(a) a little history of Stack Exchange question and answer sites as they relate to psychology and statistics; 
(b) why I think this &lt;a href="http://cogsci.stackexchange.com/"&gt;new site for psychology and cognitive science&lt;/a&gt;
has so much potential; and
(c) why, if you are a professional or student researcher in psychology, you
might want to get involved.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;A little history&lt;/h3&gt;

&lt;p&gt;I first learnt about the Stack Exchange network back in 2009. 
While I was busy learning R, a number of people in the online data science world 
such as &lt;a href="http://www.cerebralmastication.com/"&gt;JD Long&lt;/a&gt;, 
&lt;a href="http://www.oscon.com/oscon2009/public/schedule/detail/10432"&gt;Michael Driscoll&lt;/a&gt;,
&lt;a href="http://www.drewconway.com/zia/?p=1172"&gt;Drew Conway&lt;/a&gt;, and &lt;a href="https://twitter.com/#!/rstatsmob/following"&gt;many
more&lt;/a&gt; were promoting a programmer's
question and answer site called Stack Overflow as a place to ask and answer R
related questions.
It was a site pitched at overcoming the many problems of discussion boards,
mailing lists, and the like: e.g., off topic threads, spam, extended discussion
difficulty finding the correct answers, poor indexing by Google, etc.
As of Feb 2011, it now has over &lt;a href="http://stackoverflow.com/questions/tagged/r?sort=votes&amp;amp;pagesize=50"&gt;10,000 questions with the R
tag&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Shortly afterwards, the Stack Exchange Network developed &lt;a href="http://area51.stackexchange.com"&gt;Area51&lt;/a&gt;.
The idea was to take the question and answer infrastructure that made Stack
Overflow a success in the programming world, and extend it to all sorts of other
domains.
Instead of going down the model of Quora or, shudder to think, Yahoo Answers,
Stack Exchange did not permit the creation of a site until a sufficient
community of active users existed to maintain the site at a high standard.
Thus, my main interests, statistics and psychology were going to have to wait.&lt;/p&gt;

&lt;p&gt;A site for statistics questions was the first to join the network
(&lt;a href="http://stats.stackexchange.com/"&gt;stats.stackexchange.com&lt;/a&gt;).
&lt;a href="http://robjhyndman.com/researchtips/crossvalidated/"&gt;Professor Rob Hyndman proposed the
site&lt;/a&gt;, and perhaps given the
overlapping worlds of programmers and data analysts, the
site launched a few months later in July 2010.
At the time of posting it has over &lt;a href="http://stats.stackexchange.com/questions?sort=votes"&gt;7,000
questions&lt;/a&gt;.
&lt;a href="http://stats.stackexchange.com/users/183/jeromy-anglim"&gt;I've been actively involved&lt;/a&gt; in the site.
I've used it to get advice on my own research.
I've also used it extensively in various statistical consulting roles.
In particular, I've &lt;a href="http://jeromyanglim.blogspot.com.au/2011/03/how-to-ask-me-statistics-question.html"&gt;encouraged others who would otherwise send me an email about
statistics, to post the question on
stats.se&lt;/a&gt;
so that any answer can be an ongoing resource for others.&lt;/p&gt;

&lt;p&gt;In the case of psychology and cognitive science, I've had to wait a lot longer.
The overlap between programming and psychology communities is much smaller,
and site proposals were split over separate cognitive science, psychology, and
psychiatry proposals.
Finally, in December 2011 these three proposals were merged and on January 19th 2012 the
site was launched in Beta under the title Cognitive Sciences at the url
&lt;a href="http://cogsci.stackexchange.com/"&gt;cogsci.stackexchange.com&lt;/a&gt;.
Although the initial name is suggestive of a focus on "cognitive" science. 
The history of the merging of site proposals, the inclusion of the "s", plural
"sciences", and the attitude of current participants admits the full range of
questions in cognitive science, psychology, and psychiatry.&lt;/p&gt;

&lt;p&gt;At the time of posting the site is growing at a healthy rate. 
Most questions are getting good answers, and the community norms around question
quality, references, scope and so on are being clarified on the &lt;a href="http://meta.cogsci.stackexchange.com/"&gt;meta
site&lt;/a&gt;.
However, there is also the challenge of getting the word out about the site to
academics, researchers, and graduate students who are not otherwise familiar
with the Stack Exchange network of sites.
In my opinion, Stack Exchange provides the best currently available
infrastructure for building a high quality question and answer site. 
However, it still relies on a community of expert contributors.&lt;/p&gt;

&lt;p&gt;So, if you're a researcher in psychology or cognitive science, why might you
want to get involved? And why might you want to talk to fellow researchers about
the?&lt;/p&gt;

&lt;h3&gt;Reasons to participate as an academic&lt;/h3&gt;

&lt;p&gt;If you are an academic, Lecturer, or Post Doc, there are many reasons why you
might want to participate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answering questions is a way of facilitating knowledge transfer to the
broader community; this can be intrinsically enjoyable especially when you get direct
feedback on the number of people who read your answers.&lt;/li&gt;
&lt;li&gt;If you use your own name, as many people do, the voting and reputation system,
and various other mechanisms provide a means for your contribution to be
recognised.&lt;/li&gt;
&lt;li&gt;You get immediate feedback on what others think of your answers; Thus, it
creates an environment of feedback conducive to learning.&lt;/li&gt;
&lt;li&gt;I see sites like Stack Exchange as part of a broader model of open science.
As you create and develop knowledge, you encounter challenges. The idea is to
record these challenges as questions and then add the resolutions as answers.
Thus, when others encounter the same problems, good answers are only a Google
search away.
I'm not saying that question and answer sites replace journal articles, but
they can fill a bridging role linking the language of questions to the answers
provided in journal articles.&lt;/li&gt;
&lt;li&gt;Furthermore, the content on Stack Exchange is licenced under creative commons,
so even if the site disappeared the content would still be available on other
sites that reproduce the material. This is much better
than the policy of almost all journals which copyright your, typically, state-sponsored
research and lock it up behind a pay wall, thereby frustrating the
process of knowledge dissemination.&lt;/li&gt;
&lt;li&gt;While contributing to Wikipedia is another great way to improve the sum of all
knowledge, unlike Wikipedia, your answers generally stay there; in contrast to
Wikipedia, where your contributions can and are often completely removed by
other editors.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Reasons to participate as a student researcher&lt;/h3&gt;

&lt;p&gt;If you are doing a thesis in psychology or cognitive science, or possibly even if
you are just studying a few subjects, many of the above reasons for
participating will also apply.&lt;/p&gt;

&lt;p&gt;However, you may also find that the capacity to ask questions will be
particularly useful. As a side point, if it is early days in your career, you
may or may not want to use your real name.&lt;/p&gt;

&lt;p&gt;In particular, I'd encourage students completing a thesis to incorporate asking
and answering questions into their scholarly process.
You might encounter questions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is there a meta analysis on X?&lt;/li&gt;
&lt;li&gt;What are the main theory about Y?&lt;/li&gt;
&lt;li&gt;What is the best measure of Z?&lt;/li&gt;
&lt;li&gt;What is the empirical support for theory W?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These kinds of questions come up all the time when doing research.
Of course, as researchers we have strategies for finding answers ourselves.
However, the stack exchange model encourages you to learn from the answers of
others and also to "leave crumbs" so that others can follow in your footsteps
more easily. The idea is not be shy. Post questions frequently. If you're able
to answer your question, contribute a self-answer.&lt;/p&gt;

&lt;p&gt;Thus, even if only a handful of people ever read a thesis, by asking and
answering many questions along the way, resources will be left that thousands of
people will learn from and discover through Google searches in the years to
come. Even if you don't have answers, your question can be the trigger for an
expert to share knowledge to create a valuable Internet artefact.&lt;/p&gt;

&lt;h5&gt;Getting Started&lt;/h5&gt;

&lt;p&gt;If you want to learn more or give the site a go:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Have a read through the &lt;a href="http://cogsci.stackexchange.com/faq"&gt;FAQ on cogsci.se&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://cogsci.stackexchange.com/questions/ask"&gt;Ask a question&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;See if you can answer one of the &lt;a href="http://cogsci.stackexchange.com/unanswered"&gt;currently unanswered
questions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm &lt;a href="http://cogsci.stackexchange.com/users/52/jeromy-anglim"&gt;floating around on the
site&lt;/a&gt;, so if you're a
researcher in psychology, I hope to see you
&lt;a href="http://cogsci.stackexchange.com/"&gt;there&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-3324860562942638158?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=zB1_AtXJgHU:am6tH0Mo9MY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=zB1_AtXJgHU:am6tH0Mo9MY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=zB1_AtXJgHU:am6tH0Mo9MY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=zB1_AtXJgHU:am6tH0Mo9MY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=zB1_AtXJgHU:am6tH0Mo9MY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=zB1_AtXJgHU:am6tH0Mo9MY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=zB1_AtXJgHU:am6tH0Mo9MY:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=zB1_AtXJgHU:am6tH0Mo9MY:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=zB1_AtXJgHU:am6tH0Mo9MY:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/zB1_AtXJgHU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/3324860562942638158/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2012/02/new-psychology-and-cognitive-science.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/3324860562942638158?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/3324860562942638158?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/zB1_AtXJgHU/new-psychology-and-cognitive-science.html" title="New Psychology and Cognitive Science Question and Answer Site: COGSCI.SE" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2012/02/new-psychology-and-cognitive-science.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUEFR3Y-eSp7ImA9WhdSFU0.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-5256105903569404178</id><published>2011-07-24T21:40:00.000+10:00</published><updated>2011-07-24T21:40:16.851+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-24T21:40:16.851+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="I/O Psych" /><category scheme="http://www.blogger.com/atom/ns#" term="academia" /><title>Tips for Undergraduates Interested in a Career in Organisational Psychology: Australian Perspective</title><content type="html">&lt;p&gt;Undergraduate psychology students often ask me about careers in organisational
psychology.
This post aims to provide a few links and resources to assist such students to
learn about the profession and the career pathways.
The post includes (a) a basic description of organisational psychology, (b)
links to Australian educational and professional society resources, (c)
discussion of PhD and academic options, and (d) additional resources to learn
more about the profession.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview of Organisational Psychology&lt;/h3&gt;

&lt;h4&gt;What is the profession called?&lt;/h4&gt;

&lt;p&gt;Before discussing the profession some consideration should be given to what to
call it.
'Organisational psychology' goes by various names and abbreviations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Organisational Psychology (Org Psych) &lt;/li&gt;
&lt;li&gt;Industrial/Organisational Psychology (I/O or I/O Psych)&lt;/li&gt;
&lt;li&gt;Work Psychology&lt;/li&gt;
&lt;li&gt;Occupational Psychology &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different names imply both historical and present differences in focus. 
However, such terms are also often used interchangeably. 
See &lt;a href="
http://www.siop.org/userfiles/file/What's%20In%20A%20Name.pdf"&gt;SIOP's 'What's in a Name?'&lt;/a&gt;
article for an overview of various job titles.&lt;/p&gt;

&lt;p&gt;Names vary by region.
In the United States, "I/O" is preferred. 
In Australia, "Organisational Psychology" is arguably the more common term,
consistent with the APS college name and many course names.
Thus, I'll tend to use this term in this post.&lt;/p&gt;

&lt;h4&gt;What is organisational psychology?&lt;/h4&gt;

&lt;p&gt;Here are a few descriptions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Organisational Psychology is the science of people at work.  Organisational
psychologists specialise in analysing organisations and their people, and
devising strategies to recruit, motivate, develop, change and inspire." -
&lt;a href="
http://www.groups.psychology.org.au/Assets/Files/COP%20AGM%202008%20Reports.pdf
"&gt;prize winning elevator pitch (APS COP) &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Industrial / Organisational psychologists "Apply principles of psychology to
personnel, administration, management, sales, and marketing problems.
Activities may include policy planning; employee screening, training and
development; and organizational development and analysis.  May work with
management to reorganize the work setting to improve worker productivity. -
&lt;a href="
http://online.onetcenter.org/link/summary/19-3032.00"&gt;Industrial/Organisational Psychologist job description on O*N&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;"Industrial-organizational (I-O) psychology is the scientific study of the
workplace. Rigor and methods of psychology are applied to issues of critical
relevance to business, including talent management, coaching, assessment,
selection, training, organizational development, performance, and work-life
balance." - &lt;a href="http://www.siop.org/studentdefault.aspx"&gt;SIOP: Student Section&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The APS College of Organisational Psychology has a page that describes &lt;a href="
http://www.groups.psychology.org.au/cop/about_us/org_psychologists/"&gt;"What is an
organisational psychologist" and "Areas of Specialisation"&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Learning more about the profession:&lt;/h4&gt;

&lt;p&gt;A good strategy for learning more about the profession is to browse the various
society pages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://www.siop.org/default.aspx"&gt;SIOP - Division of the American Psychological Association&lt;/a&gt;: The United States is huge; and I/O
is huge in the United States. The SIOP web page has heaps of
useful online resources.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.bps.org.uk/dop/"&gt;Division of Occupational Psychology: British Psychological Society&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.groups.psychology.org.au/cop/"&gt;Australian Psychological Society: College of Organisational Psychologists&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Organisational Psychology in Australia&lt;/h3&gt;

&lt;h4&gt;Registration&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;"Psychologist" is a regulated term in Australia. 
It is illegal to call yourself a psychologist, if you are not appropriately registered.&lt;/li&gt;
&lt;li&gt;Pathways to registration are set out by the &lt;a href="
http://www.psychologyboard.gov.au/"&gt;Psychology Board of Australia&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The traditional pathway for registration has involved first completing a four
year accredited undergraduate psychology sequence, followed by either two
years of supervised practice or the completion of an accredited post-graduate
program (e.g., Masters, Doctorate, Masters / PhD).
Over recent years, rules for registration have been changing. 
So, make sure you do your own research.&lt;/li&gt;
&lt;li&gt;I should also mention that even if you can't call yourself a "psychologist",
completing an undergraduate major in psychology, particularly one with honours
in psychology (and perhaps also an undergraduate
subject in organisational psychology) can open doors to many roles related to
organisational psychology (e.g., HR, selection and recruitment,
marketing research, etc.).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Finding organisational psychology university programs in Australia:&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;a href="http://www.apac.psychology.org.au/"&gt;APAC accreditation site&lt;/a&gt; lists
approved postgraduate psychology programs. &lt;/li&gt;
&lt;li&gt;To find organisational psychology courses, last I checked, the following
worked
&lt;ul&gt;
&lt;li&gt;Click &lt;a href="
http://www.apac.psychology.org.au/Courses.aspx?ID=1045"&gt;Search for courses - Australia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Click on the State you want to search for&lt;/li&gt;
&lt;li&gt;Search for "&lt;code&gt;org&lt;/code&gt;"&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Groups and networking opportunities&lt;/h4&gt;

&lt;p&gt;&lt;a href="
http://www.groups.psychology.org.au/cop/"&gt;The Australian Psychological Society: College of Organisational Psychologists&lt;/a&gt; is the main group representing
organisational psychologists in Australia. &lt;br /&gt;
It is made up of various state branches. &lt;br /&gt;
The society sometimes runs sessions suited to students wanting to
learn more (e.g., careers fairs).&lt;/p&gt;

&lt;p&gt;A few informal online groups are also good places to learn more about the
profession in Australia. Both welcome professionals and students:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Facebook group: &lt;a href="http://www.facebook.com/group.php?gid=2355243978"&gt;Organisational Psychology in
Australia&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;LinkedIn group: &lt;a href="http://www.linkedin.com/groups?home=&amp;amp;gid=147918&amp;amp;trk=anet_ug_hm"&gt;Organisational Psychology in
Australia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Salary Surveys&lt;/h4&gt;

&lt;p&gt;There are many reasons to find a career in organisational psychology
intellectually stimulating and meaningful.
There has also often been financial reasons to find it attractive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://www.groups.psychology.org.au/Assets/Files/Salary_Survey_exec_summary.pdf"&gt;Australia: A slightly dated 2006 APS COP Salary survey&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.siop.org/surveys.aspx"&gt;United States: SIOP Salary surveys&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;A career in academia&lt;/h3&gt;

&lt;h4&gt;PhD on a topic related to organisational psychology or related area&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Doing a PhD on a topic related to organisational psychology can create
many opportunities.
Such a PhD can open up doors to academic positions in a wide range of
departments including, psychology, HRM, management, business, and so on.
The solid background in statistics and research methods provides a
particular advantage for an academic career.
Of course, academic positions are competitive and generally require a good
publication track record.&lt;/li&gt;
&lt;li&gt;Choosing a good PhD supervisor is important.
In addition to supervisors in departments that offer organisational psychology
programs, it's possible to look at supervisors in departments and universities
that don't offer such programs.&lt;/li&gt;
&lt;li&gt;The skills learnt can also readily be applied in many social science research
related roles in industry.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Examples of eminent organisational psychology academics&lt;/h4&gt;

&lt;p&gt;For those considering pursuing an academic career related to organisational
psychology, the &lt;a href="
http://www.siop.org/awardwinners.aspx"&gt;past SIOP award recipients&lt;/a&gt;,
particularly in the categories Distinguished Scientific Contribution, and
Distinguished Early Career Contribution, provide motivating examples of
successful I/O psychology researchers.&lt;/p&gt;

&lt;h4&gt;Example academic websites&lt;/h4&gt;

&lt;p&gt;The following links point to examples of successful academics in I/O psychology. &lt;br /&gt;
I also selected these particular pages because each one provides PDFs for many
of the respective academic's publications.
This can give a flavour of the kind of work, focus, and specialisation that an
academic in I/O might engage in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://users.ugent.be/~flievens/"&gt;Filip Lievens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.bsos.umd.edu/psyc/gelfand/research.html"&gt;Michele Gelfand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://iopsych.msu.edu/koz/main.htm"&gt;Steve Kozlowski&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.krannert.purdue.edu/directory/publications.asp?id=7090"&gt;Michael Campion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.management.wharton.upenn.edu/grant/"&gt;Adam Grant&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://people.tamu.edu/~mbarrick/pubs.htm"&gt;Murray Barrick&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Journals to read&lt;/h4&gt;

&lt;p&gt;Further understanding of the research done in organisational psychology and
related disciplines can be gained from reading some of the core journals.
A good starting point can be gained by perusing 
&lt;a href="
http://www.siop.org/tip/backissues/TipApr01/03Zicker.aspx"&gt;the following ranked list of journals generated by Michael Zickar and Scott
Highhouse&lt;/a&gt; back in
2001 based on a survey of SIOP members:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Journal of Applied Psychology&lt;/li&gt;
&lt;li&gt;Personnel Psychology&lt;/li&gt;
&lt;li&gt;Academy of Management Journal&lt;/li&gt;
&lt;li&gt;Academy of Management Review&lt;/li&gt;
&lt;li&gt;Organizational Behavior and Human Decision Processes&lt;/li&gt;
&lt;li&gt;Administrative Science Quarterly&lt;/li&gt;
&lt;li&gt;Journal of Management&lt;/li&gt;
&lt;li&gt;Journal of Organizational Behavior&lt;/li&gt;
&lt;li&gt;Organizational Research Methods&lt;/li&gt;
&lt;li&gt;Journal of Vocational Behavior&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Additional Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Richard Landers has a series of posts providing advice on pursuing a career in
I/O psychology from the U.S. perspective: 
&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://neoacademic.com/2011/06/14/grad-school-should-i-get-a-ph-d-or-masters-in-io-psychology/"&gt;PhD or Masters in I/O&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://neoacademic.com/2011/07/19/grad-school-prepping-for-the-gre/"&gt;Prepping for the GRE&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="http://neoacademic.com/io-blogosphere/"&gt;He also lists other I/O Blogs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.siop.org/tip/tip.aspx"&gt;TIP&lt;/a&gt; is the official newsletter of SIOP.
Current and back issues are available online and provide a good insight into
the profession including the interface between professional practice and
scientific research.&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-5256105903569404178?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=esBcKcl5u5c:Q0sUuWnAXqM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=esBcKcl5u5c:Q0sUuWnAXqM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=esBcKcl5u5c:Q0sUuWnAXqM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=esBcKcl5u5c:Q0sUuWnAXqM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=esBcKcl5u5c:Q0sUuWnAXqM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=esBcKcl5u5c:Q0sUuWnAXqM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=esBcKcl5u5c:Q0sUuWnAXqM:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=esBcKcl5u5c:Q0sUuWnAXqM:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=esBcKcl5u5c:Q0sUuWnAXqM:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/esBcKcl5u5c" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/5256105903569404178/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/07/tips-for-undergraduates-interested-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/5256105903569404178?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/5256105903569404178?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/esBcKcl5u5c/tips-for-undergraduates-interested-in.html" title="Tips for Undergraduates Interested in a Career in Organisational Psychology: Australian Perspective" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/07/tips-for-undergraduates-interested-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08GR3s9fyp7ImA9WhdTGU0.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-4431550921349913034</id><published>2011-07-17T22:30:00.000+10:00</published><updated>2011-07-17T22:30:26.567+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-17T22:30:26.567+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="SPSS" /><category scheme="http://www.blogger.com/atom/ns#" term="correlation" /><category scheme="http://www.blogger.com/atom/ns#" term="causation" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Correlation Resources: SPSS, R, Causality, Interpretation, and APA Style Reporting</title><content type="html">&lt;p&gt;This post provides links to a range of resources related to the use and
interpretation of correlations.
I wanted to provide a page with links to a number of additional resources that
would be useful both for those of my students who might be keen to learn more
and for anyone else who might be interested.
Specifically, this post provides links to:
(a) introductory book-style chapters on correlation,
(b) resources related to assorted issues in correlation (i.e., discussion of
causal inference, correlation with various variable types, range restriction,
statistical power, correlation interpretation, and significance testing),
(c) tutorials on computing correlations using SPSS and R, and
(d) tips for reporting correlations in APA Style.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;     

&lt;h3&gt;Introductions to correlation&lt;/h3&gt;

&lt;p&gt;The following provide general textbook style overviews of correlation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://davidakenny.net/statbook/chapter_16.pdf"&gt;David Kenny's Chapter 16 Testing Measures of Association&lt;/a&gt; provides a textbook overview
of correlation designed for psychology undergraduate students. 
It also includes several practice questions.
David Kenny has kindly made his &lt;a href="
http://davidakenny.net/statbook/"&gt;entire textbook 'Statistics for the Social
and Behavioral Sciences' available online for free&lt;/a&gt; as either an &lt;a href="http://davidakenny.net/statbook/kenny87.pdf"&gt;overall pdf&lt;/a&gt; or 
&lt;a href="http://davidakenny.net/statbook/"&gt;individual chapters&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.psychstat.missouristate.edu/introbook/sbk17m.htm"&gt;David Stockburger's Introductory Statistics chapter on Correlation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://web.psych.unimelb.edu.au/jkanglim/correlationandreggression.pdf"&gt;My own slides and notes on correlation&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Assorted Issues&lt;/h3&gt;

&lt;h4&gt;Correlation and Causation&lt;/h4&gt;

&lt;p&gt;Knowing how to reason about causality in the behavioural and social sciences is
a really important skill.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check out &lt;a href="
http://jeromyanglim.blogspot.com/2009/10/how-to-reason-about-causes-in.html"&gt;this earlier post on correlation and causation&lt;/a&gt;
which includes links to PDFs of important journal articles on the topic.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=6RzDMEW5omc"&gt;Joy of Stats on Correlation&lt;/a&gt;
provides a 4 minute video with a few entertaining examples of correlations and
their connection with causal inference.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Types of variables&lt;/h4&gt;

&lt;p&gt;The prototypical correlation example is based on two continuous, normally
distributed variables. 
However, in practice there are many other types of variables that you might
wish to correlate.
The following provide pages provide links to suggestions for how to analyse some
other common scenarios:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://stats.stackexchange.com/questions/3730/pearsons-or-spearmans-correlation-with-non-normal-data"&gt;What to do when one of the variables is non-normal?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://stats.stackexchange.com/questions/8956/spearmans-or-pearsons-correlation-with-likert-scales-where-linearity-and-homosc"&gt;What to do when one of the variables is a Likert item?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2009/10/analysing-ordinal-variables.html"&gt;What to do if you want to treat a variable as ordinal?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Range restriction&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;HyperStat has a general discussion of &lt;a href="http://davidmlane.com/hyperstat/A68809.html"&gt;range
restriction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;See this &lt;a href="http://cnx.org/content/m11196/latest/"&gt;simulation on connexions showing the effect of range
restriction&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Statistical Power&lt;/h4&gt;

&lt;p&gt;Statistical power within the context of correlation is the probability of
obtaining a statistically significant correlation in a study given that a true
correlation exists.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/05/statistical-power-analysis-in-gpower-3.html"&gt;This earlier post&lt;/a&gt;
provides (a) some simple rules of thumb for power analysis for correlations,
(b) how to calculate statistical power using free software called G-Power,
and (c) links to additional reading on the important topic of statistical
power.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Interpretation&lt;/h4&gt;

&lt;p&gt;When I first learnt about the correlation coefficient, I found it
challenging to truly grok what a particular value meant.
Learning the standard interpretation was easy. 
The challenging part was understanding the practical and theoretical
implications for a correlation of a given size.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The following are some of the &lt;strong&gt;standard interpretations&lt;/strong&gt; of a correlation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pearson's correlation is an index of the direction and strength of linear
association between two variables.&lt;/li&gt;
&lt;li&gt;The square of the correlation between X and Y is the percentage of
variance shared between X and Y (e.g., if &lt;code&gt;r = .50&lt;/code&gt;, then the two variables
share &lt;code&gt;.50 * .50 = 25%&lt;/code&gt; of variance).&lt;/li&gt;
&lt;li&gt;If X and Y were standardised (i.e., made so that the mean of both
variables was zero and the standard deviation was one) then, the
correlation would be the same as the regression coefficient of X
predicting Y or Y predicting X.
Thus, for example, if &lt;code&gt;r = .25&lt;/code&gt; you could say that "a value one standard deviation
greater on X predicts a .25 standard deviation greater value on Y".&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Strategies for &lt;strong&gt;building an intuition&lt;/strong&gt; of what a correlation means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Play with the &lt;a href="
http://www.ruf.rice.edu/~lane/stat_sim/reg_by_eye/"&gt;Regression by Eye&lt;/a&gt; simulation.
The simulation generates a scatterplot, and you are asked to indicate which of
a set of correlations corresponds to the scatterplot.
It helps to build a mapping between the graphical intuitiveness of a
scatterplot and the numeric summary of the linear association in the
scatterplot (i.e., the correlation coefficient).&lt;/li&gt;
&lt;li&gt;Memorise some of the rules of thumbs for describing correlation effect sizes
(see this &lt;a href="http://www.statisticshell.com/effectsizes.pdf"&gt;discussion by Andy
Field&lt;/a&gt;), but don't take the
rules of thumb too seriously.&lt;/li&gt;
&lt;li&gt;Try to build up a frame of reference for correlations in different contexts by
reading results sections. Meta analyses can also be particularly useful in
this regard.&lt;/li&gt;
&lt;li&gt;Read the article 'Meyer, G. J., et al (2001). Psychological Testing and Psychological
Assessment: A Review of Evidence and Issues. &lt;em&gt;American Psychologist, 56&lt;/em&gt;(2),
128-165.' (&lt;a href="https://mywebspace.wisc.edu/hmarleau/web/edwards/psychometrics/myers.pdf"&gt;PDF&lt;/a&gt;)
which provides large tables of meta-analytic correlations for a wide range of
medical and psychological domains sorted by the size of the correlation.
Studying these tables can help build an intuition and a context for
interpretation of correlations.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Graphical approaches&lt;/h4&gt;

&lt;p&gt;As with most statistical techniques, there are various ways of representing the
data. 
The correlation coefficient provides a very brief summary of the association
between two variables.
However, graphical representations of association are much richer.&lt;/p&gt;

&lt;p&gt;The following are some general heuristics that I find useful when plotting data
that might also be represented as a correlation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use scatterplots to explore features of the association (e.g., presence of
outliers, linearity, distributional properties, spread of data around any
trend line, etc.);&lt;/li&gt;
&lt;li&gt;If one of the variables is positively skewed, consider plotting the
corresponding axis on a log scale;&lt;/li&gt;
&lt;li&gt;If there are a lot of data points (e.g., &lt;code&gt;n &amp;gt; 1000&lt;/code&gt;), adopt a different strategy
such as using some form of partial transparency (e.g., see use of the &lt;a href="http://had.co.nz/ggplot2/geom_point.html"&gt;alpha
property in ggplot2&lt;/a&gt;), or sampling
the data;&lt;/li&gt;
&lt;li&gt;If one of the variables takes on a limited number of discrete categories,
consider using a jitter or a sunflower plot;&lt;/li&gt;
&lt;li&gt;If there are three or more variables, consider using a scatterplot matrix;&lt;/li&gt;
&lt;li&gt;Fitting some form of trend line is often useful;&lt;/li&gt;
&lt;li&gt;Adjust the size of the plotting character to the sample size (for bigger n,
use a smaller plotting character).&lt;/li&gt;
&lt;/ul&gt;

 &lt;!--http://stats.stackexchange.com/questions/13148/good-online-resource-with-tips-on-graphing-association-between-two-numeric-variab--&gt;

&lt;h4&gt;Significance tests on correlations&lt;/h4&gt;

&lt;p&gt;There are a wide range of possible significance tests that can be performed on
correlations.
The following links provide some suggestions and links for different scenarios.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2009/09/significance-tests-on-correlations.html"&gt;General post on comparing significance of two correlations&lt;/a&gt;
under various conditions.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.une.edu.au/WebStat/unit_materials/c6_common_statistical_tests/test_signif_pearson.html"&gt;Significance of correlation using Pearson's table&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Statistical Software&lt;/h3&gt;

&lt;p&gt;Calculating a correlation coefficient and its associated statistical
significance is a standard task that almost any statistical package can perform.
Many psychology students are taught to use SPSS. It is a proprietary (i.e., you
can't run it at home without a paid licence)
data analysis system with a strong empahsis on a GUI and making it easy to
perform various standardised analyses common in the social sciences.&lt;/p&gt;

&lt;p&gt;My preferred tool for performing data analysis is R.
It is open source (thus, you can run it at home for free) and is often described
as the lingua franca of statistics.  It generally requires a more sophisticated
understanding of statistics and computing to use effectively.
Thus, for the interested psychology student or researcher I have this 
&lt;a href="
http://jeromyanglim.blogspot.com/2009/06/learning-r-for-researchers-in.html"&gt;introduction to R for researchers in psychology&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Below I list resources for performing correlation analysis in SPSS and R.&lt;/p&gt;

&lt;h4&gt;SPSS&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.statisticshell.com/correlation.pdf"&gt;Andy Field has a chapter on correlation&lt;/a&gt;
which discusses correlation using SPSS. &lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=loFLqZmvfzU"&gt;This video tutorial on running and interpreting a correlation analysis using
SPSS&lt;/a&gt; goes for about 7 minutes
and is elementary.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;R&lt;/h4&gt;

&lt;p&gt;R makes it easy to perform correlations on datasets.
Specifically, the following links provide example syntax:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.statmethods.net/stats/correlations.html"&gt;Quick-R on correlations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.statmethods.net/graphs/scatterplot.html"&gt;Quick-R on scatterplots&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;More generally, William Revelle has some great resources on &lt;a href="http://personality-project.org/r/r.guide.html"&gt;R for
psychology&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Reporting Correlations in APA Style&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;APA Style Manual:&lt;/strong&gt; When required to report results using APA style, the
authoritative source is the &lt;a href="http://www.apastyle.org/"&gt;Publication Manual of the
APA&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Article Deconstruction:&lt;/strong&gt; Another general strategy is to find a journal
article that (a) reports a similar statistical test as you require, and (b)
that is published in an APA journal
or at least is in a journal that uses APA style.
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.apa.org/pubs/journals/"&gt;APA journals are listed here&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A quick search on &lt;a href="http://scholar.google.com.au/"&gt;Google Scholar&lt;/a&gt; will
often be sufficient and quicker, although PsycInfo (a subscription
service) is more reliable if you have access to it (many universities do).
E.g., a quick search for &lt;a href="http://scholar.google.com.au/scholar?hl=en&amp;amp;q=apa+%22significant+correlation+between%22+psychology&amp;amp;btnG=Search&amp;amp;as_sdt=0%2C5&amp;amp;as_ylo=&amp;amp;as_vis=0"&gt;apa "significant correlation between"
psychology&lt;/a&gt;
revealed several relevant articles and some with immediate PDF access.&lt;/li&gt;
&lt;li&gt;I also have a separate post on this general approach of &lt;a href="
http://jeromyanglim.blogspot.com/2009/09/introduction-to-journal-article.html"&gt;deconstructing
journal articles&lt;/a&gt;
to discern writing principles.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Correlation Matrices:&lt;/strong&gt; Many psychological studies, particularly those based on
correlational/observational designs, involve the measurement of a range of
numeric variables. 
It is particularly useful, and common, in such cases to report a correlation
matrix between sets of variables. 
I have a &lt;a href="
http://jeromyanglim.blogspot.com/2009/02/formatting-correlation-matrices-in.html"&gt;post with instructions on formatting a correlation matrix&lt;/a&gt;
in APA style using a combination of SPSS, Excel, and Word. 
The post also includes links to examples of correlation matrices being
reported.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://huberb.people.cofc.edu/Guide/Reporting_Statistics%20in%20Psychology.pdfs"&gt;General overview of reporting statistics including correlations using APA
style&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-4431550921349913034?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OETgt2G2uBQ:-dlkvfORfnk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OETgt2G2uBQ:-dlkvfORfnk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OETgt2G2uBQ:-dlkvfORfnk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OETgt2G2uBQ:-dlkvfORfnk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OETgt2G2uBQ:-dlkvfORfnk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OETgt2G2uBQ:-dlkvfORfnk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OETgt2G2uBQ:-dlkvfORfnk:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OETgt2G2uBQ:-dlkvfORfnk:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OETgt2G2uBQ:-dlkvfORfnk:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/OETgt2G2uBQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/4431550921349913034/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/07/correlation-resources-spss-r-causality.html#comment-form" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/4431550921349913034?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/4431550921349913034?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/OETgt2G2uBQ/correlation-resources-spss-r-causality.html" title="Correlation Resources: SPSS, R, Causality, Interpretation, and APA Style Reporting" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>4</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/07/correlation-resources-spss-r-causality.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0UNR3o-fSp7ImA9WhZVEU4.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-6254402501596748604</id><published>2011-05-23T16:14:00.000+10:00</published><updated>2011-05-23T16:14:56.455+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-23T16:14:56.455+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="computers" /><category scheme="http://www.blogger.com/atom/ns#" term="vim" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><title>Transition to Linux and Ubuntu: The Experience of a Quantitative Social Scientist</title><content type="html">&lt;p&gt;This post discusses my experience migrating to Ubuntu from Windows from the
perspective of a quantitatively oriented researcher in psychology.
It discusses (a) my general transition to open source tools for doing research;
(b) examination of Cygwin;
(c) choosing a Linux distribution;
(d) preparing for installation of Ubuntu;
(e) initial reflections on installing Ubuntu; and
(f) a long list of various solutions to specific problems that I encountered
whilst getting started with Ubuntu.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Context of transition&lt;/h3&gt;

&lt;p&gt;Anyone following this blog for a while will know that I've been progressively
migrating to using open source software for doing research.
My first foray into open source started in 2007 when I decided 
to replace SPSS with R.&lt;/p&gt;

&lt;p&gt;As is the case with many open source tools, they have a habit of mutually
reinforcing each other.
The path went something like this (with links pointing to associated blog
posts):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/search/label/LaTeX"&gt;LaTeX&lt;/a&gt; replaced Word as my
scientific document format.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/getting-started-with-markdown-benefits.html
"&gt;Markdown replaced Word&lt;/a&gt;
as my document format for note taking and informal documents.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/03/export-from-endnote-to-bibtex-jabref.html
"&gt;Bibtex, Jabref&lt;/a&gt;, and other tools replaced Endnote as a bibliographic reference
management system.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2011/01/reasons-for-transitioning-to-vim.html"&gt;Vim replaced a host of other IDEs&lt;/a&gt;, 
and text editors; it even replaced MS Word, in that it became the editor for
the plain text file formats (e.g., LaTeX, Sweave, Markdown, etc.) that I use the
most.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/getting-started-with-git-egit-eclipse.html
"&gt;git&lt;/a&gt; replaced ad hoc version control systems.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html
"&gt;&lt;code&gt;make&lt;/code&gt;&lt;/a&gt;
replaced various manual processes for building final products.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a general summary of this workflow (albeit, prior to the adoption of Vim),
&lt;a href="
http://jeromyanglim.blogspot.com/2010/12/video-of-reproducible-research-with-r.html
"&gt;see this video that I gave at Melbourne R Users in late 2010&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, I still needed to cut ties from Windows, the operating system I'd been
using for 15 years.
I'd been putting off adopting Linux for several reasons.
I was concerned about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;hardware support for my main computer,&lt;/li&gt;
&lt;li&gt;the temporary drop in performance that results from adopting a new operating
system,&lt;/li&gt;
&lt;li&gt;difficulties collaborating with other researchers operating in the Windows
world,&lt;/li&gt;
&lt;li&gt;lack of support for various key programs (e.g., Outlook; Inquisit), and&lt;/li&gt;
&lt;li&gt;the possibility that some tasks would be less efficient under Linux.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Despite these concerns, I decided to finally dive in.&lt;/p&gt;

&lt;h3&gt;Initial foray into Cygwin&lt;/h3&gt;

&lt;p&gt;About a month prior to making the switch I'd installed
&lt;a href="http://www.cygwin.com/"&gt;Cygwin&lt;/a&gt; on Windows.
This gave me access to many Linux command-line programs.
However, ultimately, while Cygwin whet my appetite, it failed to satisfy.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By default, Cygwin does not always play nicely with non-Cygwin programs.
File paths often get confused.
If it can't play nicely with Windows programs, I might as well go all the way.&lt;/li&gt;
&lt;li&gt;There are issues of where to store files (Cygwin home or Windows user home).&lt;/li&gt;
&lt;li&gt;Some Linux programs are not included.&lt;/li&gt;
&lt;li&gt;The speed of the terminal and shell was often poor.&lt;/li&gt;
&lt;li&gt;In general, interacting with other programs was a frustrating experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While some of these challenges probably could have been overcome, it felt silly
investing time in learning the idiosyncrasies of a system that only goes
half-way to creating a genuine unix experience.&lt;/p&gt;

&lt;h3&gt;Choosing a Linux distribution&lt;/h3&gt;

&lt;p&gt;The first decision involved choosing a Linux distribution.
I decided on Ubuntu for several reasons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's a popular Linux distribution.&lt;/li&gt;
&lt;li&gt;It seems like a good distribution for people new to Linux.&lt;/li&gt;
&lt;li&gt;Hardware support looked encouraging.&lt;/li&gt;
&lt;li&gt;I'd heard it was well suited as a personal desktop&lt;/li&gt;
&lt;li&gt;I'd also heard that ultimately Linux is configurable and thus, the
distribution does not provide major constraints; furthermore basic unix
command-line programs should work in all distributions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Preparing to install Ubuntu&lt;/h3&gt;

&lt;p&gt;I approached the installation of Ubuntu with trepidation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I read a lot about partitioning and dual-booting on &lt;a href="
https://help.ubuntu.com/community/HowtoPartition"&gt;Ubuntu documentation&lt;/a&gt; and &lt;a href="
http://www.psychocats.net/ubuntu/partitioning"&gt;psychocats&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;I backed up my data (of course) before starting installation.&lt;/li&gt;
&lt;li&gt;I thought a lot about setting up my partitions. 
In the end I decided on a dual-boot partition.
I have a solid state drive which is really fast, but capacity is not that high
(only 120gb).
Thus, I had to be careful with assigning space.
I gave 40gb to Windows and 80gb to Ubuntu.
This required the removal of many unwanted files from the Windows partition.&lt;/li&gt;
&lt;li&gt;I created and trialled the Ubuntu Live USB to check for hardware support, and
everything seemed to be working surprisingly well on my Dell Latitude laptop.&lt;/li&gt;
&lt;li&gt;I then installed Ubuntu, letting the Ubuntu installer handle the hard drive
partitioning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To my pleasant surprise, the installation was smooth, involving minimal choices.
The Ubuntu installation successfully partitioned my hard drive, and the core
features of my laptop still worked (sleep, hibernate, wifi, volume buttons,
graphics card, and so on).
Furthermore, I was still able to boot into Windows for when I really needed to
use Windows-only software.&lt;/p&gt;

&lt;h3&gt;Reflection on the installation&lt;/h3&gt;

&lt;p&gt;Switching operating systems is painful even when the new operating system
is better than the old one.
Many little tasks that were once automatic need to be automated in a new way.
Furthermore, to fully grok the new system, it is often necessary to do more than
map the old workflow onto the new system.&lt;/p&gt;

&lt;p&gt;For the most part the switch to Ubuntu has been smoother than I was expecting.
The first week involved dealing with a wide range of fundamental issues related
to software installation and system configuration.
However, in general, these issues have been resolved by a few Internet searches
and asking questions on &lt;a href="http://askubuntu.com/"&gt;Ask Ubuntu&lt;/a&gt; (a Stack
Exchange Q+A site).&lt;/p&gt;

&lt;p&gt;The following were some of the main issues I encountered:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linking with my university email / calendar Exchange server has been painful.
After two weeks, this still remains my biggest pain; The email program
Evolution basically works, but is painfully slow at times, often freezes, and
often produces errors.&lt;/li&gt;
&lt;li&gt;Configuring the Unity desktop (the default behaviour of the 11.04 launcher
is awful) took a bit of searching.&lt;/li&gt;
&lt;li&gt;Configuring so that I could move between laptop monitor configurations
required some fiddling.&lt;/li&gt;
&lt;li&gt;Configuring my &lt;code&gt;vimrc&lt;/code&gt; took some work. I had a number of file format issues
related to text files having inappropriate line feeds (i.e., Windows text
files instead of Unix text files).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Despite these issues I'm really enjoying using Ubuntu.
Adopting a Vim + command-line workflow is so much easier, and I'm gradually
incorporating some of the great Linux tools into my workflow.&lt;/p&gt;

&lt;h3&gt;Some reading&lt;/h3&gt;

&lt;p&gt;As part of the transition, I've also been reading a few books:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Harley Hahn's guide to Unix and Linux - Harley Hahn
&lt;ul&gt;
&lt;li&gt;This one was quite pedagogical in flavour and a bit wordy at times, but
did provide a helpful introduction to Linux.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;UNIX power tools - Jerry Peek, Tim O'Reilly, Mike Loukide
&lt;ul&gt;
&lt;li&gt;This book is massive. &lt;/li&gt;
&lt;li&gt;It provides heaps of short articles outlining useful tricks for getting
more out of Unix / Linux.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Learning the bash Shell - Cameron Newham, Bill Rosenblatt&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Looking forward&lt;/h3&gt;

&lt;p&gt;As I get settled into the new operating system I'm looking forward to 
really incorporating the tools available into my research workflow.&lt;/p&gt;

&lt;p&gt;Some of the things I'm looking forward to (which I may blog about at some point,
&lt;a href="
http://feeds.feedburner.com/jeromyanglim"&gt;see here for Blog RSS subscription options&lt;/a&gt;)
include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Writing some bash scripts and Vim commands to enable me to link bibtex
citations to stored pdfs of journal articles;&lt;/li&gt;
&lt;li&gt;Taking advantage of the command-line for file manipulation, running R,
creating LaTeX documents, and more; and&lt;/li&gt;
&lt;li&gt;Dabbling in sed, awk, Python for better text manipulation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now with the first two weeks of initial adjustment out of the way, the subtler
phase of tweaking and refinement begins.
If you've made the switch to Linux particularly within the context of research
and data analysis, I'd be keen to hear your experience.&lt;/p&gt;

&lt;h3&gt;Assorted Resolved Issues&lt;/h3&gt;

&lt;h4&gt;Overview&lt;/h4&gt;

&lt;p&gt;The rest of this post documents a wide range of problems that I encountered when
getting started with Ubuntu and the solutions that I adopted.
The caveat applies that I'm pretty new to Ubuntu, so the solutions may not
be best practice.
Furthermore, they may not make for interesting reading unless perhaps you've
stumbled onto this post through Google searching for the specific problem.&lt;/p&gt;

&lt;h4&gt;Overhaul file system&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What are the implications of Linux for how my file system should be organised?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;I used the transition to Linux to overhaul my file system.
I was keen to use the terminal to access files.
Good file names for terminal access are different to that for a point-and-click
environment.&lt;/p&gt;

&lt;p&gt;Some general principles that guided the new file system&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove spaces from file names 
&lt;ul&gt;
&lt;li&gt;It's a pain to have to escape spaces (&lt;code&gt;\&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;I replaced spaces with hyphen "-"&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Convert file names to lower case where possible
&lt;ul&gt;
&lt;li&gt;Linux is case sensitive&lt;/li&gt;
&lt;li&gt;It's quicker to type lower case&lt;/li&gt;
&lt;li&gt;Consistency reduces confusion&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Prefer file and folder names unique in the first few letters
&lt;ul&gt;
&lt;li&gt;This facilitates tab completion&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Prefer short, descriptive, and memorable file names&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also found it particularly useful to do a general reflection on my file
structure.
I cleaned up the hierarchy so that all my core activities had a location in the
file system.&lt;/p&gt;

&lt;h4&gt;Accessing Windows Drive from Ubuntu&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Are there any issues with accessing the Windows OS partition from Ubuntu?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;It's easy.
It shows up as a mounted drive called "OS".
It's path was &lt;code&gt;/media/OS&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Monitoring processes and use of system resources&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What is the Ubuntu equivalent of &lt;code&gt;Ctrl+Alt+Delete&lt;/code&gt; for viewing active
processes and memory and processor usage?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;There is a program called "System Monitor"&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Command prompt for terminal colour&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;It seems to me that it might be useful to make the command prompt a different
colour to help make it clear where one command starts and output begins a little
clearer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can this be done?&lt;/li&gt;
&lt;li&gt;What are good colour options?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Sites discussing the issue
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/"&gt;cyberciti&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.archlinux.org/index.php/Color_Bash_Prompt"&gt;archlinux wiki&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;.bashrc&lt;/code&gt; file that came with Ubuntu had a setting that could be enabled to
have a colour prompt.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Opening common binary files from command-line&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;How can common binary files (e.g., PDF, Word, Excel, PowerPoint) be opened
from the command line?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;gnome-open&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;This command can be followed by filenames, web addresses, directories, and
will typically do some appropriate default action.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gnome-open .&lt;/code&gt; opens the current directory in Nautilus&lt;/li&gt;
&lt;li&gt;&lt;code&gt;alias go=’gnome-open’&lt;/code&gt; or equivalent may be useful&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Keyboard shortcuts for size window left or right half of screen&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;I tend to work on a large monitor with space for Windows on the left and right
side of the screen.
I like to have a keyboard shortcut which sizes a window to the left or right of
the screen.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can this be done on Ubuntu?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Ubuntu does support half Desktop sizing by dragging a window with the mouse to
the left or right most side of the desktop.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;keyboard shortcuts&lt;/code&gt; offers some options for moving windows, including
maximise vertically or maximise horizontally, but no option for positioning
window on left half of screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;Ctrl+Alt+NumPad Key&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I learnt the &lt;a href="
http://askubuntu.com/questions/39740/is-there-a-unity-compiz-shortcut-key-to-move-a-window-to-your-other-monitor-no"&gt;following on
askubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;By default Ubuntu supports shortcut keys for window manipulation (e.g.,
&lt;code&gt;Ctrl+Alt+NumPad4&lt;/code&gt; maximises a window vertically on the left half of the
screen and &lt;code&gt;Ctrl+Alt+NumPad6&lt;/code&gt; does the same but to the right.&lt;/li&gt;
&lt;li&gt;The main annoying aspect of this is that these keys are not suitable for
touch typing.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Solution&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install Advanced Desktop Effects settings (Compiz with Compiz Config)&lt;/li&gt;
&lt;li&gt;Start CompizConfig&lt;/li&gt;
&lt;li&gt;Go to Window Manager - Grid&lt;/li&gt;
&lt;li&gt;Change the key bindings (I chose the following, which have a certain
consistency with Vim movement keys)
&lt;ul&gt;
&lt;li&gt;Super + h (left)&lt;/li&gt;
&lt;li&gt;Super + L (right)&lt;/li&gt;
&lt;li&gt;Super + K (maximise)&lt;/li&gt;
&lt;li&gt;Super + J (restore)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Shortcut key to initiate web search&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;On windows I had a global shortcut key (Windows+Z) to initiate a Google search.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can this be done on Ubuntu?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;googlizer&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;This can be used to create command line programs for searching.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Chrome
&lt;ul&gt;
&lt;li&gt;Start chrome&lt;/li&gt;
&lt;li&gt;Type search term in address bar&lt;/li&gt;
&lt;li&gt;Making &lt;code&gt;google.com&lt;/code&gt; the home page can speed this up&lt;/li&gt;
&lt;li&gt;Evaluation: 
&lt;ul&gt;
&lt;li&gt;The responsiveness of this is not adequate (a search box is instant;
chrome takes around 1 second to start up)&lt;/li&gt;
&lt;li&gt;It results in the loss of the default Chrome homepage&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;AutoKey
&lt;ul&gt;
&lt;li&gt;A program modelled on AutoHotKey might provide the desired functionality.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;I asked the &lt;a href="
http://askubuntu.com/questions/42398/shortcut-key-to-simple-textbox-to-perform-google-search
"&gt;question on askubuntu&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;Google Desktop Search with Desktop search disabled was a good choice.&lt;/li&gt;
&lt;li&gt;I changed the default shortcut key to &lt;code&gt;Ctrl+F12&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Using a laptop with multiple external monitors&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;How can a laptop monitor be disabled and an external monitor enabled?&lt;/li&gt;
&lt;li&gt;I use two external monitors, one at home, and one at work.
How can Ubuntu be configured to automatically detect which one is connected?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When I configure to just use my external monitor and not my laptop monitor and
then unplug the external monitor, the laptop monitor is not activated.
Thus, I can't use the mouse to reactivate the laptop monitor.
It would be good if Ubuntu could automatically detect the removal of the
external monitor, or alternatively I could have a shortcut key to activate
laptop only mode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://www.ubuntugeek.com/enable-ctrl-alt-backspace-in-ubuntukubuntu-10-04lucid-lynx.html"&gt;ubuntugeek&lt;/a&gt;
describes configuring Ubuntu so that &lt;code&gt;Ctrl+Alt+Backspace&lt;/code&gt; can force a restart
of X&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A user asks about automatic switching of monitor configurations on &lt;a href="
http://ubuntuforums.org/showthread.php?t=1712863"&gt;Ubuntu
forums&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://ubuntuforums.org/showthread.php?t=1074137"&gt;More suggestions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I asked the question on
&lt;a href=""http://askubuntu.com/questions/42390/one-click-shutdown-ubuntu-and-load-into-alternative-bootup"&gt;askubuntu&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I added my answer to the question&lt;/li&gt;
&lt;li&gt;Essentially it involves using a program called &lt;code&gt;disper&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;disper -s&lt;/code&gt; and &lt;code&gt;disper -S&lt;/code&gt; activate primary and secondary monitors
respectively. 
I've configured these commands to be triggered by shortcut keys using
CompizConfig.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Launching programs with keyboard shortcuts&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What is a good strategy for launching programs from keyboard shortcuts?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;CompizConfig makes it easy to create commands and assign shortcut keys.&lt;/li&gt;
&lt;li&gt;The Unity Launcher enables shortcut keys combining the Super key and a number
or typing the Super key and typing a key word.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Restart to Windows&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;My bootloader defaults to Ubuntu.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is there a way to shutdown Ubuntu and boot to Windows without having to make a
selection from the bootloader?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;I asked &lt;a href="
http://askubuntu.com/questions/42390/one-click-shutdown-ubuntu-and-load-into-alternative-bootup"&gt;the question on Ask Ubuntu&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;I received a good answer, and I added further details on AskUbuntu.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Default terminal size&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What is a good default Terminal size?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;I can always press F11 to get a full-screen terminal.
However, sometimes it is useful to be able to have a reasonable size terminal
come up that does not take over the whole screen.&lt;/p&gt;

&lt;p&gt;I've configured the default profile to be 95 columns by 40 rows.
I would choose more rows, but I want the setup to work on my smallest monitor
(i.e., my laptop).&lt;/p&gt;

&lt;h4&gt;Prevent Unity menu from showing&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;At first I thought the Unity menu was okay.
However, I don't like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the screen real estate that launcher consumes&lt;/li&gt;
&lt;li&gt;the way that it defaults to placing left aligned windows indented with space
to the launcher&lt;/li&gt;
&lt;li&gt;The size of the launcher icons (although at least this can be reduced)&lt;/li&gt;
&lt;li&gt;The way that it stays in focus sometimes for a period of time &lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;I asked &lt;a href="
http://askubuntu.com/questions/42473/how-to-make-unity-launcher-menu-be-almost-always-hidden-and-not-influence-window"&gt;the question on askubuntu&lt;/a&gt; and received a good suggestion.&lt;/p&gt;

&lt;p&gt;In Compix Config set Unity - Hide Launcher to Auto-hide.&lt;/p&gt;

&lt;h4&gt;Configuring Ubuntu for running basic scripts&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What is a basic strategy for running scripts in Ubuntu?&lt;/li&gt;
&lt;li&gt;How do permanently add the custom script to the path?&lt;/li&gt;
&lt;li&gt;Where should I store throw-away scripts?&lt;/li&gt;
&lt;li&gt;What is a good way to run custom scripts?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;There is a &lt;a href="http://ubuntuforums.org/showthread.php?t=654612"&gt;discussion of where to store scripts here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;A common place seems to be &lt;code&gt;~/bin&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I did the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;mkdir ~/bin&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;added &lt;code&gt;export PATH="$PATH:~/bin"&lt;/code&gt; to &lt;code&gt;.bashrc&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Find file by name&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;How can I find a file by a name or part of its name within a specified
directory (or subdirectories)?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cyberciti provides &lt;a href="
http://www.cyberciti.biz/tips/linux-findinglocating-files-with-find-command-part-1.html"&gt;a page explaining several options&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;find&lt;/code&gt; command&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The following command would find all files with the &lt;code&gt;txt&lt;/code&gt; extension in &lt;code&gt;~/dir&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;find ~/dir -name "*.txt"&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Accessing Ubuntu drive from Windows on dual-boot machine&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;I store my data on my Ubuntu drive.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can I access my Ubuntu drive from Windows?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;This &lt;a href="
http://www.psychocats.net/ubuntu/partitioning"&gt;page has three options&lt;/a&gt;, the last of which, looks like
what I want.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ext2 Installable File System for Windows
&lt;ul&gt;
&lt;li&gt;This did not work on Windows 7 (perhaps this will change in the future)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;DiskInternals Linux Reader
&lt;ul&gt;
&lt;li&gt;Evaluation
&lt;ul&gt;
&lt;li&gt;This worked adequately&lt;/li&gt;
&lt;li&gt;This has both the benefit and the problem that it does not alter the
Linux partition&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;How did it work?
&lt;ul&gt;
&lt;li&gt;Start Windows 7&lt;/li&gt;
&lt;li&gt;Install and Start DiskInternals&lt;/li&gt;
&lt;li&gt;Save selected Linux partition files onto Windows partition (I had a
special section)&lt;/li&gt;
&lt;li&gt;View, edit, and change files&lt;/li&gt;
&lt;li&gt;Restart Ubuntu and copy files from Windows partition back into
appropriate location &lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Script fur renaming files in folder&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;I sometimes download files sent to me and want to convert the file names into
more appropriate ones.&lt;/p&gt;

&lt;p&gt;The main conversions that I'd like to see are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;replace spaces with dashes ("-")&lt;/li&gt;
&lt;li&gt;replace uppercase with lower case&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Others may arise as time goes by.&lt;/p&gt;

&lt;p&gt;The script should take a list of file names.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can this be done?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;I wrote the following script and called it &lt;code&gt;cleannames&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/bash
for file in * ; do mv "$file" `echo "$file" | sed 's/ /-/g'`; done
for file in * ; do mv "$file" `echo "$file" | sed 's/.*/\L&amp;amp;/g'`; done
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Minimise current window with keyboard shortcut&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What is the keyboard shortcut to minimise a Window?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Alt+F9 minimises&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Alt+F10 maximise&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Launcher - System Settings - Shortcuts allows for custom shortcut keys&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Terminator Terminal&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Should I adopt Terminator Terminal?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;At present I'm using Gnome Terminal.&lt;/li&gt;
&lt;li&gt;Various reviews suggest that Gnome terminal is a reasonable option in terms of
speed and features.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Preventing automatic shading when watching flash videos&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;I had an ABC video on full screen and after a few minutes, Ubuntu shaded the
screen.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can this be prevented?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Power Management&lt;/code&gt; has some options&lt;/li&gt;
&lt;li&gt;I disabled the screensaver. That seemed to fix the problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Batch renaming of files&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;Unix is case sensitive.
It also encourages substantially greater use of the command-line.
As such, it is useful to adopt file naming conventions that make it easier to
work with files on the command-line.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can I batch rename files
&lt;ul&gt;
&lt;li&gt;replace underscore with dash&lt;/li&gt;
&lt;li&gt;replace upper case letter with corresponding lower case letter&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Some options
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;KRename&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;for&lt;/code&gt; loop
&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://lab.artlung.com/unix-batch-file-rename/"&gt;Tutorial on using for loops&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rename&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Convert underscore to dash:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;`for file in * ; do mv $file `echo $file | sed 's/_//'` ; done`
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Convert upper case letter
&lt;a href="http://www.ubuntu4life.com/lowercase_files_and_directories"&gt;This tutorial shows&lt;/a&gt;
how to use the convmv command.&lt;/p&gt;

&lt;h4&gt;Kill a program&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;Windows has Ctrl+Alt+Delete which facilitates killing a process.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What does Ubuntu involve?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;The system monitor lists processes and enables killing processes&lt;/li&gt;
&lt;li&gt;Ctrl+Alt+Backspace kills X (once this feature is activated)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Better console / terminal colours&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;The default background for Ubuntu terminal is a type of dark purple.
While it's "pretty", I find the contrast to be relatively low.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are better settings?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;I applied the following settings:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit - Preferences: 
&lt;ul&gt;
&lt;li&gt;Colors - Built-in schemes= white on black&lt;/li&gt;
&lt;li&gt;Background = solid colour&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;export TERM="xterm-256color"&lt;/code&gt; enables better colour support for Vim&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Problems displaying full screen video&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;I find that full screen video on YouTube seems to freeze.
How can this be fixed?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;p&gt;There is a &lt;a href="
http://www.youtube.com/watch?v=SeO8YytqEKE"&gt;tutorial on YouTube&lt;/a&gt; on how to fix this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo mkdir /etc/adobe
sudo su
sudo echo "OverrideGPUValidation = 1" &amp;gt;&amp;gt; /etc/adobe/mms.cfg"
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;Reducing Grub loader times&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;I think it would be useful to reduce the default grub display time to something
like 1 or 2 seconds.
I almost always boot to Ubuntu, and if I want to boot to Windows, I have a
command from within Ubuntu that changes the default boot for one occasion.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is this a good idea?&lt;/li&gt;
&lt;li&gt;How can I do this?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I think 2 seconds would make sense as this is long enough to easily enter
manual mode if I am watching carefully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;sudo vim/etc/default/grub&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;I modified the value of &lt;code&gt;GRUB_TIMEOUT&lt;/code&gt; and made it &lt;code&gt;GRUB_TIMEOUT=2&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sudo update-grub&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Set up git on Ubuntu&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;How do I configure git on Ubuntu?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;General information on configuring git and github on Linux is &lt;a href="http://help.github.com/linux-set-up-git/"&gt;available
here&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-6254402501596748604?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=AaLnhZaxf4k:7a7DgIHgSBE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=AaLnhZaxf4k:7a7DgIHgSBE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=AaLnhZaxf4k:7a7DgIHgSBE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=AaLnhZaxf4k:7a7DgIHgSBE:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=AaLnhZaxf4k:7a7DgIHgSBE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=AaLnhZaxf4k:7a7DgIHgSBE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=AaLnhZaxf4k:7a7DgIHgSBE:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=AaLnhZaxf4k:7a7DgIHgSBE:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=AaLnhZaxf4k:7a7DgIHgSBE:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/AaLnhZaxf4k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/6254402501596748604/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/05/transition-to-linux-and-ubuntu.html#comment-form" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/6254402501596748604?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/6254402501596748604?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/AaLnhZaxf4k/transition-to-linux-and-ubuntu.html" title="Transition to Linux and Ubuntu: The Experience of a Quantitative Social Scientist" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>12</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/05/transition-to-linux-and-ubuntu.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QESXg9cSp7ImA9WhZXFU8.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-2237580919241449465</id><published>2011-05-04T16:46:00.001+10:00</published><updated>2011-05-05T01:01:48.669+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-05T01:01:48.669+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Guide to Getting Started with R: 2011 Update</title><content type="html">&lt;p&gt;In mid-2009, I wrote a post on getting started with R. 
A lot has happened in the world of R over the last two years. 
New books, videos, online documentation, blogs and other resources have emerged. 
New community structures have emerged. 
As such I've given the guide a major overhaul both to increase its usability 
and acknowledge the many exciting changes in the world of R.  &lt;a href="
 http://jeromyanglim.blogspot.com/2009/06/learning-r-for-researchers-in.html
"&gt;The 
updated Guide to Getting Started with R is available here.&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-2237580919241449465?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=9ErBbpi-yN0:JJnOOlywrbc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=9ErBbpi-yN0:JJnOOlywrbc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=9ErBbpi-yN0:JJnOOlywrbc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=9ErBbpi-yN0:JJnOOlywrbc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=9ErBbpi-yN0:JJnOOlywrbc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=9ErBbpi-yN0:JJnOOlywrbc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=9ErBbpi-yN0:JJnOOlywrbc:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=9ErBbpi-yN0:JJnOOlywrbc:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=9ErBbpi-yN0:JJnOOlywrbc:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/9ErBbpi-yN0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/2237580919241449465/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/05/guide-to-getting-started-with-r-2011.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2237580919241449465?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2237580919241449465?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/9ErBbpi-yN0/guide-to-getting-started-with-r-2011.html" title="Guide to Getting Started with R: 2011 Update" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/05/guide-to-getting-started-with-r-2011.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMFR349eSp7ImA9WhZQF0w.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-6319574097972116689</id><published>2011-04-25T17:26:00.000+10:00</published><updated>2011-04-25T17:26:56.061+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-25T17:26:56.061+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vim" /><category scheme="http://www.blogger.com/atom/ns#" term="Inquisit" /><title>Case Study in Customising Syntax Highlighting and Folding in Vim for a Niche Scripting Language Called Inquisit</title><content type="html">&lt;p&gt;This post presents my efforts to setup a productive environment for editing
Inquisit scripts in Vim.
In addition to being relevant to people who write Inquisit scripts, the post
is designed as a general case study in customising Vim for a niche
programming language.
Specifically, the post discusses how to setup in Vim:
(a) code folding using a custom expression,
(b) custom syntax highlighting, and
(c) interactions with the command-line.
&lt;a name='more'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;Inquisit is proprietary software typically used for running computerised
experiments in the behavioural sciences.
The &lt;a href="http://www.millisecond.com/"&gt;Inquisit Website&lt;/a&gt; has further explanation
and includes a free limited trial.
I have previously discussed the benefits of the software for &lt;a href="
http://jeromyanglim.blogspot.com/2009/10/practical-tips-on-how-to-conduct_05.html"&gt;running online
psychological experiments&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Inquisit includes desktop software that runs on Windows.
It can be used to write, debug, and run Inquisit scripts that control the
flow of the experiment.
I have provided a simple example of a script here as a &lt;a href="
https://gist.github.com/938629"&gt;gist on github&lt;/a&gt;.
It contains a simple RT task, four choice RT task, and a typing test.
Further example scripts can be seen in the &lt;a href="http://www.millisecond.com/download/samples/"&gt;Task Library on the Inquisit
Website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;More recently I have started using Vim to do my text editing (see &lt;a href="
http://jeromyanglim.blogspot.com/2011/01/reasons-for-transitioning-to-vim.html"&gt;my
previous post on this conversion&lt;/a&gt;.
The conversion was motivated by an aim to increase the power and consistency
of my text editing environment. 
Thus, instead of using a separate text editor for each programming language
that I code in, I wanted, as much as possible to be able to use Vim
for as many tasks as possible.&lt;/p&gt;

&lt;p&gt;Vim has great built-in support for many languages, however, Inquisit is a
niche scripting language.
Thus, Vim lacked built-in support for the language.
Nonetheless, to true power of Vim is its customisability.&lt;/p&gt;

&lt;p&gt;Below I explain the customisations I developed to work more effectively with
Inquisit.
It is still a work in progress, and imperfect. 
However, even at this stage, I find writing Inquisit scripts far more
enjoyable than using the editor built-in to the Inquisit software.&lt;/p&gt;

&lt;p&gt;I present this example as a case study in customising Vim for a new
programming language.&lt;/p&gt;

&lt;p&gt;If you want to follow any updates, check out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the git repository with the entire contents of my &lt;a href="
https://github.com/jeromyanglim/JA_Vimfiles"&gt;vimfiles and plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;inside the repository is my &lt;a href="
https://github.com/jeromyanglim/JA_Vimfiles/blob/master/myvimrc"&gt;vimrc&lt;/a&gt;
which includes various customisations for Inquisit file types.&lt;/li&gt;
&lt;li&gt;my syntax highlighting file for &lt;a href="
https://github.com/jeromyanglim/JA_Vimfiles/blob/master/syntax/inquisit.vim"&gt;Inquisit files&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Below I describe a few of these customisations.
The sections of greatest general interest are likely to be those on syntax
highlighting and code folding.&lt;/p&gt;

&lt;h3&gt;Overview of an Inquisit script&lt;/h3&gt;

&lt;p&gt;Before describing my customisations, below is a short snippet from an
Inquisit script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# general stimuli
&amp;lt;text cross&amp;gt;
/position=(50%, 50%)
/items=("+")
/fontstyle = ("Arial", 60pt, false)
&amp;lt;/text&amp;gt;

&amp;lt;text error.toosoon&amp;gt;
/position=(50%, 50%)
/items=("PRESSED TOO SOON")
/fontstyle = ("Arial", 30pt, false)
/txcolor =(255,0,0)
&amp;lt;/text&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The line beginning with a hash is my own internal section marker.
All text outside element tags &lt;code&gt;&amp;lt;...&amp;gt;...&amp;lt;/...&amp;gt;&lt;/code&gt; is not interpreted by
Inquisit.&lt;/li&gt;
&lt;li&gt;The code is made up of elements which have a keyword name (e.g., &lt;code&gt;text&lt;/code&gt;)
and an identifier (e.g., &lt;code&gt;cross&lt;/code&gt; or &lt;code&gt;error.toosoon&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;In the above example, these elements are used to represent objects
displayed on a screen such as a plus symbol or some text.&lt;/li&gt;
&lt;li&gt;Elements have attributes, which have a name and a value.
Attributes are contained between opening (e.g., &lt;code&gt;&amp;lt;text ...&amp;gt;&lt;/code&gt;) and closing
element tags (e.g., &lt;code&gt;&amp;lt;/text&amp;gt;&lt;/code&gt;).
Attributes begin with a slash, then the name of the attribute (e.g.,
&lt;code&gt;position&lt;/code&gt;, then equals sign, and then the value of the attribute.&lt;/li&gt;
&lt;li&gt;Values of attributes have various syntactical forms typically involving
either parentheses or square brackets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My scripts often range between 500 and 2000 lines of code.
For a more complete example, see the &lt;a href="
https://gist.github.com/938629"&gt;gist mentioned earlier&lt;/a&gt;.
You can even download a free trial of the software if you'd like to see how
it runs.
The remainder of this post describes the customisations that I developed to
make writing Inquisit scripts in Vim more productive.&lt;/p&gt;

&lt;h3&gt;Launching an Inquisit Script from Vim&lt;/h3&gt;

&lt;h4&gt;Question&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;How can Inquisit Scripts be tested directly from Vim command-line?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Discussion&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://www.millisecond.com/support/docs/v3/html/howto/howtocommandline.htm"&gt;Inquisit Help lists command line options&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I adopted the following strategy.
First, I added the Inquisit executable to the path; E.g., I added 
&lt;code&gt;C:\Program Files\Millisecond Software\Inquisit 3&lt;/code&gt; to my path.
This means that entering &lt;code&gt;inquisit&lt;/code&gt; on the command-line starts Inquisit.&lt;/p&gt;

&lt;p&gt;Then I added the following code to my &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function! RunInquisit()
    let cmdstring = "!start inquisit " . '"%:p"'
    exe cmdstring
endfunction
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Thus, when I have an Inquisit script open in Vim, I just have to type
&lt;code&gt;:call RunInquisit()&lt;/code&gt; and this will start Inquisit and send the script in
the active buffer to Inquisit for running. 
Once run, this enables debugging of any errors (Inquisit has a good
built-in debugger). 
If no errors are obtained, the experiment will start, which facilitates
the identification of errors in the actual design of the experiment.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;function!&lt;/code&gt; declares a new function overriding any previous function by
the same name.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;RunInquisit()&lt;/code&gt; is the arbitrary name of the function, although it does
need to start with a capital letter. In this case, it takes no arguments.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;let cmdstring...&lt;/code&gt; assigns a string to the variable &lt;code&gt;cmdstring&lt;/code&gt;.
The period (&lt;code&gt;.&lt;/code&gt;) is the concatenation operator.
&lt;code&gt;!start&lt;/code&gt; is means of starting a program from the command line asynchronously.
&lt;code&gt;inquisit&lt;/code&gt; is the name of the Inquisit executable.
&lt;code&gt;%:p&lt;/code&gt; is a file modifier pattern where &lt;code&gt;%&lt;/code&gt; represents the active buffer
and &lt;code&gt;:p&lt;/code&gt; indicates that the pattern should be replaced with the file name
with complete path for the active buffer. See &lt;code&gt;:h filename-mod&lt;/code&gt; for more
information.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;exe&lt;/code&gt; executes the string on the Vim command-line.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Code Folding&lt;/h3&gt;

&lt;h4&gt;Question&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;What is a useful strategy for code folding for Inquisit Scripts?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;General discussion of code folding&lt;/h4&gt;

&lt;p&gt;I'm a huge fan of code folding in general, and in Vim specifically.
When done appropriately, code folding provides many benefits.
In particular, it makes large files easier to navigate, and it makes it
easier to get an overview of the contents of a file.&lt;/p&gt;

&lt;p&gt;After some reflection I have a few principles that I use to guide the design
of a folding scheme.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use the language
&lt;ul&gt;
&lt;li&gt;Folds should where possible take advantage of natural markers in the
programming language.&lt;/li&gt;
&lt;li&gt;Using built-in markers means that time does not need to be allocated
to the task of managing the creation of folds.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Use unobtrusive markers
&lt;ul&gt;
&lt;li&gt;When markers are used that are not part of the language, they should
be simple an unobtrusive.&lt;/li&gt;
&lt;li&gt;Markers should not accidentally occur.&lt;/li&gt;
&lt;li&gt;This typically involves taking advantage of the commenting system in
the language.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Two or three fold levels is typically sufficient
&lt;ul&gt;
&lt;li&gt;Too many folds creates navigational issues whereby excessive time is
spent navigating between folds.&lt;/li&gt;
&lt;li&gt;As a general rule I like it when the lowest level of folding contains
at least 5 or more lines and not much more than a page or page and a
half of text.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Avoid Fold-1 - text - Fold-2 pattern
&lt;ul&gt;
&lt;li&gt;I.e., when a fold is expanded, there should not be a passage of
expanded text and then a lower level fold.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Inquisit scripts and code folding&lt;/h4&gt;

&lt;p&gt;Inquisit scripts are made up of elements that look somewhat like HTML.
Good coding practice suggests grouping related elements into sections.
This lead me to adopt the following folding scheme.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Level 1 folds
&lt;ul&gt;
&lt;li&gt;These are lines that begin with a single hash &lt;code&gt;#&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;As such they are not defined by the language, but the language permits
putting almost any text outside elements. &lt;/li&gt;
&lt;li&gt;They are designed to represent logical groups of Inquisit elements.&lt;/li&gt;
&lt;li&gt;I typically have sections for:
&lt;ul&gt;
&lt;li&gt;Experiment: a section that sets out any experiment level
information such as global variables, data format, random
allocation of subjects, and so forth.&lt;/li&gt;
&lt;li&gt;Blocks: a section that sets out each block in the experiment .&lt;/li&gt;
&lt;li&gt;One for each block: a section that contains all the trials,
stimuli, and item code for a given block.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Level 2 folds
&lt;ul&gt;
&lt;li&gt;These represent each element.&lt;/li&gt;
&lt;li&gt;Thus, they are automatically created by the language.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;My code implementing folding for Inquisit scripts&lt;/h4&gt;

&lt;p&gt;The code below achieves this design.
It is placed in my &lt;code&gt;vimrc&lt;/code&gt; file.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function! InquisitLevel(elements)
    " elements: 0 or 1
    if getline(v:lnum) =~ '^# .*$'
        return "&amp;gt;1"
    endif
    if a:elements &amp;amp;&amp;amp; getline(v:lnum) =~ '^&amp;lt;[a-zA-Z].*$'
        return "&amp;gt;2"
    endif
    return "=" 
endfunction                  
au BufEnter *.exp setlocal foldexpr=InquisitLevel(1)
au BufEnter *.exp setlocal foldmethod=expr
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;It contains a function that takes an argument called &lt;code&gt;elements&lt;/code&gt;.
If it is 0, then only section headings are folded and not elements.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;getline&lt;/code&gt; is a Vim function that returns the content of a line.
In this case &lt;code&gt;v:lnum&lt;/code&gt; is used by &lt;code&gt;expr&lt;/code&gt; fold method to indicate a
particular line number.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;=~&lt;/code&gt; is a logical operator that sees whether the text on the left is
matched by the regular expression on the right.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;'^# .*$'&lt;/code&gt; means match from the start of the line (&lt;code&gt;^&lt;/code&gt;) where the hash
character is in the first column, followed by a space, and then any number
(&lt;code&gt;*&lt;/code&gt;) of characters (&lt;code&gt;.&lt;/code&gt;) followed by the end of the line ( &lt;code&gt;$&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If such a match does occur, then &lt;code&gt;return "&amp;gt;1"&lt;/code&gt; which means that heading 1
starts on that line.
See &lt;code&gt;h fold-expr&lt;/code&gt; for more information.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a:elements&lt;/code&gt; is a variable that contains the value of the argument
&lt;code&gt;elements&lt;/code&gt; passed to the function.
The &lt;code&gt;a:&lt;/code&gt; is a necessary prefix for arguments.
In Vim 0 is false and 1 is true.
The double ampersand (&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;) is the logical AND operator.&lt;/li&gt;
&lt;li&gt;The second match matches lines that begin (&lt;code&gt;^&lt;/code&gt;) with the less than sign
followed by at least one alphabetical character and then any number of
additional arbitrary characters.
This provides a simple way that adequately matches for my purposes the
start of Inquisit elements.&lt;/li&gt;
&lt;li&gt;Thus, if &lt;code&gt;elements&lt;/code&gt; is non-zero and there is a match, this line is the
start of a level 2 heading (&lt;code&gt;"&amp;gt;2"&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;If no matches are obtained, a value of &lt;code&gt;=&lt;/code&gt; is returned, which tells &lt;code&gt;expr&lt;/code&gt;
to use the fold level of the previous line. &lt;/li&gt;
&lt;li&gt;The code is set up automatically using the two &lt;code&gt;au&lt;/code&gt; commands.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;BufEnter *.exp&lt;/code&gt; is an event that occurs when the buffer is entered
through file opening or buffer switching.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;*.exp&lt;/code&gt; is a file name filter. Thus, the command only works once the file
has a file names.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;foldexpr&lt;/code&gt; is a Vim setting that takes a custom function that determines
fold levels.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;foldmethod&lt;/code&gt; is a Vim setting that indicates the type of folding to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Using code folding&lt;/h4&gt;

&lt;p&gt;The main keys that I use for code folding are as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;zj&lt;/code&gt; an &lt;code&gt;zk&lt;/code&gt; 
&lt;ul&gt;
&lt;li&gt;to move the cursor down and up between fold headings.&lt;/li&gt;
&lt;li&gt;This is not needed when text is already folded, but is useful when the
cursor is expanded text and I want to get the cursor to the previous
or next fold.&lt;/li&gt;
&lt;li&gt;I often use &lt;code&gt;zjzx&lt;/code&gt; to move down and show only the next fold.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zc&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to close a fold.&lt;/li&gt;
&lt;li&gt;I often follow this up with &lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; to navigate over folds.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zx&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to show only the current fold.&lt;/li&gt;
&lt;li&gt;It is an awesome command that I use all the time. 
It functions like magnifying glass zooming in on the code of interest
while at the same time providing hierarchical context.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zM&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to close all folds to level 1.&lt;/li&gt;
&lt;li&gt;I often use &lt;code&gt;zMzx&lt;/code&gt; when folds have been expanded. This then gives the
effect of only showing the active fold.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zR&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to expand all folds.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;zO&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;to expand a single fold and its sub-folds.&lt;/li&gt;
&lt;li&gt;I often use this when a section of text has more folds than is
desirable.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Syntax highlighting&lt;/h3&gt;

&lt;h4&gt;Question&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;What is a basic syntax highlighting system for Inquisit scripts?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Basic installation instructions&lt;/h4&gt;

&lt;p&gt;If all you want to do is make use of my syntax highlighting for Inquisit
files, follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Copy my syntax highlighting file for &lt;a href="
https://github.com/jeromyanglim/JA_Vimfiles/blob/master/syntax/inquisit.vim
"&gt;Inquisit files&lt;/a&gt; into your syntax directory in your custom vimfiles directory.&lt;/li&gt;
&lt;li&gt;Add the following command to your vimrc file &lt;code&gt;au BufEnter *.exp set ft=inquisit&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;It creates a file type called &lt;code&gt;inquisit&lt;/code&gt; that then lets Vim know that
it should apply the Inquisit syntax highlighting.&lt;/li&gt;
&lt;li&gt;Note that it assumes that you are using the standard &lt;code&gt;*.exp&lt;/code&gt; file
extension.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Screenshots&lt;/h4&gt;

&lt;p&gt;The following are some screenshots showing what the folding and syntax
highlighting look like with a &lt;code&gt;molokai&lt;/code&gt; colour scheme.&lt;/p&gt;

&lt;h5&gt;Image with sections folded&lt;/h5&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/DAWP2.png" title="image with sections folded" /&gt;&lt;/p&gt;

&lt;h5&gt;Image of folding with element expanded&lt;/h5&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/i2UwW.png" title="imge of folding with element
expanded" /&gt;&lt;/p&gt;

&lt;h5&gt;Basic image of the syntax highlighting&lt;/h5&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/DPIqa.png" title="basic image of the syntax
highlighting" /&gt;&lt;/p&gt;

&lt;h4&gt;Overview of writing the syntax highlighting file&lt;/h4&gt;

&lt;p&gt;Before describing the syntax file in more detail, I should present a
few caveats.
I am new to syntax files in Vim, and I am far from a master in regular
expressions.
I hacked out a syntax highlighting scheme that works for me, adequately.
It is far from perfect.
But I guess that's a lesson in itself when it comes to using Vim.
Vim allows for near infinite customisation, but you have to consider the
return on investment of any customisation efforts.&lt;/p&gt;

&lt;p&gt;In general, when developing the syntax file I had a look through a few
example syntax files for what I thought might be similar file types.
For every command that I did not understand I did Vim help searches.
And in general I just fiddled around with a sample Inquisit file open until
I got something that basically worked.
For people needing a little more regular expression training, there's a
great &lt;a href="http://vimregex.com/"&gt;Vim-oriented tutorial here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Discussion of the syntax highlighting file&lt;/h4&gt;

&lt;p&gt;At the top of the file was the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syntax case ignore
syn clear
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;This tells Vim that syntax highlighting should be case insensitive&lt;/li&gt;
&lt;li&gt;&lt;code&gt;syn clear&lt;/code&gt; clears any existing syntax highlighting applied to the file, although this
is often not required.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The syntax file then contains many &lt;code&gt;syn keyword&lt;/code&gt; commands, such as the
following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syn keyword inquisitElementKeyword contained survey 
syn keyword inquisitElementKeyword contained surveypage 
syn keyword inquisitElementKeyword contained textbox 
...
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Words like &lt;code&gt;survey&lt;/code&gt;, &lt;code&gt;surveypage&lt;/code&gt;, etc. are all element names and keywords
within the language.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;keyword&lt;/code&gt; is a simple form of matching that matches the keyword
exactly without resorting to patterns.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;inquisitElementKeyword&lt;/code&gt; is a grouping name which I use later to assign
colours and show where such keywords are contained.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;contained&lt;/code&gt; keyword allows the scope of keywords to
be limited to only situations where they are contained within some other
syntactical structure.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The syntax file then contains code for matching operators, an example of
which is shown below:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syn match inquisitOperator contained "||"
syn match inquisitOperator contained "&amp;amp;&amp;amp;"
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;This involved using the &lt;code&gt;match&lt;/code&gt; approach. 
This was required because the characters in operators are not alphabetical
characters.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I then added code to syntax highlight numbers.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syn match inquisitNumber contained "\&amp;lt;[0-9%][0-9%]*"
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The code shows the diverse options that &lt;code&gt;match&lt;/code&gt; provides.
It matches one or more numbers or the percent sign.
The combination of backslash and less-than-sign means that numbers must be
at the start of what Vim sees as a word.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then came some code to represent regions of text&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syn region inquisitString start=+"+ end=+"+
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The above code defined a &lt;code&gt;region&lt;/code&gt; based on quotation marks.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The plus sign is used as an alternate delimiter in order to indicate that 
the double quotes are the actual text used to match the start and end of
the region.&lt;/p&gt;

&lt;p&gt;syn region inquisitElementBlock start="&amp;lt;..*&gt;" end="&lt;/..*&gt;" transparent &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The above code represents an Inquisit element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;The similarity with HTML tags may be apparent. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;code&gt;transparent&lt;/code&gt; keyword is used to indicate that this merely represents
a logical unit and does not impose any actual syntax highlighting.&lt;/p&gt;

&lt;p&gt;syn region inquisitAttributeKeyword contained start="\&amp;lt;" end="&gt;" 
syn region inquisitAttributeRegion start="\/" end="=" oneline contains=inquisitAttributeKeyword&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The above code creates a quick and dirty way of highlighting attribute
names in elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Such attribute names always appear as a word contained between a slash and
an equals sign.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;\&amp;lt;&lt;/code&gt; and &lt;code&gt;\&amp;gt;&lt;/code&gt; match the start and end of a word, but this is contained.&lt;/li&gt;
&lt;li&gt;The second line indicates that the first line is contained in it.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;oneline&lt;/code&gt; keyword ensures that the match occurs entirely on one line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After some additional code comes the assignment of colours to groups.
The following are a few examples:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;hi link inquisitElementKeyword Keyword
hi link inquisitOperator Operator
hi link inquisitDelimiter Delimiter  
hi link inquisitString Character
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Each command creates a highlighting link between the custom groups created
in the script and a common logical highlighting object used by many colour
schemes. &lt;/li&gt;
&lt;li&gt;In case you were interested, I use &lt;code&gt;molokai&lt;/code&gt; as my default colour scheme.
It is a popular dark scheme &lt;a href="
http://www.vim.org/scripts/script.php?script_id=2340"&gt;available from vim.org&lt;/a&gt;, and from &lt;a href="http://winterdom.com/2008/08/molokaiforvim"&gt;Thomas
Restrepo's blog&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Getting Inquisit Help while in Vim&lt;/h3&gt;

&lt;h4&gt;Question&lt;/h4&gt;

&lt;p&gt;Inquisit provides clear and well-organised documentation.
In Desktop Inquisit, pressing F1 in a script brings up the help for the
element under the cursor.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How can I make it easy to get help on Inquisit commands while continuing to
work within Vim?&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Discussion&lt;/h4&gt;

&lt;p&gt;The simplest strategy is just to keep a copy of the Inquisit help file open
while coding and type in search terms directly.
In the end, I have found this to be quite adequate.
However, I record some thoughts and ideas I explored for more automated
approaches below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;HH "C:\Program Files\Millisecond Software\Inquisit 3\inquisit.chm"&lt;/code&gt; will open
Inquisit help (at least on my system given my installation path and version).&lt;/li&gt;
&lt;li&gt;Alternatively there is a online version of help: 
&amp;lt; http://www.millisecond.com/support/docs/v1/index.htm &gt;&lt;/li&gt;
&lt;li&gt;I asked &lt;a href="
http://stackoverflow.com/questions/4976872/command-line-options-for-hh-and-opening-chm-windows-help-files"&gt;a question on StackOverflow&lt;/a&gt;
for more information.&lt;/li&gt;
&lt;li&gt;I installed &lt;a href="http://www.keyworks.net/keyhh.htm"&gt;keyhh&lt;/a&gt;.
The following command basically did the trick:
&lt;code&gt;keyhh -#klink "data element" c:\Program Files\Millisecond Software\Inquisit 3\inquisit.chm&lt;/code&gt;
where &lt;code&gt;"data element"&lt;/code&gt; is a hypothetical search term.&lt;/li&gt;
&lt;li&gt;I also found &lt;a href="
https://github.com/vim-scripts/winhelp"&gt;this vimscript&lt;/a&gt;
designed to assist interaction with chm help files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Future refinements&lt;/h3&gt;

&lt;p&gt;In the future I may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improve the syntax highlighting&lt;/li&gt;
&lt;li&gt;Introduce an Inquisit code formatting customisation&lt;/li&gt;
&lt;li&gt;Improve integration with the Inquisit language particularly with regard to
attributes&lt;/li&gt;
&lt;li&gt;Develop code that facilitates writing Inquisit scripts, such as sequences
of numbers for trial and block sequences&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;General lessons Learnt&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Tinkering with the syntax highlighting, folding, and command-line
interaction in Vim encouraged me to think more deeply about each feature
and how the feature could be optimised for my workflow.&lt;/li&gt;
&lt;li&gt;The ability to customise Vim as I have done here validates my decision to
adopt Vim. Vim encourages the development of amazing text editing shortcut
keys; the more they can be applied to the languages that I write in, the
better.&lt;/li&gt;
&lt;li&gt;Investment in customisation pays off both in terms of (a) making the immediate
task of programming in the given language easier, and (b) making it easier
to customise other languages in the future.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Additional Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2011/01/reasons-for-transitioning-to-vim.html"&gt;My Conversion to Vim&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2009/10/practical-tips-on-how-to-conduct_05.html"&gt;Conducting an online experiment with Inquisit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-6319574097972116689?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Vn01-zPQZdU:61iEFKb4gEY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Vn01-zPQZdU:61iEFKb4gEY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=Vn01-zPQZdU:61iEFKb4gEY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Vn01-zPQZdU:61iEFKb4gEY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Vn01-zPQZdU:61iEFKb4gEY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=Vn01-zPQZdU:61iEFKb4gEY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Vn01-zPQZdU:61iEFKb4gEY:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=Vn01-zPQZdU:61iEFKb4gEY:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Vn01-zPQZdU:61iEFKb4gEY:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/Vn01-zPQZdU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/6319574097972116689/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/04/case-study-in-customising-syntax.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/6319574097972116689?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/6319574097972116689?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/Vn01-zPQZdU/case-study-in-customising-syntax.html" title="Case Study in Customising Syntax Highlighting and Folding in Vim for a Niche Scripting Language Called Inquisit" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/04/case-study-in-customising-syntax.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkYAR3o-fip7ImA9WhZRGEo.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-8200857994209942209</id><published>2011-04-16T00:09:00.001+10:00</published><updated>2011-04-16T00:35:46.456+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-16T00:35:46.456+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vim" /><category scheme="http://www.blogger.com/atom/ns#" term="markup" /><category scheme="http://www.blogger.com/atom/ns#" term="thinking" /><category scheme="http://www.blogger.com/atom/ns#" term="Word" /><title>Using Vim and VimOutliner as a Brainstorming and Outlining Tool</title><content type="html">&lt;p&gt;This post discuses using Vim as an outlining tool.
It focuses particularly on VimOutliner.
In particular the post
(a) discusses reasons why I like outlining tools, 
(b) presents some links for getting started and installing VimOutliner,
(c) presents my verdict on the personal utility of VimOutliner, and
(d) presents an assortment of little issues that I encountered and resolved while
learning to use VimOutliner.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview:&lt;/h3&gt;

&lt;p&gt;I've been a huge fan of outlining tools for more than ten years.
It all started when I stumbled on Outline View in MS Word.
I tweaked the settings a little bit, reducing the tab width to zero, and adding
a few additional shortcut keys and macros.&lt;/p&gt;

&lt;p&gt;I used Outline View to do much of my project-related brainstorming.
For example, if I had a yes/no decision to make, I'd type the name of the
problem with subheadings: description, yes, no, and decision.
The description would articulate the nature of the decision.
I'd then put reasons for yes, and reasons for no under their respective
headings.
This facilitated taking both perspectives.
Once I'd reached the decision, I could fold up the decision and move it from a
pending section to a resolved section.&lt;/p&gt;

&lt;p&gt;On a typical project there might 20, 30, or more decisions to be
made. &lt;br /&gt;
Using the hierarchical structure of Outline View allowed me to zoom in
and out of problems.
And this is but one example.
I used outlines for brainstorming, articulating problems, recording a log of
events, organising notes, and more.&lt;/p&gt;

&lt;p&gt;Of course, I'm not the first to discover the power of outlining.
Outlining is part of many people's brainstorming and thinking toolkit 
(see &lt;a href="
http://freemind.sourceforge.net/wiki/index.php/Main_Page"&gt;Free Mind for an open source mind mapping tool&lt;/a&gt;), 
&lt;a href="http://owl.english.purdue.edu/owl/resource/544/03/"&gt;this post on essay writing strategies&lt;/a&gt;,
etc.).&lt;/p&gt;

&lt;p&gt;The beauty of a tool like Outline View is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the ability to quickly manipulate the outline, promoting and demoting elements,
moving elements or whole trees up and down, and so on&lt;/li&gt;
&lt;li&gt;the ability to quickly navigate the outline&lt;/li&gt;
&lt;li&gt;the ability to selectively show elements of the outline&lt;/li&gt;
&lt;li&gt;Outline View also had benefits in that it had all the standard tools of MS
Word available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;However, Outline View also had problems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It was limited to 9 heading levels.&lt;/li&gt;
&lt;li&gt;Large files over about 200,000 words were often sluggish, and
sometimes crashed.&lt;/li&gt;
&lt;li&gt;It was difficult to convert the file into other formats.&lt;/li&gt;
&lt;li&gt;It lacked some fold navigation and viewing options, such as collapsing up a
fold or just showing the folds required to view the current line.&lt;/li&gt;
&lt;li&gt;Many of the keyboard shortcuts for Outline navigation and viewing required
movement of the hands from the home key position.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;VimOutliner&lt;/h3&gt;

&lt;p&gt;I previously posted about &lt;a href="
http://jeromyanglim.blogspot.com/2011/01/reasons-for-transitioning-to-vim.html
"&gt;my transition to using Vim&lt;/a&gt;.
As part of this transition, I was keen to bring as many tasks as possible into
Vim.
I saw the appeal of plain text.
I wanted to use cross-platform, open source tools.
I wanted to take advantage of the power of the text editing keys in Vim.
Thus, I wanted to switch from MS Word Outline View to an outliner in Vim.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.vim.org/scripts/script.php?script_id=2638"&gt;VimOutliner&lt;/a&gt; is a
major outlining tool for Vim. 
Raymon Li wrote &lt;a href="
  http://rayli.net/blog/2010/08/vimoutliner-windows-installation-howto/"&gt;instructions for installing VimOutliner on Windows&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here are some additional links relevant to Vim, VimOutliner, and outlining more
broadly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://video.google.com/videoplay?docid=8810772602188234059#"&gt;Steve Lit has a video on VimOutliner&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
https://github.com/vimoutliner/vimoutliner"&gt;The VimOutliner Plugin is also available on github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.troubleshooters.com/tpromag/199911/199911.htm"&gt;Discussion of Vim Outlines, Code, and Software by Steve Litt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Peter Stuifzand wrote about using &lt;a href="
http://peterstuifzand.nl/gtd-vimoutliner.html"&gt;VimOutliner and GTD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Org-mode&lt;/strong&gt;: I also hear great things about &lt;a href="
http://orgmode.org/"&gt;Emacs Org-Mode&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;There is also &lt;a href="https://github.com/hsitz/VimOrganizer"&gt;VimOrganiser&lt;/a&gt; which is
designed as a partial clone of Emacs org-mode. &lt;br /&gt;
But as of April 2011 it is at the relatively early stages of development. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Evaluation of VimOutliner after 3 months&lt;/h3&gt;

&lt;p&gt;At the time of posting I've been using Vim for around three months.
However, for the last month and half I have settled into a workflow that does
not involve VimOutliner.
Instead, I've switched to using &lt;a href="http://daringfireball.net/projects/markdown/"&gt;Markdown&lt;/a&gt;
in Vim with custom folding for my brainstorming.&lt;/p&gt;

&lt;p&gt;I'll talk more about my Markdown brainstorming setup at a later date
(for an overview of Markdown in Vim, see this &lt;a href="
http://net.tutsplus.com/tutorials/other/vim-essential-plugin-markdown-to-html/"&gt;video on Vim and Markdown&lt;/a&gt;
if you're curious).
However, in general my preference for using Markdown has largely flowed from the
benefits provided by Vim when working with text file formats.
Specifically in MS Word, Outline View relative to Normal View had the
advantage of being able to quickly hide and show the relevant text in a
hierarchical document.
However, Vim's folding tools can facilitate hiding and showing of text in a
variety of text formats.
Thus, with Markdown I can write text in a more structured format.
The content can more readily be used in other sources, such as blog posts.
Yet using Vim I can still hide and show relevant sections of text and move
sections around fluidly.                  &lt;/p&gt;

&lt;h3&gt;Assorted problems and solutions&lt;/h3&gt;

&lt;p&gt;The remainder of this post records a few challenges that I encountered when
getting oriented with VimOutliner. 
I've recorded them here in case they might be useful to others.
Bear in mind that they are effectively the working notes of someone new both to
Vim and VimOutliner.&lt;/p&gt;

&lt;h4&gt;1. Promote or demote multiple lines&lt;/h4&gt;

&lt;h5&gt;Question:&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;How can multiple lines be promoted or demoted?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion:&lt;/h5&gt;

&lt;p&gt;Visual line selection approach:
1. &lt;code&gt;V&lt;/code&gt; to enter visual line mode 
* select lines to be promoted or demoted 
* &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;&lt;/code&gt; to demote or promote
* &lt;code&gt;.&lt;/code&gt; to repeat, &lt;code&gt;u&lt;/code&gt; to undo&lt;/p&gt;

&lt;p&gt;Collapsed fold approach:
1. collapse a fold (e.g., &lt;code&gt;zc&lt;/code&gt;) 
2. &lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; to demote or promote&lt;/p&gt;

&lt;h4&gt;2. Tab width for outline files&lt;/h4&gt;

&lt;h5&gt;Question:&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What is the best tab width for outlines?&lt;/li&gt;
&lt;li&gt;If this is different to the default setting, how can such a change be limited
to Vim Outlines?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion:&lt;/h5&gt;

&lt;p&gt;Tab width of 2 might be better.&lt;/p&gt;

&lt;p&gt;I added the following commands to my Vimrc&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;au BufEnter *.otl setlocal tabstop = 2
au BufEnter *.otl setlocal shiftwidth=2
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;3. Using virtualedit&lt;/h4&gt;

&lt;h5&gt;Question:&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Should &lt;code&gt;virtualedit&lt;/code&gt; be turned off when working with outline mode?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Enter&lt;/code&gt; in insert mode at the end of a heading line starts a new line with
proper indentation&lt;/li&gt;
&lt;li&gt;&lt;code&gt;o&lt;/code&gt; and &lt;code&gt;O&lt;/code&gt; in normal mode add new lines below and above the current heading
at the same heading level&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thus, &lt;code&gt;vitualedit&lt;/code&gt; can be the source of formatting problems.
However, with care, this can be prevented, and I like virtualedit enough to not
turn it off for this file type.&lt;/p&gt;

&lt;h4&gt;4. Opening just subheadings&lt;/h4&gt;

&lt;h5&gt;Question:&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;How can a collapsed heading only be opened to show the first set of headings?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion:&lt;/h5&gt;

&lt;p&gt;The documentation for VimOutliner does not mention this.
General Vim help on folding (&lt;code&gt;h folding&lt;/code&gt;) is relevant.
&lt;code&gt;zx&lt;/code&gt; and &lt;code&gt;zv&lt;/code&gt; are the two relevant key combinations.&lt;/p&gt;

&lt;h4&gt;5. Add heading below fold at same level as fold&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;p&gt;I often edit a fold, fold it up and then want to add another level as a fold.
For example, take the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;text1
    text2.1
    text2.2
    text2.3
    text2.4
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I might want to fold up &lt;code&gt;text1&lt;/code&gt; to hide &lt;code&gt;text2.1&lt;/code&gt; to &lt;code&gt;text2.4&lt;/code&gt; and then want to
add a new heading at the same level as &lt;code&gt;text1&lt;/code&gt; below &lt;code&gt;test2.4&lt;/code&gt;.
Pressing &lt;code&gt;o&lt;/code&gt; adds a line below &lt;code&gt;text2.4&lt;/code&gt; at the same level as &lt;code&gt;text2.4&lt;/code&gt;.
How do I add a heading below &lt;code&gt;test2.4&lt;/code&gt;?&lt;/p&gt;

&lt;h5&gt;Discussion&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Assume in insert mode&lt;/li&gt;
&lt;li&gt;Ensure cursor is actually on fold: &lt;code&gt;kj&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;Move cursor to start of text &lt;code&gt;^&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Copy preceding tabs &lt;code&gt;y0&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Collapse headings again &lt;code&gt;zc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add line &lt;code&gt;o&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Exit mode &lt;code&gt;&amp;lt;ESC&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Paste tabs &lt;code&gt;P&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Enter insert mode at end of line &lt;code&gt;A&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And optionally&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Collapse unnecessary folds &lt;code&gt;&amp;lt;ESC&amp;gt;zx&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Return to insert mode &lt;code&gt;A&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Taken together and with some seemingly necessary tweaking, this makes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;au FileType vo_base  map &amp;lt;leader&amp;gt;o kjzO^y0zco&amp;lt;Esc&amp;gt;0DPA&amp;lt;Esc&amp;gt;zxA
&lt;/code&gt;&lt;/pre&gt;

&lt;h5&gt;Issues&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;It does not work when body text is at the bottom
&lt;ul&gt;
&lt;li&gt;it adds an extra body text line&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;It sometimes does not work when the outline is corrupted 
&lt;ul&gt;
&lt;li&gt;it displays various error messages&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;It does not work when the heading is not folded
&lt;ul&gt;
&lt;li&gt;it leaves a blank line&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;6. Preventing outline file format corruption&lt;/h4&gt;

&lt;h5&gt;Question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;What kinds of corruption of the outline file format can occur?&lt;/li&gt;
&lt;li&gt;How can this be prevented?&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Discussion:&lt;/h5&gt;

&lt;p&gt;Spaces where tabs should be is a major source of problems.&lt;/p&gt;

&lt;p&gt;Outline format uses tabs for indentation.
In general, if spaces precede the first printed character, the file format
becomes corrupted.&lt;/p&gt;

&lt;p&gt;The following are common causes of this&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spaces can be inserted by using space instead of tab&lt;/li&gt;
&lt;li&gt;spaces can be inserted when virtual edit is on&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Potential Resolutions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prevent 
&lt;ul&gt;
&lt;li&gt;Disable virtualedit (i.e., &lt;code&gt;set virtualedit=""&lt;/code&gt;).
However, I like virtualedit and disabling it for one file type makes my
editing experience less consistent. 
So I chose not to do this.&lt;/li&gt;
&lt;li&gt;Follow the rule of always starting a new heading using a limited set of keys:
&lt;code&gt;Enter&lt;/code&gt;, &lt;code&gt;o&lt;/code&gt;, &lt;code&gt;O&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Always change heading level using standard keys:
&lt;ul&gt;
&lt;li&gt;Tab, Ctrl+D, Ctrl+T (insert mode)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt; &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; (normal mode)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Avoid leaving blank lines
&lt;ul&gt;
&lt;li&gt;If a new heading is created, but no text is entered, delete it before
moving the cursor.&lt;/li&gt;
&lt;li&gt;The above behaviour could be automated with a substitution command.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Diagnose Problem
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;set list&lt;/code&gt; shows whether the characters preceding headings are all &lt;code&gt;^I&lt;/code&gt;
(&lt;code&gt;set nolist&lt;/code&gt;) turns this off.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Fix
&lt;ul&gt;
&lt;li&gt;Manually replace spaces with tabs with assistance from &lt;code&gt;set list&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Use substitution to replace all problematic lines.
This could also be linked to an autocommand that automatically checks and
fixes problems&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;General Advice
&lt;ul&gt;
&lt;li&gt;See &lt;a href="
http://vim.wikia.com/wiki/Highlight_unwanted_spaces"&gt;this vimtip on highlighting unwanted white space&lt;/a&gt;
In the case of VimOutliner, this would be any space before the first
printed character in a line.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-8200857994209942209?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=S0siwXe960Y:Q-wG0ozYrqc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=S0siwXe960Y:Q-wG0ozYrqc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=S0siwXe960Y:Q-wG0ozYrqc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=S0siwXe960Y:Q-wG0ozYrqc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=S0siwXe960Y:Q-wG0ozYrqc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=S0siwXe960Y:Q-wG0ozYrqc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=S0siwXe960Y:Q-wG0ozYrqc:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=S0siwXe960Y:Q-wG0ozYrqc:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=S0siwXe960Y:Q-wG0ozYrqc:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/S0siwXe960Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/8200857994209942209/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/04/using-vim-and-vimoutliner-as.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/8200857994209942209?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/8200857994209942209?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/S0siwXe960Y/using-vim-and-vimoutliner-as.html" title="Using Vim and VimOutliner as a Brainstorming and Outlining Tool" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/04/using-vim-and-vimoutliner-as.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck8NSX8zcSp7ImA9WhVQFk0.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-617591034496748746</id><published>2011-03-30T15:36:00.004+11:00</published><updated>2012-04-05T14:41:38.189+10:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-05T14:41:38.189+10:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="statistics" /><category scheme="http://www.blogger.com/atom/ns#" term="statistical consulting" /><category scheme="http://www.blogger.com/atom/ns#" term="teaching" /><title>How to Ask Me a Statistics Question</title><content type="html">&lt;p&gt;This post includes instructions on how to ask me a written statistics
question.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h5&gt;The old way&lt;/h5&gt;

&lt;p&gt;I receive a lot of statistics questions by email.
Answering such questions by email is inefficient.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A lot of questions re-occur.&lt;/li&gt;
&lt;li&gt;Answers only help a single person.&lt;/li&gt;
&lt;li&gt;Senders only get my suggestions, and not suggestions from other experts.&lt;/li&gt;
&lt;li&gt;Sender do not get much feedback on how to improve in the art of
writing effective questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;A better way&lt;/h5&gt;

&lt;p&gt;A better model involves using &lt;a href="http://stats.stackexchange.com"&gt;http://stats.stackexchange.com&lt;/a&gt; . 
It offers many benefits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Many experts have an opportunity to provide an answer.&lt;/li&gt;
&lt;li&gt;The questions can be improved and refined.&lt;/li&gt;
&lt;li&gt;Questions and answers are accessible from search engines.
Thus, the question and answers become an ongoing Internet resource that
are typically read by many hundreds of people.&lt;/li&gt;
&lt;li&gt;The answers are under a Creative Commons licence which means that they can
be reused in other forms.&lt;/li&gt;
&lt;li&gt;Learning to write effective questions on question and answer sites is an
important skill.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Procedure for asking a question&lt;/h5&gt;

&lt;ol&gt;
&lt;li&gt;Go to &lt;a href="http://stats.stackexchange.com/"&gt;http://stats.stackexchange.com/&lt;/a&gt; .&lt;/li&gt;
&lt;li&gt;Create an account 
&lt;ul&gt;
&lt;li&gt;You can create an account with a non-identifying user name if
you prefer.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Read the &lt;a href="http://stats.stackexchange.com/faq"&gt;FAQ&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click &lt;a href="http://stats.stackexchange.com/questions/ask"&gt;ASK QUESTION&lt;/a&gt;.
&lt;ul&gt;
&lt;li&gt;Enter your question title, description, and any relevant tags.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h5&gt;Important things to remember:&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Be prepared to edit your question to provide additional information in
response to comments; be prepared to respond to people who propose answers
and explain why the answer is helpful or not.
Asking a question is only the beginning of the process.
The people answering the question are volunteers who are often motivated
to create a question and answer combination that will be helpful for others
in the future. 
You should try to facilitate this process.&lt;/li&gt;
&lt;li&gt;When asking questions, show what initial research you have
done to answer the question (e.g., Google searches, reading a textbook).&lt;/li&gt;
&lt;li&gt;Try to extract the general question out of the specifics of your project,
so that answers will be of greater use for future readers.&lt;/li&gt;
&lt;li&gt;Include background information that might be needed in order to answer
your question effectively.&lt;/li&gt;
&lt;li&gt;If your question includes multiple parts, then you may need to ask
separate questions.&lt;/li&gt;
&lt;li&gt;If you are concerned about anonymity, create a user name that is
non-identifying, and, if necessary, tweak your question to make any
project-specific details a little more abstract.&lt;/li&gt;
&lt;li&gt;Your question may be clearer if you break up your question into (a) context;
(b) questions; and where appropriate (c) your initial answers.&lt;/li&gt;
&lt;li&gt;If your background is psychology, be aware that users on
stats.stackexchange have diverse backgrounds. Clearly explain any
psychological terms or concepts.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;Asking me a question&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;If you are a research student or academic where I work at the Melbourne Business School, then send me the URL to the question by email, and I will do my best to answer your question.&lt;/li&gt;
&lt;li&gt;For all others, if you don't get a good answer in a few days and you think that I'd be well suited
to answering the question, feel free to send me an email including the web
address for the question, or post it below.
Of course, I can't promise that I'll have time to answer the question.
&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-617591034496748746?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=2DRyc_Vkad4:GVPrv3_EuNM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=2DRyc_Vkad4:GVPrv3_EuNM:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=2DRyc_Vkad4:GVPrv3_EuNM:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=2DRyc_Vkad4:GVPrv3_EuNM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=2DRyc_Vkad4:GVPrv3_EuNM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=2DRyc_Vkad4:GVPrv3_EuNM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=2DRyc_Vkad4:GVPrv3_EuNM:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=2DRyc_Vkad4:GVPrv3_EuNM:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=2DRyc_Vkad4:GVPrv3_EuNM:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/2DRyc_Vkad4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/617591034496748746/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/03/how-to-ask-me-statistics-question.html#comment-form" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/617591034496748746?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/617591034496748746?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/2DRyc_Vkad4/how-to-ask-me-statistics-question.html" title="How to Ask Me a Statistics Question" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>7</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/03/how-to-ask-me-statistics-question.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEQHSHk8fSp7ImA9Wx9bEkg.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-1088538028809176212</id><published>2011-02-21T13:45:00.000+11:00</published><updated>2011-02-21T13:45:39.775+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-21T13:45:39.775+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="modelling" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>R Optimisation Tips using Optim and Maximum Likelihood</title><content type="html">&lt;p&gt;This post summarises some R modelling tips I picked up at
&lt;a href="http://www.psych.unimelb.edu.au/AMPC2011/index.htm"&gt;AMPC2011&lt;/a&gt;.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;p&gt;I got some tips from a tutorial on parameter estimation
put on by &lt;a href="http://www.newcl.org/?q=node/50"&gt;Scott Brown&lt;/a&gt;from the 
 &lt;a href="http://www.newcl.org/"&gt;Newcastle Cognition Lab&lt;/a&gt;.
The R code used in the tutorial is available &lt;a href="
http://www.psych.unimelb.edu.au/AMPC2011/rt.zip"&gt;directly here&lt;/a&gt;
or from the &lt;a href="
http://www.psych.unimelb.edu.au/AMPC2011/index.htm"&gt;conference website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The main tips I took from the tutorial were:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consider using &lt;a href="http://en.wikipedia.org/wiki/Bayesian_information_criterion"&gt;BIC&lt;/a&gt;
as a model comparison criterion.&lt;/li&gt;
&lt;li&gt;When modelling reaction times, consider modelling data as a mixture model of
two processes. One process is the main process of experimental interest and
another is a secondary process that otherwise contributes noise.
The secondary process is used to capture what would otherwise be outliers that
flow, particularly, from very slow reaction times observed when participants
get distracted.
Probability assigned to the two processes
can be specified a priori based on knowledge of the experimental phenomena.
In the specific example that Scott showed, the outlier process was given a
probability of 0.03 and this was treated as a uniform distribution between 0
and the trial time-out time.&lt;/li&gt;
&lt;li&gt;Consider transformations model parameters for the purpose of estimation and
then converting the transformed parameters back to their original scale.
This can facilitate estimation and also assist in enforcing psychologically
meaningful constraints on parameter values (e.g., ensuring that asymptotic
reaction time is greater than zero).&lt;/li&gt;
&lt;li&gt;The combination of the R function &lt;code&gt;optim&lt;/code&gt; and a custom created objective
function, such as a minus log-likelihood function provides a powerful tool for
parameter estimation of custom models. &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;a href="
http://www.psych.unimelb.edu.au/AMPC2011/rt.zip"&gt;Scott Brown's tutorial&lt;/a&gt; includes an example of
this.&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.mayin.org/ajayshah/KB/R/documents/mle/mle.html"&gt;Ajay Shah has an example&lt;/a&gt;
of writing a likelihood function and then getting a maximum likelihood
estimate using &lt;code&gt;optim&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Benjamin Bolker has great material available on the web from his book
&lt;a href="http://www.math.mcmaster.ca/~bolker/emdbook/index.html"&gt;Ecological Models and Data in R&lt;/a&gt;.
PDFs, Rnw, and R code for early versions of the chapters are provided on
the website.
Chapter 6 (&lt;a href="http://www.math.mcmaster.ca/~bolker/emdbook/chap6A.pdf"&gt;likelihood and all that&lt;/a&gt;)
, 7 (&lt;a href="http://www.math.mcmaster.ca/~bolker/emdbook/chap7A.pdf"&gt;the gory details of model fitting&lt;/a&gt;),
and 8 (&lt;a href="http://www.math.mcmaster.ca/~bolker/emdbook/chap8A.pdf"&gt;worked likelihood estimation examples&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Brian Ripley has a &lt;a href="
http://www.stats.ox.ac.uk/~ruth/RCourse/Rcourse54up.pdf"&gt;set of slides on simulation and optimisation in R&lt;/a&gt;. 
In particular it provides a useful discussion of the various optimisation
algorithms available using &lt;code&gt;optim&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;I also got the impression that it will soon be time to dive into &lt;a href="
http://www.mrc-bsu.cam.ac.uk/bugs/"&gt;WinBUGS&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-1088538028809176212?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=f3G7kN5iCT8:H6rhH6BN9AQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=f3G7kN5iCT8:H6rhH6BN9AQ:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=f3G7kN5iCT8:H6rhH6BN9AQ:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=f3G7kN5iCT8:H6rhH6BN9AQ:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=f3G7kN5iCT8:H6rhH6BN9AQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=f3G7kN5iCT8:H6rhH6BN9AQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=f3G7kN5iCT8:H6rhH6BN9AQ:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=f3G7kN5iCT8:H6rhH6BN9AQ:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=f3G7kN5iCT8:H6rhH6BN9AQ:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/f3G7kN5iCT8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/1088538028809176212/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/02/r-optimisation-tips-using-optim-and.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/1088538028809176212?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/1088538028809176212?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/f3G7kN5iCT8/r-optimisation-tips-using-optim-and.html" title="R Optimisation Tips using Optim and Maximum Likelihood" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>6</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/02/r-optimisation-tips-using-optim-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0AGSXkyfCp7ImA9Wx9bEkg.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-4183686649943021469</id><published>2011-02-21T13:33:00.001+11:00</published><updated>2011-02-21T13:35:28.794+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-21T13:35:28.794+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="psychology" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>R versus Matlab in Mathematical Psychology</title><content type="html">&lt;p&gt;I recently attended the 2011 Australasian Mathematical Psychology Conference.
This post summarises a few thoughts I had on the use of R, Matlab and other
tools in mathematical psychology flowing from discussions with researchers at
the conference.
&lt;a name='more'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wanted to get a sense of the software used by researchers in mathematical
psychology.
What was popular?
Why was it popular?
From the small-n, non-random sample of conference attendees that I spoke to over
coffee and cake, I concluded:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Many experienced math psych researchers know a bit of both R and Matlab, but
most specialised in one. &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;Matlab seemed to be substantially more popular than R in math psych.&lt;/li&gt;
&lt;li&gt;The general attitude seemed to be that both tools offered similar
functionality.&lt;/li&gt;
&lt;li&gt;Reasons given for using Matlab:
&lt;ul&gt;&lt;li&gt;Consistency: several researchers commented that functions are highly
consistent in Matlab, making it easier to return to coding in Matlab after
a break.&lt;/li&gt;
&lt;li&gt;Superior built-in documentation: 
There was a sense that Matlab documentation was more user-friendly.&lt;/li&gt;
&lt;li&gt;Historical precedent: researchers grew up on Matlab and then taught it to
their graduate students.&lt;/li&gt;
&lt;li&gt;Existing packages and models: it seems like Matlab is well established in
cognitive psychology where substantial existing code to guide subsequent
researchers.&lt;/li&gt;
&lt;li&gt;University pays: Thus, while R is free, Matlab is effectively free to the
academic if the academic's university has a site licence.&lt;/li&gt;
&lt;li&gt;User friendly IDE: 
In R it seems that most users pretty quickly start playing around with
alternative editors, whether it be ESS, Vim and R, Eclipse, Tinn-R or
something else. In Matlab, the built-in IDE seemed popular.
While these external editors can be configured to create a really powerful
data analytic environment, Matlab users appreciated having something that
was productive out-of-the-box.&lt;/li&gt;
&lt;li&gt;Matlab is user friendly for implementing matrix algebra based
calculations.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Reasons given for using R:
&lt;ul&gt;&lt;li&gt;Free (as in beer)&lt;/li&gt;
&lt;li&gt;Open source: A few people talked about this. However, I got the sense
that the ideology of open source technology could be encouraged further.&lt;/li&gt;
&lt;li&gt;Sweave: Even amongst Matlab users, there was a respect and interest in the
idea of &lt;a href="http://www.stat.uni-muenchen.de/~leisch/Sweave/"&gt;Sweave in R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;R's packages: The sheer number of packages particularly for statistics is
one of R's great strengths.&lt;/li&gt;
&lt;li&gt;Superior graphics&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;A few people also spoke positively of Python (see this summary of 
&lt;a href="
http://aliquote.org/memos/2011/02/07/python-for-statistical-computing"&gt;useful Python packages for statistics&lt;/a&gt;
by Christophe Lalanne.&lt;/li&gt;
&lt;li&gt;All the above links into general discussion of the relative merits of 
&lt;a href="
http://stackoverflow.com/questions/2264974/psychology-researcher-wants-to-learn-new-language"&gt;R, Matlab, and Python on SO&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From my discussions, I saw no need for me to personally switch from R to Matlab.
Sweave, graphics, and all the R packages are fantastic.
The community around R is also one of its great strengths.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/tagged/r"&gt;R StackOverflow&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://twitter.com/#!/search/%23rstats"&gt;Rstats on Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tolstoy.newcastle.edu.au/R/"&gt;R Help&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stats.stackexchange.com/questions/tagged/r"&gt;R on Cross Validated&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.revolutionanalytics.com/local-r-groups.html
"&gt;Local R User Groups&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.r-bloggers.com/"&gt;R Bloggers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, open source just aligns better with science.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open and freely modifiable source code&lt;/li&gt;
&lt;li&gt;Freely available psychological measurement tools&lt;/li&gt;
&lt;li&gt;Freely available data&lt;/li&gt;
&lt;li&gt;Reproducible research documents using technologies such as Sweave&lt;/li&gt;
&lt;li&gt;Open-access journals&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It all combines to support scientific disciplines in 
sharing and building knowledge through accountability and trust.
This applies both to sharing between researchers as well as communicating with
the broader community.&lt;/p&gt;

&lt;p&gt;I get a bad feeling when I think of researchers and interested community members
who can't afford Matlab being excluded from research.&lt;/p&gt;

&lt;p&gt;However, it was interesting to consider how issues like user-friendly
documentation, development environments, and consistency could be facilitated in
a massive and distributed open source project such as R.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;...END RANT...&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;Related Posts&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;Getting Started with Sweave&lt;/a&gt; &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2009/06/learning-r-for-researchers-in.html"&gt;Learning R in Psychology&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/12/r-workflow-slides-from-talk-at.html"&gt;Links to Example Sweave Documents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;David Hiebeler's &lt;a href="
http://cran.r-project.org/doc/contrib/Hiebeler-MatlabR.pdf"&gt;Matlab to R translation document&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-4183686649943021469?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OhOxr-zhJLw:LJCG2YToYxA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OhOxr-zhJLw:LJCG2YToYxA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OhOxr-zhJLw:LJCG2YToYxA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OhOxr-zhJLw:LJCG2YToYxA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OhOxr-zhJLw:LJCG2YToYxA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OhOxr-zhJLw:LJCG2YToYxA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OhOxr-zhJLw:LJCG2YToYxA:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=OhOxr-zhJLw:LJCG2YToYxA:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=OhOxr-zhJLw:LJCG2YToYxA:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/OhOxr-zhJLw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/4183686649943021469/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/02/r-versus-matlab-in-mathematical.html#comment-form" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/4183686649943021469?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/4183686649943021469?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/OhOxr-zhJLw/r-versus-matlab-in-mathematical.html" title="R versus Matlab in Mathematical Psychology" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>6</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/02/r-versus-matlab-in-mathematical.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8MRX4yeSp7ImA9Wx9XF08.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-6913591354801474312</id><published>2011-01-11T15:30:00.002+11:00</published><updated>2011-01-11T16:14:44.091+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-11T16:14:44.091+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="vim" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Reasons for Transitioning to Vim: Bringing LaTeX, R, Sweave and More under One Roof</title><content type="html">&lt;p&gt;This post describes the reasons for my transition to Vim.&lt;/p&gt;

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Brief Background&lt;/h3&gt;

&lt;p&gt;Over the years I've used a lot of different text editors on Windows.
In general, I've used whatever text editor came with a program.
When I started using R, I moved from Rgui through Tinn-R, JGR, and others,
finally settling in to really enjoy the StatET plugin in Eclipse.
When I started using LaTeX, I tried TexnicCenter, WinEdt, and Texlipse.
Each program had the standard Windows shortcut keys and often a few extra ones
for tasks such as deleting lines and toggling comments.
However, these novel shortcut keys varied between programs.&lt;/p&gt;

&lt;p&gt;I've acquired some fairly good skills in using Windows' admittedly limited set of
standard text editing features.
For example, I was comfortable pressing &lt;code&gt;Ctrl+Shift+Right&lt;/code&gt; to select a word.
I even developed and learnt a custom set of key bindings that allowed me to use
the navigation and cursor keys from the home key position
(&lt;a href="
http://jeromyanglim.blogspot.com/2010/07/how-to-edit-text-faster-on-windows-by.html"&gt;see my earlier post&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Nonetheless, this wasn't enough.
I wanted something more powerful, more consistent, more "awesome".&lt;/p&gt;

&lt;h3&gt;Reasons for Adopting Vim&lt;/h3&gt;

&lt;h4&gt;Frustration with Previous Tools&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;I was &lt;strong&gt;hitting a wall in Eclipse&lt;/strong&gt;.
The StatET plugin for Eclipse has some excellent features which make working
with R really nice 
(&lt;a href="
http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;see my earlier blog post&lt;/a&gt; 
However, there were a few tasks that I could not easily automate.
For example, I couldn't get decent code folding or an outline view for Sweave
files.
I couldn't develop a quick keyboard shortcut to send the R code in &lt;code&gt;\Sexpr{}&lt;/code&gt; to
the R console.
There was no key to switch consoles.
I could go on.
I could see no easy way to introduce the desired customisation.
No doubt the customisations were possible, but it meant diving into a whole world
of complexity or hoping that one day someone else would write a plugin to meet
my particular needs.
I could describe a similar experience with WinEdt.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Readiness for Vim&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I'd already adopted a &lt;strong&gt;plain-text--command-line workflow&lt;/strong&gt;.
LaTeX for documents; 
R for data analysis; 
Beamer for presentations;
Make for building programs;
Markdown for writing blog posts.
This meant that I could do most of my daily tasks in a text editor. 
There was also the possibility that with Vim I could bring in other tasks into a
more integrated environment (e.g., outlining, task lists, etc.).
When I was first learning LaTeX, R, the command-line, and so on, it was useful
to have software that held my hand a little bit.
After getting comfortable with such things, Vim is just one additional step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The main markup and programming languages that I use already had decent
support in Vim (e.g., R, LaTeX, etc.).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Vim Matched My Orientation&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I like the &lt;strong&gt;philosophy of Vim&lt;/strong&gt;.
I touch type. 
I learn shortcut keys.
I use AutoHotKey.
I despise unnecessary movement of the hands to the cursor keys or the mouse.
Vim is built for efficiency.
Vim is built for using the keyboard.
I'm happy to invest a little effort to get this efficiency.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I watched &lt;strong&gt;Derek Wyatt&lt;/strong&gt;'s awesome, funny, and informative videos on Vim. 
&lt;a href="http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-novice-tutorial-videos/"&gt;http://www.derekwyatt.org/vim/vim-tutorial-videos/vim-novice-tutorial-videos/&lt;/a&gt;
I related to what Derek was saying. 
I related to the "Notepad-wall". 
I liked an editor that saw the mouse as an "evil" "rat-tailed beast".
I liked an editor that saw moving the hands from the home key position as a health
hazard.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Great Features of Vim&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Vim was invented in 1991 and Vi goes back much further
(&lt;a href="http://en.wikipedia.org/wiki/Vim_(text_editor"&gt;see Wikipedia&lt;/a&gt;)).
It's still very popular.
Whenever I learn shortcut keys and introduce software customisations, I am
paying a present cost for future time savings.
Future time savings come both from the fact that the software is still supported
and that I don't drop the software because I find something better.
Vim has been around for a long time, is open source, and has an active developer
community. 
Thus, it feels like it will be around for a long time to come.
Also, given that many coding gurus use Vim, I'm hoping I wont be switching to
another tool any time soon (but I guess we'll have to see).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;a href="
http://stackoverflow.com/questions/1711/what-is-the-single-most-influential-book-every-programmer-should-read/1735#1735"&gt;Pragmatic Programmer&lt;/a&gt;
says that you should learn at least &lt;strong&gt;one powerful text editor&lt;/strong&gt; really well.
The main two options seem to be Vim and Emacs.
At this point I've been lured by the elegance of the mode-based approach to text
editing in Vim.
However, as with a lot of things, I feel the more important point is that I move
my workflow to either Emacs or Vim.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The system for saving settings in Vim gives me more confidence that I can roll
over my &lt;strong&gt;customisations&lt;/strong&gt; easily to other machines.
Eclipse always felt a bit mysterious regarding how and where customisations
would be stored.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Vim appears to &lt;strong&gt;lack "deal-breakers"&lt;/strong&gt;. 
By deal-breakers I refer to something about a piece of software that is so
frustrating that you just can't use it.
While most software can be frustrating at times, it should be simple enough to
customise the software to overcome the problem.
With Vim customisation is a natural extension of the editor.
With Eclipse, some useful customisation is possible, but there also feels like
there is a wall.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Building on the previous point &lt;strong&gt;customisation is a natural extension&lt;/strong&gt; of the
software. 
Vim is similar to R in this respect.
While a lot of programs have a more advanced scripting language to add
customisations, they don't all facilitate the gradual transition towards greater
use of this scripting language.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;Expect to see several upcoming posts on Vim as I begin to incorporate Vim into my
workflow using R, LaTeX, and other tools.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/search/label/"&gt;Other Posts on Vim&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-6913591354801474312?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=kEJW2tsdzsk:aZjd4N3pHuo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=kEJW2tsdzsk:aZjd4N3pHuo:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=kEJW2tsdzsk:aZjd4N3pHuo:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=kEJW2tsdzsk:aZjd4N3pHuo:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=kEJW2tsdzsk:aZjd4N3pHuo:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=kEJW2tsdzsk:aZjd4N3pHuo:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=kEJW2tsdzsk:aZjd4N3pHuo:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=kEJW2tsdzsk:aZjd4N3pHuo:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=kEJW2tsdzsk:aZjd4N3pHuo:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/kEJW2tsdzsk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/6913591354801474312/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2011/01/reasons-for-transitioning-to-vim.html#comment-form" title="23 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/6913591354801474312?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/6913591354801474312?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/kEJW2tsdzsk/reasons-for-transitioning-to-vim.html" title="Reasons for Transitioning to Vim: Bringing LaTeX, R, Sweave and More under One Roof" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>23</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2011/01/reasons-for-transitioning-to-vim.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4ARXc-eip7ImA9Wx9QFU8.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-509755131525445939</id><published>2010-12-28T18:55:00.000+11:00</published><updated>2010-12-28T18:55:44.952+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-28T18:55:44.952+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="summary post" /><title>2010 in Review: 99 Most Popular Pages on Jeromy Anglim's Blog</title><content type="html">In the spirit of taking stock of the year that's been,
 and in the spirit of festive television repeats, 
 this post reviews 2010 for this blog.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;2010 in Review&lt;/h3&gt;

&lt;p&gt;It has been a satisfying year of blogging.
Subscribers have grown from 70 to around 390.
Annual site visits have grown from 10,000 in 2009 to around 94,000
in 2010.&lt;/p&gt;

&lt;p&gt;I've also enjoyed getting involved with
 &lt;a href="http://www.crossvalidated.com/"&gt;CrossValidated&lt;/a&gt;,
 &lt;a href="
 http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/"&gt;Melbourne R Users&lt;/a&gt;,
 &lt;a href="
 http://www.r-bloggers.com/"&gt;R-Bloggers&lt;/a&gt;,
 &lt;a href="
 https://github.com/jeromyanglim"&gt;github&lt;/a&gt;,
 and &lt;a href="
 http://twitter.com/#!/jeromyanglim"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm looking forward to posting more in 2011 on
 Sweave, reproducible research, R packages, unit testing,
 and more.&lt;/p&gt;

&lt;p&gt;To all the readers of this blog, all the best for New Years
and the year ahead.&lt;/p&gt;

&lt;h3&gt;Most Popular Pages for 2010&lt;/h3&gt;

&lt;p&gt;The following were the 99 most popular blog pages 
for 2010 (with 2010 page views in brackets)
courtesy of &lt;a href="http://www.google.com/analytics/"&gt;Google Analytics&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/videos-on-data-analysis-with-r.html"&gt;videos-on-data-analysis-with-r&lt;/a&gt; (6353)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/recovering-corrupted-excel-2007-file.html"&gt;recovering-corrupted-excel-2007-file&lt;/a&gt; (5358)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/how-to-write-literature-review-in.html"&gt;how-to-write-literature-review-in&lt;/a&gt; (4180)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/apa-style-references-in-latex.html"&gt;apa-style-references-in-latex&lt;/a&gt; (3348)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;getting-started-with-sweave-r-latex&lt;/a&gt; (3241)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/abbreviations-of-r-commands-explained.html"&gt;abbreviations-of-r-commands-explained&lt;/a&gt; (2772)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/03/calculating-composite-scores-of-ability.html"&gt;calculating-composite-scores-of-ability&lt;/a&gt; (2605)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/06/learning-r-for-researchers-in.html"&gt;learning-r-for-researchers-in&lt;/a&gt; (2487)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/05/pronunciation-guides-for-mathematical.html"&gt;pronunciation-guides-for-mathematical&lt;/a&gt; (2216)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/export-from-endnote-to-bibtex-jabref.html"&gt;export-from-endnote-to-bibtex-jabref&lt;/a&gt; (1984)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/search/label/R"&gt;/search/label/R&lt;/a&gt; (1896)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/04/winedt-60-for-latex-features.html"&gt;winedt-60-for-latex-features&lt;/a&gt; (1891)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/08/getting-started-with-beamer-tips-and.html"&gt;getting-started-with-beamer-tips-and&lt;/a&gt; (1875)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/multinomial-logistic-regression-spss.html"&gt;multinomial-logistic-regression-spss&lt;/a&gt; (1673)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/02/formatting-correlation-matrices-in.html"&gt;formatting-correlation-matrices-in&lt;/a&gt; (1654)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/texniccenter-customisations.html"&gt;texniccenter-customisations&lt;/a&gt; (1594)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/11/generalized-estimating-equations.html"&gt;generalized-estimating-equations&lt;/a&gt; (1537)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/data-mining-and-r.html"&gt;data-mining-and-r&lt;/a&gt; (1508)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/structural-equation-modelling-in-r.html"&gt;structural-equation-modelling-in-r&lt;/a&gt; (1456)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/03/user-interface-for-r-statet-and-eclipse.html"&gt;user-interface-for-r-statet-and-eclipse&lt;/a&gt; (1445)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/05/online-mathematics-video-courses-for.html"&gt;online-mathematics-video-courses-for&lt;/a&gt; (1445)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/repeated-measures-experiments-with-many.html"&gt;repeated-measures-experiments-with-many&lt;/a&gt; (1385)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/factor-analysis-in-r.html"&gt;factor-analysis-in-r&lt;/a&gt; (1332)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/difference-scores-are-they-okay-to-use.html"&gt;difference-scores-are-they-okay-to-use&lt;/a&gt; (1237)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/05/statistics-for-psychology-thesis.html"&gt;statistics-for-psychology-thesis&lt;/a&gt; (1156)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/case-study-in-optimising-code-in-r.html"&gt;case-study-in-optimising-code-in-r&lt;/a&gt; (1127)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/writing-method-section-in-psychology.html"&gt;writing-method-section-in-psychology&lt;/a&gt; (1115)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/how-to-write-predictions-and-hypotheses.html"&gt;how-to-write-predictions-and-hypotheses&lt;/a&gt; (1087)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;sweave-tutorial-using-sweave-r-and-make&lt;/a&gt; (1064)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/variable-importance-and-multiple.html"&gt;variable-importance-and-multiple&lt;/a&gt; (1063)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/data-mining-and-statistics-video-course.html"&gt;data-mining-and-statistics-video-course&lt;/a&gt; (1048)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/running-command-line-programs-in.html"&gt;running-command-line-programs-in&lt;/a&gt; (1010)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/06/canonical-correlation-getting-started.html"&gt;canonical-correlation-getting-started&lt;/a&gt; (1006)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/fitting-nonlinear-regression-models-to.html"&gt;fitting-nonlinear-regression-models-to&lt;/a&gt; (948)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/analysing-ordinal-variables.html"&gt;analysing-ordinal-variables&lt;/a&gt; (933)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/practice-questions-for-statistics-in.html"&gt;practice-questions-for-statistics-in&lt;/a&gt; (930)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/converting-microsoft-word-document-into.html"&gt;converting-microsoft-word-document-into&lt;/a&gt; (922)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/scoring-multiple-choice-test-in-spss.html"&gt;scoring-multiple-choice-test-in-spss&lt;/a&gt; (901)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/job-satisfaction-measurement-scales.html"&gt;job-satisfaction-measurement-scales&lt;/a&gt; (864)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/logistic-regression-resources-in-spss.html"&gt;logistic-regression-resources-in-spss&lt;/a&gt; (859)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/teaching-resources.html"&gt;teaching-resources&lt;/a&gt; (855)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/tetrachoric-correlations-overview-and.html"&gt;tetrachoric-correlations-overview-and&lt;/a&gt; (806)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/analysis-of-winter-olympic-medal-data.html"&gt;analysis-of-winter-olympic-medal-data&lt;/a&gt; (801)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/structural-equation-modelling-and-path.html"&gt;structural-equation-modelling-and-path&lt;/a&gt; (800)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/how-to-write-introduction-section-in.html"&gt;how-to-write-introduction-section-in&lt;/a&gt; (789)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/04/implications-of-office-layout-and.html"&gt;implications-of-office-layout-and&lt;/a&gt; (788)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/formatting-table-in-word-r-to-tab.html"&gt;formatting-table-in-word-r-to-tab&lt;/a&gt; (719)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/calculating-scale-scores-for.html"&gt;calculating-scale-scores-for&lt;/a&gt; (675)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/p/jeromy-anglims-academic-publications.html"&gt;/p/jeromy-anglims-academic-publications&lt;/a&gt; (673)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/p/site-map-jeromy-anglims-blog-psychology.html"&gt;/p/site-map-jeromy-anglims-blog-psychology&lt;/a&gt; (667)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/exploratory-factor-analysis-and-scale.html"&gt;exploratory-factor-analysis-and-scale&lt;/a&gt; (646)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/statistical-power-analysis-in-gpower-3.html"&gt;statistical-power-analysis-in-gpower-3&lt;/a&gt; (645)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/08/simple-beamer-template-for-getting.html"&gt;simple-beamer-template-for-getting&lt;/a&gt; (645)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/introduction-to-journal-article.html"&gt;introduction-to-journal-article&lt;/a&gt; (614)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/introduction-to-spss-syntax-advice-for.html"&gt;introduction-to-spss-syntax-advice-for&lt;/a&gt; (609)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/04/how-to-get-quick-access-to-full-text.html"&gt;how-to-get-quick-access-to-full-text&lt;/a&gt; (563)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/07/how-to-process-inquisit-raw-data-in.html"&gt;how-to-process-inquisit-raw-data-in&lt;/a&gt; (558)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/item-parcelling-in-confirmatory-factor.html"&gt;item-parcelling-in-confirmatory-factor&lt;/a&gt; (524)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/05/bootstrapping.html"&gt;bootstrapping&lt;/a&gt; (522)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2008/11/carryover-effects-in-repeated-measures.html"&gt;carryover-effects-in-repeated-measures&lt;/a&gt; (513)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/12/r-workflow-slides-from-talk-at.html"&gt;r-workflow-slides-from-talk-at&lt;/a&gt; (508)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/04/exporting-pdfs-from-jabref-using-batch.html"&gt;exporting-pdfs-from-jabref-using-batch&lt;/a&gt; (494)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-3-console-input-and.html"&gt;sweave-tutorial-3-console-input-and&lt;/a&gt; (486)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-2-individual.html"&gt;sweave-tutorial-2-individual&lt;/a&gt; (484)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/01/tips-on-reading-mathematics-for-non.html"&gt;tips-on-reading-mathematics-for-non&lt;/a&gt; (476)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/syntax-tips-for-efficient-variable.html"&gt;syntax-tips-for-efficient-variable&lt;/a&gt; (472)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/08/social-network-analysis-resources-for-r.html"&gt;social-network-analysis-resources-for-r&lt;/a&gt; (471)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/inverting-logistic-function.html"&gt;inverting-logistic-function&lt;/a&gt; (455)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/scale-construction-item-reversal-scale.html"&gt;scale-construction-item-reversal-scale&lt;/a&gt; (452)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/significance-tests-on-correlations.html"&gt;significance-tests-on-correlations&lt;/a&gt; (441)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/discriminant-function-analysis.html"&gt;discriminant-function-analysis&lt;/a&gt; (439)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/analysis-of-multiple-choice-test.html"&gt;analysis-of-multiple-choice-test&lt;/a&gt; (418)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/efficient-variable-selection-in-r.html"&gt;efficient-variable-selection-in-r&lt;/a&gt; (414)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/04/free-video-courses-on-r-structural.html"&gt;free-video-courses-on-r-structural&lt;/a&gt; (410)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/meta-analysis-tips-resources-and.html"&gt;meta-analysis-tips-resources-and&lt;/a&gt; (399)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/practical-tips-on-how-to-conduct_05.html"&gt;practical-tips-on-how-to-conduct_05&lt;/a&gt; (397)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/choosing-auto-generation-pattern-for.html"&gt;choosing-auto-generation-pattern-for&lt;/a&gt; (389)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html"&gt;makefiles-for-sweave-r-and-latex-using&lt;/a&gt; (382)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/tips-for-using-statet-and-eclipse-for.html"&gt;tips-for-using-statet-and-eclipse-for&lt;/a&gt; (372)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/01/free-online-mathematics-books.html"&gt;free-online-mathematics-books&lt;/a&gt; (369)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/follow-up-tests-in-anova-in-spss.html"&gt;follow-up-tests-in-anova-in-spss&lt;/a&gt; (367)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2008/11/causality-and-mediation-analysis.html"&gt;causality-and-mediation-analysis&lt;/a&gt; (357)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/02/single-group-correlational-study-basic.html"&gt;single-group-correlational-study-basic&lt;/a&gt; (355)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/using-regular-expressions-in-r-case.html"&gt;using-regular-expressions-in-r-case&lt;/a&gt; (350)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/10/getting-started-with-writing.html"&gt;getting-started-with-writing&lt;/a&gt; (347)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/clustered-samples-and-assuming.html"&gt;clustered-samples-and-assuming&lt;/a&gt; (339)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/jeromy-anglims-academic-publications.html"&gt;jeromy-anglims-academic-publications&lt;/a&gt; (338)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/blogs-on-r-statistics.html"&gt;blogs-on-r-statistics&lt;/a&gt; (334)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/11/getting-started-with-git-egit-eclipse.html"&gt;getting-started-with-git-egit-eclipse&lt;/a&gt; (331)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/34-minute-video-on-using-r-to-analyse.html"&gt;34-minute-video-on-using-r-to-analyse&lt;/a&gt; (328)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2008/11/mediation-and-moderation-reference.html"&gt;mediation-and-moderation-reference&lt;/a&gt; (315)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/article-deconstruction-how-to-writing.html"&gt;article-deconstruction-how-to-writing&lt;/a&gt; (311)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/introduction-to-social-network-analysis.html"&gt;introduction-to-social-network-analysis&lt;/a&gt; (304)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/problems-with-high-resolution-laptops.html"&gt;problems-with-high-resolution-laptops&lt;/a&gt; (280)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/03/inquisit-simple-reaction-time-four.html"&gt;inquisit-simple-reaction-time-four&lt;/a&gt; (269)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/12/matrix-algebra-in-r-resources-videos.html"&gt;matrix-algebra-in-r-resources-videos&lt;/a&gt; (268)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/05/great-measurement-but-small-sample-size.html"&gt;great-measurement-but-small-sample-size&lt;/a&gt; (256)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/09/adjusting-correlations-for-reliability.html"&gt;adjusting-correlations-for-reliability&lt;/a&gt; (239)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2009/10/producing-table-of-item-descriptive.html"&gt;producing-table-of-item-descriptive&lt;/a&gt; (236)&lt;/li&gt;
&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-509755131525445939?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=WIFDu94Km3E:8vi-G4NgyDI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=WIFDu94Km3E:8vi-G4NgyDI:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=WIFDu94Km3E:8vi-G4NgyDI:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=WIFDu94Km3E:8vi-G4NgyDI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=WIFDu94Km3E:8vi-G4NgyDI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=WIFDu94Km3E:8vi-G4NgyDI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=WIFDu94Km3E:8vi-G4NgyDI:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=WIFDu94Km3E:8vi-G4NgyDI:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=WIFDu94Km3E:8vi-G4NgyDI:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/WIFDu94Km3E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/509755131525445939/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/12/2010-in-review-99-most-popular-pages-on.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/509755131525445939?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/509755131525445939?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/WIFDu94Km3E/2010-in-review-99-most-popular-pages-on.html" title="2010 in Review: 99 Most Popular Pages on Jeromy Anglim's Blog" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/12/2010-in-review-99-most-popular-pages-on.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYDQHk9cSp7ImA9Wx9QFUw.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-2319092387814324278</id><published>2010-12-28T17:02:00.000+11:00</published><updated>2010-12-28T17:02:51.769+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-28T17:02:51.769+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="statistics" /><category scheme="http://www.blogger.com/atom/ns#" term="SPSS" /><category scheme="http://www.blogger.com/atom/ns#" term="internet" /><title>Question and Answer Sites on Statistics, Computing, Research, and Psychology</title><content type="html">This post sets out some of my favourite question
 and answer sites on topics related to statistics,
 computing, research, and psychology.  

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;Question and answer sites have been a part of the internet
 for a long time.
However, more recent sites such as typified
 by the &lt;a href="http://stackexchange.com/"&gt;StackExchange Model&lt;/a&gt; are 
 improving the situation substantially.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Results are readily searchable on Google.&lt;/li&gt;
&lt;li&gt;Good answers get voted to the top&lt;/li&gt;
&lt;li&gt;Subscriptions are not required&lt;/li&gt;
&lt;li&gt;Incentives are given to posters to provide good answers&lt;/li&gt;
&lt;li&gt;Questions and answers can be edited and improved&lt;/li&gt;
&lt;li&gt;Community and social networks are facilitated&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Forums by Topic&lt;/h3&gt;

&lt;p&gt;The following are some of my current 
favourite question and answer sites for various types of questions.&lt;/p&gt;

&lt;h4&gt;Statistics&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stats.stackexchange.com/"&gt;Cross Validated&lt;/a&gt;: 
A StackExchange site for questions related to statistics and data analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;R&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/tagged/r"&gt;R Tag on StackOverflow&lt;/a&gt;:
A good option for anything related to programming in R&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stats.stackexchange.com/"&gt;Cross Validated&lt;/a&gt;:
This is a good option if the question concerns statistical elements of R.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stat.ethz.ch/mailman/listinfo/r-help"&gt;R Help Mailing List&lt;/a&gt;:
Another option for asking R related questions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;SPSS&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.listserv.uga.edu/archives/spssx-l.html"&gt;SPSSX-L Listserv&lt;/a&gt;:
An SPSS Mailing list&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stats.stackexchange.com/"&gt;Cross Validated&lt;/a&gt;:
Add the SPSS tag to the question.
The question is likely to be better received if it concerns statistics 
more than it concerns SPSS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;LaTeX&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://tex.stackexchange.com/"&gt;TeX.StackExchange&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Programming&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/"&gt;Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Inquisit&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.millisecond.com/community/forums/"&gt;Millisecond Forums&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Maths&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://math.stackexchange.com/"&gt;Math Stackexchange&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Computers, Non-programming&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://superuser.com/"&gt;SuperUser&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;General Question and Answer Sites&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.quora.com"&gt;Quora&lt;/a&gt;:
Quora is relatively new and is designed to cover any
question imaginable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Psychological Research&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://area51.stackexchange.com/proposals/2149/cognitive-science?referrer=-MJssSabI9MN5QfMOt5KEg2"&gt;A Cognitive Science StackExchange&lt;/a&gt;
has been proposed.
If this interests you, commit to the proposal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Additional Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://www.catb.org/~esr/faqs/smart-questions.html"&gt;How to ask questions the smart way&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-2319092387814324278?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=HOkSyESN5xU:3YBh3ajblU0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=HOkSyESN5xU:3YBh3ajblU0:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=HOkSyESN5xU:3YBh3ajblU0:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=HOkSyESN5xU:3YBh3ajblU0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=HOkSyESN5xU:3YBh3ajblU0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=HOkSyESN5xU:3YBh3ajblU0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=HOkSyESN5xU:3YBh3ajblU0:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=HOkSyESN5xU:3YBh3ajblU0:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=HOkSyESN5xU:3YBh3ajblU0:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/HOkSyESN5xU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/2319092387814324278/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/12/question-and-answer-sites-on-statistics.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2319092387814324278?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2319092387814324278?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/HOkSyESN5xU/question-and-answer-sites-on-statistics.html" title="Question and Answer Sites on Statistics, Computing, Research, and Psychology" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/12/question-and-answer-sites-on-statistics.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UESX4-eCp7ImA9Wx9REkU.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-3721897032784687047</id><published>2010-12-13T23:40:00.002+11:00</published><updated>2010-12-14T11:06:48.050+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-14T11:06:48.050+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="version_control" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><category scheme="http://www.blogger.com/atom/ns#" term="Australia" /><title>Video of Reproducible Research with R: Melbourne R Users 1st Dec 2010</title><content type="html">As &lt;a href="
http://jeromyanglim.blogspot.com/2010/12/r-workflow-slides-from-talk-at.html"&gt;previously mentioned&lt;/a&gt;
I gave a talk at Melbourne R Users Group
 titled "Reproducible Research and R Workflow".
It covered technologies including LaTeX, Sweave, R, make, Eclipse, and git.
This post shares the video.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;p&gt;I'd like to thank Pedro Olaya for filming the session,
and &lt;a href="
http://www.drewconway.com/zia/"&gt;Drew Conway&lt;/a&gt;
for preparing, uploading, and hosting the video
along with the many other &lt;a href="
http://www.vcasmo.com/user/drewconway"&gt;great existing videos
from R User Groups from around the world&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you follow Drew's Blog &lt;a href="
http://www.drewconway.com/zia/"&gt;ZIA&lt;/a&gt;
 you may have already seen the video.
If you don't follow his blog, you should definitely check it out.
Here are three of my favourite posts by Drew:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.drewconway.com/zia/?p=2378"&gt;Data Science Venn Diagram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.drewconway.com/zia/?p=1614"&gt;Must have R Packages for Social Scientists&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.drewconway.com/zia/?p=2174"&gt;Ten Reasons Why Grad Students Should Blog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For those who did not catch Drew's &lt;a href="
http://www.drewconway.com/zia/?p=2549"&gt;original post&lt;/a&gt;, the videos are shown below.&lt;/p&gt;

&lt;h3&gt;My Talk&lt;/h3&gt;

&lt;p&gt;For a copy of the slides, R Code, and more see the &lt;a href="
http://jeromyanglim.blogspot.com/2010/12/r-workflow-slides-from-talk-at.html"&gt;previous post&lt;/a&gt;. 
The video is embedded below
(If you are viewing this post in a feed reader, 
and the embedded video is not displaying &lt;a href="
http://jeromyanglim.blogspot.com/2010/12/video-of-reproducible-research-with-r.html"&gt;click here&lt;/a&gt;
to go to the original post):
&lt;object width="440" height="360"&gt;&lt;param name="movie" value="http://www.vcasmo.com/swf/vcasmo.swf"&gt;&lt;/param&gt;&lt;param name="flashvars" value="pid=10362"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.vcasmo.com/swf/vcasmo.swf" flashvars="pid=10362" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" width="440" height="360"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;

&lt;h3&gt;Geoff's Talk&lt;/h3&gt;

&lt;p&gt;The other talk from the session was by Geoff Robinson
 who discussed several useful strategies for working with R.&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://files.meetup.com/1685538/R%20Workflow%20slides%20Geoff%20Robinson.ppt"&gt;slides&lt;/a&gt;
and &lt;a href="
http://files.meetup.com/1685538/R%20Workflow%20script%20Geoff%20Robinson.R"&gt;R Script&lt;/a&gt;
are available for download.&lt;/p&gt;

&lt;p&gt;The talk is embedded below:
&lt;object width="440" height="360"&gt;&lt;param name="movie" value="http://www.vcasmo.com/swf/vcasmo.swf"&gt;&lt;/param&gt;&lt;param name="flashvars" value="pid=10363"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowScriptAccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.vcasmo.com/swf/vcasmo.swf" flashvars="pid=10363" allowFullScreen="true" allowScriptAccess="always" type="application/x-shockwave-flash" width="440" height="360"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;

&lt;h3&gt;Melbourne R User Group&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/members/12349115/"&gt;Yuval Marom&lt;/a&gt;
 kindly asked me to become a co-organiser of the
&lt;a href="
http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/"&gt;Melbourne R user Group (MelbURN)&lt;/a&gt;.
While most people who read this blog are from overseas,
if you are in Melbourne, feel free to &lt;a href="
http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/"&gt;join the group&lt;/a&gt;.
If you know something about R, are passing through Melbourne, 
 and would like to give a talk on R,
 let Yuval or me know (see the &lt;a href="
 http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/"&gt;Contact Us Button&lt;/a&gt;),
 and we'll see if we can organise something. &lt;/p&gt;

&lt;h3&gt;Related Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/05/videos-on-data-analysis-with-r.html"&gt;R Videos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/search/label/Sweave"&gt;R and Sweave&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
https://github.com/jeromyanglim"&gt;Code from the talk on jeromyanglim @ github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-3721897032784687047?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ZPh9DNB8u_I:i451v87wwrY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ZPh9DNB8u_I:i451v87wwrY:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ZPh9DNB8u_I:i451v87wwrY:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ZPh9DNB8u_I:i451v87wwrY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ZPh9DNB8u_I:i451v87wwrY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ZPh9DNB8u_I:i451v87wwrY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ZPh9DNB8u_I:i451v87wwrY:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ZPh9DNB8u_I:i451v87wwrY:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ZPh9DNB8u_I:i451v87wwrY:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/ZPh9DNB8u_I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/3721897032784687047/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/12/video-of-reproducible-research-with-r.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/3721897032784687047?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/3721897032784687047?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/ZPh9DNB8u_I/video-of-reproducible-research-with-r.html" title="Video of Reproducible Research with R: Melbourne R Users 1st Dec 2010" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/12/video-of-reproducible-research-with-r.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIMQXg5fip7ImA9Wx9SEk0.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-2454464486960253630</id><published>2010-12-02T00:03:00.000+11:00</published><updated>2010-12-02T00:03:00.626+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-02T00:03:00.626+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="presentations" /><category scheme="http://www.blogger.com/atom/ns#" term="version_control" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>R Workflow: Slides from a Talk at Melbourne R Users (1st Dec 2010)</title><content type="html">I gave a presentation at 
&lt;a href="
http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/"&gt;Melbourne R Users&lt;/a&gt;
on the topic of R Workflow.
The presentation covered R code organisation,
and useful R related tools including Eclipse, StatET, Git, make, Sweave
and LaTeX.
Also, the slides from the presentation
 provide links to four complete examples of using R, 
 Sweave, LaTeX, and make.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;PDF of Slides&lt;/h3&gt;

&lt;p&gt;A PDF of the slides
 is available in &lt;a href="
 https://github.com/jeromyanglim/RMeetup_Workflow/raw/master/backup/Rmeetup_Workflow_fullscreen.pdf"&gt;fullscreen&lt;/a&gt;
 and &lt;a href="
https://github.com/jeromyanglim/RMeetup_Workflow/raw/master/backup/Rmeetup_Workflow_handout.pdf"&gt;four-to-a-page handout&lt;/a&gt;
format.
Most slides contain links to resources for learning more.
Thus, it should be possible to understand the main ideas of the talk just 
by just reading the slides and reading the links.&lt;/p&gt;

&lt;h3&gt;Video&lt;/h3&gt;

&lt;p&gt;A video of both my talk and the previous talk
by Geoff Robinson will hopefully be made available in the not
too distant future (I'll post when it is available).&lt;/p&gt;

&lt;h3&gt;Github Repository&lt;/h3&gt;

&lt;p&gt;If you want to learn more about &lt;code&gt;beamer&lt;/code&gt;, &lt;code&gt;LaTeX&lt;/code&gt; and &lt;code&gt;make&lt;/code&gt;,
you can check out the source code used to produce the PDF of the presentation.
The repository is available on GitHub:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/jeromyanglim/RMeetup_Workflow"&gt;https://github.com/jeromyanglim/RMeetup_Workflow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Thanks&lt;/h3&gt;

&lt;p&gt;I'd like to thank &lt;a href="http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/members/12349115/"&gt;Yuval Marom&lt;/a&gt;
 for all the work he has put into
kickstarting and organising the &lt;a href="
http://www.meetup.com/MelbURN-Melbourne-Users-of-R-Network/"&gt;Melbourne R User Group&lt;/a&gt;
and Deloitte for providing such a great venue.&lt;/p&gt;

&lt;h3&gt;Links Presented in the Talk&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://blog.revolutionanalytics.com/2010/10/a-workflow-for-r.html"&gt;David Smith on R Workflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://stackoverflow.com/questions/1429907/workflow-for-statistical-analysis-and-report-writing/1434424"&gt;StackOverflow Question on R Workflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.johnmyleswhite.com/notebook/2010/08/26/projecttemplate/"&gt;John Myles White's ProjectTemplate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.walware.de/goto/statet"&gt;StatET Official Site&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://www.splusbook.com/RIntro/RCourseMaterial.html"&gt;Useful StatET Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;My Guide to Getting Started with Eclipse, StatET and Sweave&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/getting-started-with-git-egit-eclipse.html"&gt;Git, Egit, and Eclipse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html"&gt;Makefiles, Sweave, and R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;Sweave Tutorial 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-2-individual.html"&gt;Sweave Tutorial 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-3-console-input-and.html"&gt;Sweave Tutorial 3&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
https://github.com/jeromyanglim/Sweave_Winter_Olympics"&gt;GitHub Repository of what will be Sweave Tutorial 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-2454464486960253630?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ad_KA4tXlGw:K9VV4N2OIdA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ad_KA4tXlGw:K9VV4N2OIdA:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ad_KA4tXlGw:K9VV4N2OIdA:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ad_KA4tXlGw:K9VV4N2OIdA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ad_KA4tXlGw:K9VV4N2OIdA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ad_KA4tXlGw:K9VV4N2OIdA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ad_KA4tXlGw:K9VV4N2OIdA:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ad_KA4tXlGw:K9VV4N2OIdA:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ad_KA4tXlGw:K9VV4N2OIdA:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/ad_KA4tXlGw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/2454464486960253630/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/12/r-workflow-slides-from-talk-at.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2454464486960253630?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/2454464486960253630?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/ad_KA4tXlGw/r-workflow-slides-from-talk-at.html" title="R Workflow: Slides from a Talk at Melbourne R Users (1st Dec 2010)" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/12/r-workflow-slides-from-talk-at.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUHRHYyeip7ImA9Wx9SEUw.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-5212348335923420306</id><published>2010-11-30T22:23:00.000+11:00</published><updated>2010-11-30T22:23:55.892+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-30T22:23:55.892+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Sweave Tutorial 3: Console Input and Output - Multiple Choice Test Analysis</title><content type="html">This post provides an example of using Sweave
 to perform an item analysis of a multiple choice test.
It is designed as a tutorial for learning more about 
 using Sweave in a mode where console input and output is displayed.
Copies of all source code and the final PDF report is provided.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;The repository with all source files is available at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/jeromyanglim/Sweave_Item_Analysis/"&gt;https://github.com/jeromyanglim/Sweave_Item_Analysis/&lt;/a&gt;.&lt;!--_--&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A copy of the resulting PDF can be viewed &lt;a href="
https://github.com/jeromyanglim/Sweave_Item_Analysis/raw/master/.backup/Item_Analysis_Report.pdf"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For general information on program requirements and running the code
 see &lt;a href="
 http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;this earlier post&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Sweave Documents that Display Console Input and Output&lt;/h3&gt;

&lt;p&gt;I find it useful to distinguish between different kinds of 
Sweave documents. One key distinction is between &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;reports that display the console and reports 
that do no display the console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reports that display the console are suited to distinct applications,
 including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;R tutorials&lt;/li&gt;
&lt;li&gt;Personal analyses&lt;/li&gt;
&lt;li&gt;Analyses provided to experts who understand R and the Project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It would be further possible to distinguish between 
reports that do and do not show the console input (&lt;code&gt;echo=true&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Developing Sweave reports that display the console
still benefit from thoughtful variable names, 
selective display of output and so forth.
However, naturally less time is invested in 
putting the polish on figures, tables, and inline text.&lt;/p&gt;

&lt;p&gt;The previous Sweave Tutorials were examples
 of Sweave documents that do not display the console.
&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;Tutorial 1 was a data driven document&lt;/a&gt;
&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-2-individual.html"&gt;Tutorial 2 was a set of batch polished reports&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The present tutorial is an example of
a Sweave document that displays console input and output.&lt;/p&gt;

&lt;p&gt;The remainder of the post discusses various aspects of the 
 source code.&lt;/p&gt;

&lt;h3&gt;Source Code&lt;/h3&gt;

&lt;h3&gt;Folder and File Structure&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;.gitignore&lt;/code&gt; records the folder where derived files are stored by &lt;code&gt;make&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;makefile&lt;/code&gt; is similar to that explained and used in &lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;Sweave Tutorial 1&lt;/a&gt;.
This similarity has been obtained through 
(a) the use of variables in the &lt;code&gt;makefile&lt;/code&gt; 
(b) the fact that both projects are driven by the &lt;code&gt;Rnw&lt;/code&gt; file;
thus, make calls Rnw, which in turn imports data, and so forth.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;README.md&lt;/code&gt; is a file in &lt;a href="
http://jeromyanglim.blogspot.com/2010/11/getting-started-with-markdown-benefits.html"&gt;markdown&lt;/a&gt;.
Markdown is the markup language used on Github.
The file is automatically displayed on the repository home page.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;data&lt;/code&gt;: This folder contains a file with the responses to the 50
multiple choice questions.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;meta&lt;/code&gt;: This folder contains a file with information
about each of the 50 multiple choice questions including the text,
response options, and the supposedly correct response.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;backup&lt;/code&gt;: This folder contains a copy of the resulting PDF.
Although this is a derived file and as such should not generally be monitored
by Git, it's helpful to include a copy for easy access.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Sweave.sty&lt;/code&gt;: I find it easier and more portable to just include this
LaTeX style file required by Sweave in with the project.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Item_Analysis_Report.Rnw&lt;/h3&gt;

&lt;h4&gt;Library loading and data import&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;initial_settings, echo=false&amp;gt;&amp;gt;=
options(stringsAsFactors=FALSE)
options(width=80)
library(psych) # used scoring and alpha
library(CTT) # used for spearman brown prophecy
@


&amp;lt;&amp;lt;import_data, echo=false&amp;gt;&amp;gt;=
cases &amp;lt;- read.delim("data/cases.tsv")
items &amp;lt;- read.delim("meta/items.tsv")
items$variable &amp;lt;- paste("item", items$item, sep="")
@
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;options(width=80)&lt;/code&gt; ensures that the console width is suitable
for the printed page&lt;/li&gt;
&lt;li&gt;&lt;code&gt;options(stringsAsFactors=FALSE)&lt;/code&gt; means that character variables
imported using &lt;code&gt;read.delim&lt;/code&gt; are left as character variables 
and not converted into &lt;code&gt;factors&lt;/code&gt;.
In general I find this a more useful default behaviour.
In particular I often use the actual text, particularly in metadata, 
to generate variable names, print text and so forth.
Leaving variables as character is better for this.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Using data before it has apparently been generated&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;...
The example involves performing an item analysis of 
responses of \Sexpr{nrow(cases)} students 
to a set of \Sexpr{nrow(items)} multiple choice test items.
...

&amp;lt;&amp;lt;&amp;gt;&amp;gt;=
&amp;lt;&amp;lt;initial_settings&amp;gt;&amp;gt;
&amp;lt;&amp;lt;import_data&amp;gt;&amp;gt;
@
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;In the above code I wanted to be able to write the number
of cases before showing the code for importing settings and data.
Thus, I first ran the code chunks with &lt;code&gt;echo=false&lt;/code&gt; to prevent display.
Then, afterwards, these code chunks were rerun inside a code chunk
using the syntax &lt;code&gt;&amp;lt;&amp;lt;name_of_code_chunk&amp;gt;&amp;gt;&lt;/code&gt; &lt;!--_--&gt;
(i.e., without the &lt;code&gt;=&lt;/code&gt; sign at the end of the opening.
This time they were displayed.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Scoring multiple choice tests&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;score_test&amp;gt;&amp;gt;=
itemstats &amp;lt;- score.multiple.choice(key = items$correct, 
            data = cases[,items$variable])
@
&lt;/code&gt;&lt;/pre&gt;

&lt;!--_--&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;score.multiple.choice&lt;/code&gt; is a function in the &lt;code&gt;psych&lt;/code&gt; package
for scoring multiple choice tests.
&lt;code&gt;key&lt;/code&gt; is a vector of integers representing the correct response.
&lt;code&gt;data&lt;/code&gt; is a matrix or data.frame of responses from a 
set of respondents.&lt;/li&gt;
&lt;li&gt;the example shows how metadata can be used to simplify code.
&lt;code&gt;items$variable&lt;/code&gt; includes the name of the 50 personality test items
&lt;code&gt;items$correct&lt;/code&gt; includes the vector of correct responses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h3&gt;Figures in Sweave&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;plot_mean_by_r, fig=true&amp;gt;&amp;gt;=
plot(r ~ mean , itemstats$item.stats, type="n")
text(itemstats$item.stats$mean, itemstats$item.stats$r, 1:50)
abline(h=.2, v=c(.5, .9))
@
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Code chunks can produce single figures.
the &lt;code&gt;fig=true&lt;/code&gt; key-value pair is required.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;type="n"&lt;/code&gt; is used to not show points
and then &lt;code&gt;text(...)&lt;/code&gt; is used to plot the item numbers on the plot.&lt;/li&gt;
&lt;li&gt;Because the document is an informal document
designed to display the console,
the figure is not wrapped in a figure float.
A float would involve more typing and might even be annoying if
it moved around the document.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h3&gt;Using Sweave to Better follow the DRY (Don't Repeat Yourself) Principle&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;flag_bad_items&amp;gt;&amp;gt;=
rules &amp;lt;- list(
        tooEasy = .95,
        tooHard = .3,
        lowR = .15)
oritemstats$item.stats$tooEasy &amp;lt;- 
    oritemstats$item.stats$mean &amp;gt; rules$tooEasy
...
@

\begin{itemize}
\item \emph{Too Easy}: mean correct $&amp;gt;$
\Sexpr{rules$tooEasy}.
\Sexpr{sum(oritemstats$item.stats$tooEasy)}
items were bad by this definition.
... 
\end{itemize}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The above abbreviated version of the actual code highlights 
how Sweave can be used to prevent repetition
and facilitate modifiability.&lt;/li&gt;
&lt;li&gt;The code flags items as too easy if more than 95% of participants
get the item correct.
This value (&lt;code&gt;.95&lt;/code&gt;) is stored in a variable.
It's then subsequently used both in the code to flag
items as too easy and also used in the text where the
rule is described in plain text (i.e., &lt;code&gt;\Sexpr{rules$tooEasy}&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;This is a particularly powerful use of Sweave whereby any text
in a document that might be repeated or any text that describes
details of a data analytic algorithm is a good candidate for simplification
using Sweave.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;h4&gt;\Sexpr{} and formatting&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;The formula suggests  that in order to obtain
an alpha of \Sexpr{sbrown$targetAlpha},
\Sexpr{round(sbrown$multiple, 2)} times as many items are required.
Thus, the final scale would need around
\Sexpr{ceiling(sbrown$refinedItemCount)} items.
Assuming a similar number of good and bad items,
this would require an initial pool of around
\Sexpr{ceiling(sbrown$totalItemCount)} items.
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The above code highlights a couple of examples of how inline
formatting of numbers can be done, and is often required
when including inline text.
In this case, &lt;code&gt;ceiling&lt;/code&gt; and &lt;code&gt;round&lt;/code&gt; functions were used.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Sweave Tutorial Series&lt;/h3&gt;

&lt;p&gt;This post is the third installment in a Sweave Tutorial Series:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;Using Sweave, R, and Make to Generate a PDF of Multiple Choice Questions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;Batch Individual Personality Reports using R, Sweave, and LaTeX&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Related Posts&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;Getting Started with Sweave&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;makefiles for Sweave, R and LaTeX using Eclipse on Windows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-5212348335923420306?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=R7Lia5VFUKE:PQlEuUOcRsk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=R7Lia5VFUKE:PQlEuUOcRsk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=R7Lia5VFUKE:PQlEuUOcRsk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=R7Lia5VFUKE:PQlEuUOcRsk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=R7Lia5VFUKE:PQlEuUOcRsk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=R7Lia5VFUKE:PQlEuUOcRsk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=R7Lia5VFUKE:PQlEuUOcRsk:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=R7Lia5VFUKE:PQlEuUOcRsk:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=R7Lia5VFUKE:PQlEuUOcRsk:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/R7Lia5VFUKE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/5212348335923420306/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-3-console-input-and.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/5212348335923420306?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/5212348335923420306?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/R7Lia5VFUKE/sweave-tutorial-3-console-input-and.html" title="Sweave Tutorial 3: Console Input and Output - Multiple Choice Test Analysis" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-3-console-input-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMHR3w8eSp7ImA9Wx9SEEw.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-8639315527477758240</id><published>2010-11-29T17:48:00.001+11:00</published><updated>2010-11-29T17:50:36.271+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-29T17:50:36.271+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="personality" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Sweave Tutorial 2: Batch Individual Personality Reports using R, Sweave, and LaTeX</title><content type="html">&lt;p&gt;
This post documents an example of using Sweave
to generate individualised personality reports based on 
responses to a personality test.
Each report provides information on both the responses of the general 
sample and responses of the specific respondent.
All source code is provided, and selected aspects are discussed,
including &lt;code&gt;makefiles&lt;/code&gt; use of &lt;code&gt;\Sexpr&lt;/code&gt;, figures, and LaTeX tables using Sweave.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;All source code is available on GitHub:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/jeromyanglim/Sweave_Personality_Reports"&gt;https://github.com/jeromyanglim/Sweave_Personality_Reports&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Three examples of compiled PDF reports can be viewed as follows: 
&lt;a href="https://github.com/jeromyanglim/Sweave_Personality_Reports/raw/master/.backup/Report_Template_ID1.pdf"&gt;ID1&lt;/a&gt;
&lt;a href="https://github.com/jeromyanglim/Sweave_Personality_Reports/raw/master/.backup/Report_Template_ID2.pdf"&gt;ID2&lt;/a&gt;
and &lt;a href="
https://github.com/jeromyanglim/Sweave_Personality_Reports/raw/master/.backup/Report_Template_ID4.pdf"&gt;ID4&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The resulting report is a simple proof of concept example.&lt;/p&gt;

&lt;h3&gt;Discussion of Source Code&lt;/h3&gt;

&lt;h3&gt;makefile&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;outputDir = .output
backupDir = .backup

test:
    -mkdir $(outputDir)
    Rscript --verbose run1test.R  

test5:
    -mkdir $(outputDir)
    Rscript --verbose run5test.R  


runall:
    -mkdir $(outputDir)
    Rscript --verbose runAll.R  

clean:
    -rm $(outputDir)/*

backup:
    -mkdir $(backupDir)
    cp $(outputDir)/Report_Template_ID*[0123456789].pdf --target-directory=$(backupDir)
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;outputDir&lt;/code&gt; stores the name of the folder used to store derived files 
(e.g., tex files, images, and compiled document PDFs)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;backupDir&lt;/code&gt; stores the name of the folder where document PDFs are to be stored&lt;/li&gt;
&lt;li&gt;&lt;code&gt;test:&lt;/code&gt; is the default goal.
Running make in the project directory will run &lt;code&gt;run1test.R&lt;/code&gt; which will 
build one report.&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;--verbose&lt;/code&gt; option shows the progress of R when run as a script.
It's useful for seeing progress and debugging.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;test5:&lt;/code&gt; compiles five reports.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;runall:&lt;/code&gt; compiles all reports.
Further information on each of the &lt;code&gt;Run... .R&lt;/code&gt; files can be obtained by inspecting these files. In general they source &lt;code&gt;Run.R&lt;/code&gt; and specify which ids to run reports on.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;clean:&lt;/code&gt; removes all the files from the output directory 
(i.e., all the derived files)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;backup:&lt;/code&gt; copies reports to the backup folder; i.e., it separates the finished documents from all the other derived files.&lt;/li&gt;
&lt;li&gt;To run &lt;code&gt;test5&lt;/code&gt;, &lt;code&gt;runnall&lt;/code&gt; etc., type &lt;code&gt;make test5&lt;/code&gt; or &lt;code&gt;make runnall&lt;/code&gt; etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3&gt;main.R&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;main.R&lt;/code&gt; loads external functions and packages, imports data,
imports metadata and processes the data.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Import Data
ipip &amp;lt;-read.delim("data/ipip.tsv")
ipipmeta &amp;lt;-read.delim("meta/ipipmeta.tsv")
ipipscales &amp;lt;- read.delim("meta/ipipscales.tsv")
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;When importing the data, I have adopted the useful convention 
(which I observed from &lt;a href="
http://www.johnmyleswhite.com/notebook/2010/08/26/projecttemplate/"&gt;John Myles White's ProjectTemplate Package&lt;/a&gt;) 
of naming objects and data file names the same.
The file extension also clearly indicates the file format (i.e., tab-separated-values).&lt;/li&gt;
&lt;li&gt;I often have separate &lt;code&gt;data&lt;/code&gt; and &lt;code&gt;meta&lt;/code&gt; folders.
Importing metadata often makes for more manageable code than when
incorporating metadata by hard coding it into the R script.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Test scores are calculated using the function &lt;code&gt;score.items&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ipipstats &amp;lt;- psych::score.items(ipipmeta[,ipipscales$scale], 
        ipip[,ipipmeta[,"variable"]],
        min = 1, max = 5)
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;psych&lt;/code&gt; package has a number of useful functions for psychological research.
&lt;code&gt;score.items&lt;/code&gt; is particularly good.
It enables the creation of means and totals for multiple scales.
It handles item reversal.
It also returns information related to the reliability of the scales.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3&gt;Run.R&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;source("main.R", echo = TRUE)
id &amp;lt;- NULL
exportReport &amp;lt;- function(x) {
    id &amp;lt;&amp;lt;- x
    fileStem &amp;lt;- "Report_Template"
    file.copy("Report_Template.Rnw",
            paste(".output/", fileStem, "_ID", id, ".Rnw", sep =""),
            overwrite = TRUE)
    file.copy("Sweave.sty", ".output/Sweave.sty", overwrite = TRUE)
    setwd(".output")
    Sweave(paste(fileStem, "_ID", id, ".Rnw", sep =""))
    tools::texi2dvi(paste(fileStem, "_ID", id, ".tex", sep =""), pdf = TRUE)
    setwd("..")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The above code provides the function to run Sweave on each
individualised report&lt;/li&gt;
&lt;li&gt;the code is a little bit messy, contains a few hacks, 
and is not especially robust.&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;exportReport&lt;/code&gt; function takes an &lt;code&gt;id&lt;/code&gt; value as an argument &lt;code&gt;x&lt;/code&gt;. 
Note the use of the alternative assignment operator.
(&lt;a href="http://stat.ethz.ch/R-manual/R-patched/library/base/html/assignOps.html"&gt;See ?assignOps&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;The code is designed to keep derived files away from source files
by copying files into the &lt;code&gt;.output&lt;/code&gt; folder and
even changing the working directory to that directory.&lt;/li&gt;
&lt;li&gt;The code creates an individualised copy of the Rnw file; 
Runs &lt;code&gt;Sweave&lt;/code&gt; on the report to produce a &lt;code&gt;tex&lt;/code&gt; file,
and then runs &lt;code&gt;texi2dvi&lt;/code&gt; with &lt;code&gt;pdf=TRUE&lt;/code&gt; to produce the final &lt;code&gt;pdf&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3&gt;Report_Template.Rnw&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Rnw&lt;/code&gt; file contains interspersed chunks of LaTeX and R code.&lt;/li&gt;
&lt;li&gt;Because the &lt;code&gt;Rnw&lt;/code&gt; file is called from within R, 
all the R objects and data processing code does not need to be called 
at the start of the Rnw file.
This approach is one way of reducing the time it takes to run
a set of Sweave reports all based on a common data source.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;\Sexpr{}&lt;/code&gt; command is used to incorporate in-line text.
(&lt;code&gt;... sample of \Sexpr{nrow(ipip)} students ...&lt;/code&gt;). 
In the example above, it prints the actual number of cases
into the &lt;code&gt;ipip&lt;/code&gt; data.frame (i.e., the sample size).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Incorporating a figure using Sweave&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;\begin{figure}
&amp;lt;&amp;lt;plot_scale_distributions, fig=true&amp;gt;&amp;gt;=
plotScale &amp;lt;- function(ipipscale) {
    ggplot(ipip, aes_string(x=ipipscale["scale"])) + 
        scale_x_continuous(limits=c(1, 5),
            name = ipipscale["name"]) +
        scale_y_continuous(name = "", labels ="",   breaks = 0) +
        geom_density(fill="green", alpha = .5) +
        geom_vline(xintercept = ipip[ipip$id %in% id, ipipscale["scale"]],
                size=1) 
}


scaleplots &amp;lt;-   apply(ipipscales, 1, function(X) plotScale(X))

arrange(scaleplots[[1]], 
        scaleplots[[2]],
        scaleplots[[3]],
        scaleplots[[4]],
        scaleplots[[5]],
        ncol=3)
@
\caption{Figures show distributions of scores of each personality factor
in the norm sample.
Higher scores mean greater levels of the factor. 
The black vertical line indicates your score.}
\end{figure}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The first R code chunk produces a figure using &lt;code&gt;ggplot2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The code above takes a while to run (perhaps around 10 seconds on my machine).
But the resulting plot is more attractive than what I could easily get with 
&lt;code&gt;base&lt;/code&gt; graphics.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;&amp;lt;plot_scale_distributions, fig=true&amp;gt;&amp;gt;=&lt;/code&gt; indicates the start of 
an R code chunk. 
&lt;code&gt;fig=true&lt;/code&gt; lets Sweave know that it has to produce code to include a figure.&lt;/li&gt;
&lt;li&gt;The R code chunk is substituted with
&lt;code&gt;\includegraphics{Report_Template_ID10-plot_scale_distributions}&lt;/code&gt;
in the &lt;code&gt;tex&lt;/code&gt; file and the &lt;code&gt;pdf&lt;/code&gt; and &lt;code&gt;eps&lt;/code&gt; figures are created.
Thus, if you want a float with captions and labels,
you have to add them around the R code chunk.&lt;/li&gt;
&lt;li&gt;the &lt;code&gt;plotScale&lt;/code&gt; function is used to generate a ggplot2 figure
of the distribution of scores on each personality scale along with 
a marking of the respondent's score on each scale.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;arrange&lt;/code&gt; function is used to layout multiple ggplot2 figures
on a single plot. 
The source code is in the &lt;code&gt;lib/vp.layout.R&lt;/code&gt; and was taken from 
a [post by Stephen Turner(
http://gettinggeneticsdone.blogspot.com/2010/03/arrange-multiple-ggplot2-plots-in-same.html)&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Preparing a formatted table in R for LaTeX&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;prepare_table&amp;gt;&amp;gt;=
ipiptable &amp;lt;- list()
ipiptable$colnames &amp;lt;- c("item", "scaleF", "text", "meanF",
        "sdF", "is1F", "is2F", "is3F", "is4F", "is5F")
ipiptable$cells &amp;lt;- ipipsummary[,ipiptable$colnames ]
ipiptable$cells$item &amp;lt;- paste(ipiptable$cells$item, ".", sep="")

# assign actual respones to table
ipiptable$cells[,c("is1F", "is2F", "is3F", "is4F", "is5F")] &amp;lt;-
        sapply(1:5, function(X)
        ifelse(as.numeric(ipip[ipip$id %in% id, ipipmeta$variable]) == X, 
                paste("*", ipiptable$cells[[paste("is", X, "F", sep ="")]], sep =""),
                ipiptable$cells[[paste("is", X, "F", sep ="")]]))


ipiptable$cellsF &amp;lt;- as.matrix(ipiptable$cells) 

ipiptable$cellsF &amp;lt;- ipiptable$cellsF[order(ipiptable$cellsF[, "scaleF"]), ]

ipiptable$row1 &amp;lt;- c("", "Scale", "Item Text", 
        "M", "SD", "VI\\%", "MI\\%", "N\\%", "MA\\%", "VA\\%")

ipiptable$table &amp;lt;- rbind(ipiptable$row1, ipiptable$cellsF)
ipiptable$tex &amp;lt;- paste(
        apply(ipiptable$table, 1, function(X) paste(X, collapse = " &amp;amp; ")), 
        "\\\\")
for(i in c(41, 31, 21, 11, 1)) {
    ipiptable$tex &amp;lt;- append(ipiptable$tex, "\\midrule", after=i)
}
ipiptable$tex1 &amp;lt;- ipiptable$tex[c(1:34)]
ipiptable$tex2 &amp;lt;- ipiptable$tex[c(1,35:56)]
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;I often find it useful to split R code chunks for 
table preparation and table presentation.
In general this allows any text that appears before the table to include
&lt;code&gt;\Sexpr{}&lt;/code&gt; commands incorporating figures from the analyses which 
generate the table.
In the present case, it was useful because the table was split over two pages.&lt;/li&gt;
&lt;li&gt;The code shows some of the general logic I use for customised table creation.
In hindsight I could probably refactor it into a function so that I don't have to always type &lt;code&gt;ipiptable&lt;/code&gt; which would make things a little more concise&lt;/li&gt;
&lt;li&gt;The general process of table creation involves:
(a) extracting information on cells with cells often grouped into types which will receive common formatting treatment
(b) formatting cells (e.g., rounding, decimals, and so on)
(c) assembling the cells typically using a combination of the functions 
&lt;code&gt;rbind&lt;/code&gt; and &lt;code&gt;cbind&lt;/code&gt;
(d) Inserting tex column and end of row separators with something like:
&lt;code&gt;paste(apply(x, 1, function(X) paste(X, collapse = " &amp;amp; ")), "\\\\")&lt;/code&gt;
where &lt;code&gt;x&lt;/code&gt; is the matrix of table cells.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Don't Repeat Yourself Principle using R and Sexpr{}&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;ipiptable$caption &amp;lt;-
        "Response options were 
1 = (V)ery (I)naccurate, 
2 = (M)oderately (I)naccurate,
3 = (N)either Inaccurate nor Accurate, 
4 = (M)oderately (A)ccurate
5 = (V)ery (A)ccurate.
Thus, VI\\\\% indicates the percentage of the norm sample 
        giving a response indicating that the item is a Very Inaccurate
description of themselves.
Your response is indicated with an asterisk (*)."
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;This text was used in both tables.
Thus, this text can then be called using &lt;code&gt;\Sexpr{ipiptable[["caption"]]}&lt;/code&gt;.
This follows the DRY principle (Don't Repeat Yourself).
Thus, if the caption needs to be modified, it only needs to be modified in one place.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Incorporating the tex formatted table using R Code chunks&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;\begin{table}
\begin{adjustwidth}{-1cm}{-1cm}
\caption{Table of results for (A)greeableness, (C)onscientiousness
and (E)motional (S)tability items.
\Sexpr{ipiptable[["caption"]]}} 
\begin{center}
\begin{tabular}{rrp{4cm}rrrrrrr}
\toprule
&amp;lt;&amp;lt;table_part1, results=tex&amp;gt;&amp;gt;=
cat(ipiptable$tex1, sep="\n") 
@
\bottomrule
\end{tabular}
\end{center}
\end{adjustwidth}
\end{table}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The tables are then incorporated into the &lt;code&gt;tex&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;The R code only generated some of the required &lt;code&gt;tex&lt;/code&gt; for the table.
Thus all the other desired elements such as the table environment and captions
are written either side of the R code chunk.&lt;/li&gt;
&lt;li&gt;the R code chunk uses the option &lt;code&gt;results=tex&lt;/code&gt; in order to enter
the output from the &lt;code&gt;cat&lt;/code&gt; function verbatim into the resulting tex file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cat(ipiptable$tex1, sep="\n")&lt;/code&gt; includes a vector of &lt;code&gt;tex&lt;/code&gt;.
With the newline separator simply making the resulting &lt;code&gt;tex&lt;/code&gt; more readable.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Additional Resources&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;Getting Started with Sweave&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2009/06/learning-r-for-researchers-in.html"&gt;Getting Started with R&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html"&gt;Sweave Tutorial: Using Sweave, R, and Make to Generate a PDF of Multiple Choice Questions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-8639315527477758240?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=I8BFJ2z3neE:LxRav0Y9-Xs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=I8BFJ2z3neE:LxRav0Y9-Xs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=I8BFJ2z3neE:LxRav0Y9-Xs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=I8BFJ2z3neE:LxRav0Y9-Xs:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=I8BFJ2z3neE:LxRav0Y9-Xs:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=I8BFJ2z3neE:LxRav0Y9-Xs:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=I8BFJ2z3neE:LxRav0Y9-Xs:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=I8BFJ2z3neE:LxRav0Y9-Xs:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=I8BFJ2z3neE:LxRav0Y9-Xs:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/I8BFJ2z3neE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/8639315527477758240/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-2-individual.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/8639315527477758240?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/8639315527477758240?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/I8BFJ2z3neE/sweave-tutorial-2-individual.html" title="Sweave Tutorial 2: Batch Individual Personality Reports using R, Sweave, and LaTeX" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-2-individual.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QAQ38ycSp7ImA9Wx9TGUQ.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-1408227657154734343</id><published>2010-11-29T13:55:00.000+11:00</published><updated>2010-11-29T13:55:42.199+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-29T13:55:42.199+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="version_control" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Getting Started with Git, EGit, Eclipse, and GitHub: Version Control for R Projects</title><content type="html">This post provides information on &lt;br /&gt;
(a) installing Git using the Eclipse plugin Egit.
(b) uploading repositories to GitHub, and
(c) links to resources on Git, Git and LaTeX, and Git and R.
The focus is on version control for people working on R, Sweave, and LaTeX
related projects.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;Version control works really well with R, Sweave, and LaTeX projects.&lt;/p&gt;

&lt;h4&gt;Benefits of Version Control&lt;/h4&gt;

&lt;p&gt;There are many benefits to version control for the data analyst. 
Version control allows you to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rewind a project or a file to a previous state,
which in turn encourages experimentation&lt;/li&gt;
&lt;li&gt;Ensure there is a record of changes&lt;/li&gt;
&lt;li&gt;Facilitate collaboration&lt;/li&gt;
&lt;li&gt;Facilitate backup&lt;/li&gt;
&lt;li&gt;Show changes between files&lt;/li&gt;
&lt;li&gt;Facilitate code sharing and reproducibility&lt;/li&gt;
&lt;li&gt;and much more...
See this question on &lt;a href="
http://stackoverflow.com/questions/2712421/r-and-version-control-for-the-solo-data-analyst"&gt;StackOverflow&lt;/a&gt;
for further discussion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also found that adopting version control 
facilitated several conceptual benefits.
It encouraged greater consideration of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the distinction between source and derived files&lt;/li&gt;
&lt;li&gt;the nature of dependencies: 
&lt;ul&gt;&lt;li&gt;dependencies between elements of code&lt;/li&gt;
&lt;li&gt;dependencies between files within a project&lt;/li&gt;
&lt;li&gt;and dependencies with files and programs external to the repository&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;the nature of a repository and how repositories should be divided&lt;/li&gt;
&lt;li&gt;the nature of committing and documenting changes and project milestones&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Choosing a Version Control System and Workflow&lt;/h3&gt;

&lt;h4&gt;Why Git?&lt;/h4&gt;

&lt;p&gt;There are many version control systems (see &lt;a href="http://codicesoftware.blogspot.com/2010/11/version-control-timeline.html"&gt;Plastic SCM&lt;/a&gt; for a discussion).
I've chosen to use Git for the following reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git can work well with Eclipse and Windows using Egit and 
&lt;a href="http://stackoverflow.com/questions/157476/what-guis-exist-for-git-on-windows"&gt;many other tools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Git is one of the popular version control systems&lt;/li&gt;
&lt;li&gt;Git enables uploading to Github&lt;/li&gt;
&lt;li&gt;Git has good documentation and support material&lt;/li&gt;
&lt;li&gt;Experts, who know a lot more about version control than I do, use Git
(e.g., &lt;a href="https://github.com/hadley"&gt;Hadley Wickham&lt;/a&gt;);
the designer of Git is &lt;a href="http://www.youtube.com/watch?v=4XpnKHJAok8"&gt;Linus Torvalds&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, the big difference is between using a version control system 
and not using a version control system.&lt;/p&gt;

&lt;h4&gt;Why EGit?&lt;/h4&gt;

&lt;p&gt;EGit is a Git plugin for Eclipse.
I use Eclipse and StatET to write R code and Sweave documents.
I found EGit a particularly easy tool for getting started with Git 
and version control.
The documentation is straightforward and the interface is easily integrated into
my Eclipse workflow.&lt;/p&gt;

&lt;h3&gt;Getting Started with EGit and Git in Eclipse&lt;/h3&gt;

&lt;p&gt;There are many ways to interact with Git.&lt;/p&gt;

&lt;p&gt;Installing EGit in eclipse involves using the update manager.
&lt;a href="
http://www.vogella.de/articles/EGit/ar01s02.html"&gt;Vogella.de has a tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To get started with your first Git repository in Eclipse, check out the
&lt;a href="http://wiki.eclipse.org/EGit/User_Guide"&gt;EGit user Guide&lt;/a&gt;. &lt;!--_--&gt;
When I was first getting started I used
a simple R project rather than a Java Hello World application.&lt;/p&gt;

&lt;h3&gt;GitHub&lt;/h3&gt;

&lt;p&gt;GitHub is one of several sites for sharing git repositories 
(for example, see Hadley Wickham's &lt;a href="https://github.com/hadley/data-baby-names"&gt;baby names analysis&lt;/a&gt;, or
my own example of using &lt;a href="http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html"&gt;Sweave to write Multiple Choice Questions&lt;/a&gt;).
It also has many useful social networking features.&lt;/p&gt;

&lt;h4&gt;Uploading a repository to GitHub from Eclipse&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Set up a free account on &lt;a href="https://github.com/"&gt;https://github.com/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Work through the tutorial on &lt;a href="
http://wiki.eclipse.org/EGit/User_Guide#Create_Repository_at_GitHub"&gt;creating a repository at GitHub&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While the above tutorial briefly mentions &lt;a href="
http://wiki.eclipse.org/EGit/User_Guide#Eclipse_SSH_Configuration"&gt;SSH Configuration&lt;/a&gt;, &lt;!--_--&gt; 
it does not go into detail.
When setting up my SSH key, I did the following:  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click &lt;code&gt;Eclipse -- Window -- Preferences -- General -- Network Connections -- SSH2 -- Key Management&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click on Generate DSA Key&lt;/li&gt;
&lt;li&gt;Type in a passphrase (i.e., a long and robust password)&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;Save Private Key&lt;/code&gt; (I saved it to a new folder under my user account)&lt;/li&gt;
&lt;li&gt;Go to this new folder and open "id_dsa.pub" &lt;!--_--&gt; 
as a plain text file and copy the contents of the file to the clipboard.&lt;/li&gt;
&lt;li&gt;Go to &lt;code&gt;github.com -- Account Settings -- SSH Public Keys&lt;/code&gt; 
and click &lt;code&gt;Add another public key&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Paste the public key into the box and give it a name&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Using gist.github&lt;/h4&gt;

&lt;p&gt;Gists provide a quick way to get started with GitHub.
Gists are useful for storing and sharing snippets of code.
The result can be embedded into blog posts.
To get formatted R code, 
 give the file name a ".r" file extension (e.g., "test.r") 
 (thanks to &lt;a href="http://support.github.com/discussions/feature-requests/171-syntax-highlighting-for-r"&gt;Hadley Wikham&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;A simple example of an embedded gist is shown below:&lt;/p&gt;

&lt;script src="https://gist.github.com/706557.js?file=hello_world.r"&gt;&lt;/script&gt;

&lt;h4&gt;Interesting R GitHub repositories&lt;/h4&gt;

&lt;p&gt;Good examples of people sharing R projects on GitHub include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/hadley/"&gt;Hadley Wickham&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/diegovalle"&gt;Diego Valle&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/johnmyleswhite"&gt;John Myles White&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/drewconway/"&gt;Drew Conway&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the suggestions &lt;a href="http://stats.stackexchange.com/questions/4429/who-to-follow-on-github-to-learn-about-best-practice-in-data-analysis"&gt;on Stats.SE&lt;/a&gt;.
I also have &lt;a href="https://github.com/jeromyanglim/"&gt;an account&lt;/a&gt;
in case you are interested. &lt;/p&gt;

&lt;h3&gt;Additional Resources&lt;/h3&gt;

&lt;h4&gt;General Git&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www-cs-students.stanford.edu/~blynn/gitmagic/"&gt;Gitmagic tutorial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://progit.org/blog.html"&gt;Progit blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.gitready.com/"&gt;Gitready&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.youtube.com/watch?v=8dhZ9BXQgc4&amp;amp;feature=channel"&gt;Video of Google Tech Talk on Git&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Git and LaTeX&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://www.academicproductivity.com/2008/revision-control-for-latex-in-search-of-an-answer/"&gt;Discussion on the Academic Productivity Blog&lt;/a&gt; 
on the topic of version control and LaTeX&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tex.stackexchange.com/search?tab=relevance&amp;amp;q=git"&gt;Tex.SE&lt;/a&gt; 
has several questions on LaTeX and git&lt;/li&gt;
&lt;li&gt;Article on &lt;a href="
http://www.tug.org/pracjourn/2007-3/henningsen/henningsen.pdf"&gt;tools for collaborative writing of scientific latex documents&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ctan.org/tex-archive/support/vc/vc-manual.pdf"&gt;vc package&lt;/a&gt; on CTAN supports Git&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Git and R&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/2712421/r-and-version-control-for-the-solo-data-analyst"&gt;Benefits of version control for the solo data analysist&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://permut.wordpress.com/2010/04/21/revision-control-statistics-bleg"&gt;Revision control and statistics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.kieranhealy.org/files/misc/workflow-apps.pdf"&gt;Thoughts on version control by Kieran Healy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/2286831/how-do-you-combine-revision-control-with-workflow-for-r"&gt;Revision Control, Workflow, and R&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-1408227657154734343?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=rVrzb1HFlYY:NKfcYFCqm10:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=rVrzb1HFlYY:NKfcYFCqm10:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=rVrzb1HFlYY:NKfcYFCqm10:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=rVrzb1HFlYY:NKfcYFCqm10:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=rVrzb1HFlYY:NKfcYFCqm10:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=rVrzb1HFlYY:NKfcYFCqm10:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=rVrzb1HFlYY:NKfcYFCqm10:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=rVrzb1HFlYY:NKfcYFCqm10:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=rVrzb1HFlYY:NKfcYFCqm10:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/rVrzb1HFlYY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/1408227657154734343/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/11/getting-started-with-git-egit-eclipse.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/1408227657154734343?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/1408227657154734343?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/rVrzb1HFlYY/getting-started-with-git-egit-eclipse.html" title="Getting Started with Git, EGit, Eclipse, and GitHub: Version Control for R Projects" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/11/getting-started-with-git-egit-eclipse.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04FSXg-eip7ImA9Wx9SF0U.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-1120662403227628927</id><published>2010-11-27T00:31:00.006+11:00</published><updated>2010-12-08T16:25:18.652+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-08T16:25:18.652+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="teaching" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="make" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>Sweave Tutorial 1: Using Sweave, R, and Make to Generate a PDF of Multiple Choice Questions</title><content type="html">In this post I present an example of using Sweave to prepare a PDF of formatted multiple choice questions.
More broadly the example shows how to use Sweave to incorporate elements of a database
into a formatted  LaTeX document.
It aims to be useful to anyone wanting to learn more about the almost magical powers of &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;Sweave&lt;/code&gt;, and &lt;code&gt;R&lt;/code&gt;.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;The repository with all source files is available at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/jeromyanglim/Sweave_MCQ"&gt;https://github.com/jeromyanglim/Sweave_MCQ&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The repository allows you to download all files as an archive or view the files individually on the web.
A copy of the final PDF generated from the process is available 
&lt;a href="https://github.com/jeromyanglim/Sweave_MCQ/raw/master/.backup/Sweave_MCQ.pdf"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I ran the code on Windows with the following programs installed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.r-project.org/"&gt;R&lt;/a&gt;: For the R code&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.murdoch-sutherland.com/Rtools/"&gt;Rtools&lt;/a&gt;: For &lt;code&gt;make&lt;/code&gt; and the &lt;code&gt;sh&lt;/code&gt; commands in Make and for Sweave to run on the command line&lt;/li&gt;
&lt;li&gt;&lt;a href="http://miktex.org/"&gt;MikTeX&lt;/a&gt;: For compilation of the PDF using &lt;code&gt;texify&lt;/code&gt; and the default downloading of the &lt;code&gt;exam&lt;/code&gt; document class&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It should run on MAC and Linux with appropriate R, make, and LaTeX tools installed.&lt;/p&gt;

&lt;p&gt;Assuming you have the above installed, to run the code&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Download the &lt;a href="https://github.com/jeromyanglim/Sweave_MCQ"&gt;repository from github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Uninstall to a directory&lt;/li&gt;
&lt;li&gt;Open the shell in that directory&lt;/li&gt;
&lt;li&gt;Type: &lt;code&gt;make&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The remainder of this post explains the code in each of the main files in the repository.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3&gt;The Makefile&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;makefile&lt;/code&gt; is used to build the PDF from the Rnw Source.
It also performs other useful tasks.
A copy of the makefile is shown below:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;output = .output
rnwfile = Sweave_MCQ
backup = .backup

all:
    R CMD Sweave $(rnwfile).Rnw
    -mkdir $(output)
    -cp *.sty $(output)
    -mv *.tex *.pdf *.eps $(output)
    cd $(output); texify --run-viewer --pdf $(rnwfile).tex 

tex:
    cd $(output); texify --run-viewer --pdf $(rnwfile).tex

clean:
    -rm $(output)/*

backup:
    -mkdir $(backup)
    cp  $(output)/$(rnwfile).pdf $(backup)/$(rnwfile).pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I recently &lt;a href="http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html"&gt;posted on the benefits of makefiles when developing Sweave documents.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;make&lt;/code&gt; file starts with three variables.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;output&lt;/code&gt; stores the name of the folder where where all derivative files are placed.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;rnwfile&lt;/code&gt; stores the name of the Rnw source file without the &lt;code&gt;.Rnw&lt;/code&gt; extension. 
This is also the base of the resulting &lt;code&gt;.tex&lt;/code&gt; and &lt;code&gt;.pdf&lt;/code&gt; files.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;backup&lt;/code&gt; stores the name of the folder where a copy of the pdf is placed if this is desired.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The file then has four goals.&lt;/p&gt;

&lt;p&gt;The default goal is called &lt;code&gt;all:&lt;/code&gt;.
If &lt;code&gt;make&lt;/code&gt; is called without argument from the command line in the project directory, the recipe immediately below &lt;code&gt;all:&lt;/code&gt; is run. Note that all apparent indentations are tab indentations (a set of spaces would cause an error).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first line runs Sweave on the &lt;code&gt;Rnw&lt;/code&gt; file from the command line.
On windows this &lt;code&gt;R CMD Sweave&lt;/code&gt; requires installation of &lt;a href="http://www.murdoch-sutherland.com/Rtools/"&gt;Rtools&lt;/a&gt;
Note how &lt;code&gt;$(rnwfile).Rnw&lt;/code&gt; will actually be &lt;code&gt;Sweave_MCQ.Rnw&lt;/code&gt; after variable substitution.&lt;/li&gt;
&lt;li&gt;The second line creates a directory that corresponds to the value in the variable &lt;code&gt;output&lt;/code&gt;. 
The hyphen at the start of the line ensures that any errors, such as if the folder already exists, do not stop &lt;code&gt;make&lt;/code&gt; from running.
Note that commands such as &lt;code&gt;mkdir&lt;/code&gt;, &lt;code&gt;cp&lt;/code&gt;, &lt;code&gt;cd&lt;/code&gt;, and &lt;code&gt;rm&lt;/code&gt; are based on the &lt;code&gt;sh&lt;/code&gt; shell.
These commands are supported on Windows if you have &lt;code&gt;Rtools&lt;/code&gt; installed.&lt;/li&gt;
&lt;li&gt;The third line copies &lt;code&gt;Sweave.sty&lt;/code&gt; into the &lt;code&gt;output&lt;/code&gt; folder.&lt;/li&gt;
&lt;li&gt;The fourth line copies &lt;code&gt;tex&lt;/code&gt;, &lt;code&gt;pdf&lt;/code&gt; and &lt;code&gt;eps&lt;/code&gt; files (i.e., those generated by the Sweave command) into the &lt;code&gt;output&lt;/code&gt; folder.
This is done to ensure that the root directory only includes source files.
This has several benefits. 
(a) It makes version control easier; &lt;br /&gt;
(b) it makes it easy to see the source files and
(c) it reduces the risk of accidentally deleting source files when deleting derived files.&lt;/li&gt;
&lt;li&gt;the fifth line changes the home directory to the &lt;code&gt;output&lt;/code&gt; directory and then runs
&lt;code&gt;texify&lt;/code&gt; on the &lt;code&gt;tex&lt;/code&gt; file generated from Sweave. 
The flags ensure that a pdf is generated and that the default viewer is initiated.
This command could be modified to something like &lt;code&gt;pdflatex&lt;/code&gt; or some other &lt;code&gt;latex&lt;/code&gt; program.&lt;/li&gt;
&lt;li&gt;By changing the directory, all the derived latex files are kept in the output folder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;tex:&lt;/code&gt; goal can be called by running &lt;code&gt;make tex&lt;/code&gt; at the command line.
I use it in case I want there is an error in the when compiling the pdf from the tex file.
Sometimes its easier to work out where the bug is by manipulating the intervening tex file.
Of course once the problem has been identified, it needs to be incorporated into the Rnw source.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;clean:&lt;/code&gt; goal removes all files in the output directory (i.e., all the derived files)&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;backup:&lt;/code&gt; goal copies the resulting pdf into the &lt;code&gt;backup&lt;/code&gt; folder.
I figured this might be useful in order to include a copy of the final product in the repository.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3&gt;.gitignore&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;/.output
.project
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The .&lt;code&gt;gitignore&lt;/code&gt; file prevents all files in the &lt;code&gt;/.output&lt;/code&gt; directory (i.e., the derived files) and the file &lt;code&gt;.project&lt;/code&gt; from being placed under version control in git.&lt;/p&gt;

&lt;p&gt;I'm preparing a post on version control, git, and github which will be posted shortly.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3&gt;Sweave_MCQ.Rnw&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Sweave_MCQ.Rnw&lt;/code&gt; is the R noweb file that contains chunks of LaTeX and R code.
When Sweave is run on this file, the R code chunks are converted into &lt;code&gt;tex&lt;/code&gt; and, potentially, image files are generated.&lt;/p&gt;

&lt;h4&gt;LateX Preamble&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;\documentclass[12pt, a4paper]{exam}
\usepackage[OT1]{fontenc}
\usepackage{Sweave}
\SweaveOpts{echo=FALSE}
\usepackage{hyperref}            
\hypersetup{pdfpagelayout=SinglePage} % http://www.tug.org/applications/hyperref/ftp/doc/manual.html
\setkeys{Gin}{width=0.8\textwidth}
\pagestyle{headandfoot} % every page has a header and footer
\header{}{Sample Multiple Choice Questions}{}
\footer{}{Page \thepage\ of \numpages}{}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The latex preamble is mostly general code that ensures proper display of the reuslting document.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;exam&lt;/code&gt; document class is great for writing a variety of exam style documents in LaTeX.
See &lt;a href="http://www.ctan.org/tex-archive/macros/latex/contrib/exam/"&gt;CTAN - exam&lt;/a&gt;
for documentation.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;hyperref&lt;/code&gt; is used to display hyperlinks and allows the resulting pdf to open in &lt;code&gt;SinglePage&lt;/code&gt; format.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;\setkeys...&lt;/code&gt; controls the width of Sweave figures relative to the paragraph width. There are no figures in this documents; so it is not really required.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;\pagestyle{headerandfoot}...&lt;/code&gt; These three lines ensure the display of header and footer information on each page.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;First R Code Chunk&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;&amp;lt;prepare_data&amp;gt;&amp;gt;=
items &amp;lt;- read.csv("data/items.csv", stringsAsFactors = FALSE)

writeQuestion &amp;lt;- function(x){
    c("\\filbreak",
            paste("\\question\n", x["itemText"]),
            "\\begin{choices}",
            paste("\\choice", x["optionA"]),
            paste("\\choice", x["optionB"]),
            paste("\\choice", x["optionC"]), 
            paste("\\choice", x["optionD"]), 
            "\\vspace{10 mm}",
            "\\end{choices}\n\n")
}

itemText &amp;lt;- apply(items, 1, function(X)  writeQuestion(x = X))

answers &amp;lt;- paste(items$item, "=",
        LETTERS[as.numeric(items$correctAnswer)],
        sep ="")
answersText &amp;lt;- paste(answers, collapse = "; ")
@
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;R code chunks in Sweave are commenced by &lt;code&gt;&amp;lt;&amp;lt;&amp;gt;&amp;gt;=&lt;/code&gt; and ended by &lt;code&gt;@&lt;/code&gt;. 
These need to appear in the first column of the text file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;&amp;lt;prepare_data&amp;gt;&amp;gt;=&lt;/code&gt;: The first non-keyword placed in the opening tags provides a name for the R code chunk. 
A short descriptive title is useful both when reading the source and when debugging Sweave compilation.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;items...&lt;/code&gt;: this line reads in a csv file into a data frame with 40 cases. 
Each case is a multiple choice question with fields such as the question text, the text for the four response options, and the correct answer.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;writeQuestion...&lt;/code&gt;: This is a function which is designed to take a row of data from the &lt;code&gt;items&lt;/code&gt; data frame and return a latex formated character vector, where each element is ultimately be printed on its own line of the tex file.
Note how in order to produce one backslash in LaTeX, two backslashes, need to be written.
The &lt;code&gt;\question&lt;/code&gt;, &lt;code&gt;\choices&lt;/code&gt;, and &lt;code&gt;\choice&lt;/code&gt; commands are part of the &lt;code&gt;exam&lt;/code&gt; document class and are used for formatting multiple choice questions.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;apply...&lt;/code&gt; takes the &lt;code&gt;items&lt;/code&gt; data frame and for each row (1=rows) runs the function &lt;code&gt;writeQuestion&lt;/code&gt; on the row.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;answers...&lt;/code&gt; and &lt;code&gt;answersText&lt;/code&gt; create a formatted string that shows item numbers and letters for correct answers, all drawn from the &lt;code&gt;items&lt;/code&gt; data frame.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Remaining code&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;\begin{questions}
&amp;lt;&amp;lt;print_items, results=tex&amp;gt;&amp;gt;=
cat(itemText, sep = "\n")
@
\newpage
\section*{Answers}
&amp;lt;&amp;lt;print_answers, results=tex&amp;gt;&amp;gt;=
cat(answersText) 
@

\end{questions}
&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;The second R code chunk has a descriptive name &lt;code&gt;print_items&lt;/code&gt;.
It uses the key-value pair &lt;code&gt;results=tex&lt;/code&gt;. 
This ensures that Sweave interprets the text outputed using &lt;code&gt;cat&lt;/code&gt; as raw &lt;code&gt;tex&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;cat...&lt;/code&gt; prints the long character vector &lt;code&gt;itemText&lt;/code&gt; containing all the latex for the questions. 
&lt;code&gt;sep="\n"&lt;/code&gt; means that each element is printed on a new line 
which makes the resulting &lt;code&gt;tex&lt;/code&gt; file easier to read. &lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;hr /&gt;

&lt;h3&gt;Summary and Related Resources&lt;/h3&gt;

&lt;p&gt;The combination of &lt;code&gt;make&lt;/code&gt;, &lt;code&gt;R&lt;/code&gt;, &lt;code&gt;Sweave&lt;/code&gt;, and &lt;code&gt;LaTeX&lt;/code&gt; is tremendously powerful.
Hopefully, this post encourages a few more people to have a play.
To learn more check out some of the following posts and pages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;Getting Started with Sweave&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="
http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html"&gt;makefiles for Sweave, R and LaTeX using Eclipse on Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://stats.stackexchange.com/questions/1980/complete-substantive-examples-of-reproducible-research-using-r"&gt;Question on Stats.SE 'Complete substantive examples of reproducible research using R'&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt; After posting this article on my blog, 
&lt;a href="http://www.aliquote.org/"&gt;Christophe Lalanne&lt;/a&gt; 
let me know about a paper by Bettina Grün and Achim Zeileis called 
&lt;a href="http://www.jstatsoft.org/v29/i10/"&gt;'Automatic Generation of Exams in R'&lt;/a&gt; in JSS. 
It also uses Sweave, LaTeX, and the exams document class.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-1120662403227628927?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ShisEaM2RqU:1imxAI7HZMc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ShisEaM2RqU:1imxAI7HZMc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ShisEaM2RqU:1imxAI7HZMc:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ShisEaM2RqU:1imxAI7HZMc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ShisEaM2RqU:1imxAI7HZMc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ShisEaM2RqU:1imxAI7HZMc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ShisEaM2RqU:1imxAI7HZMc:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ShisEaM2RqU:1imxAI7HZMc:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ShisEaM2RqU:1imxAI7HZMc:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/ShisEaM2RqU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/1120662403227628927/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html#comment-form" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/1120662403227628927?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/1120662403227628927?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/ShisEaM2RqU/sweave-tutorial-using-sweave-r-and-make.html" title="Sweave Tutorial 1: Using Sweave, R, and Make to Generate a PDF of Multiple Choice Questions" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>8</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/11/sweave-tutorial-using-sweave-r-and-make.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMBRnw7fyp7ImA9Wx9TFkU.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-3400252866070924695</id><published>2010-11-23T16:09:00.003+11:00</published><updated>2010-11-25T21:20:57.207+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-25T21:20:57.207+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="LaTeX" /><category scheme="http://www.blogger.com/atom/ns#" term="Sweave" /><category scheme="http://www.blogger.com/atom/ns#" term="R" /><title>makefiles for Sweave, R and LaTeX using Eclipse on Windows</title><content type="html">This post provides a brief introduction to &lt;code&gt;make&lt;/code&gt; and &lt;code&gt;makefiles&lt;/code&gt;.
In particular it describes how to set up &lt;code&gt;make&lt;/code&gt; on Windows with an emphasis on using &lt;code&gt;make&lt;/code&gt; in Eclipse on projects involving R, Sweave, and LaTeX.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;make&lt;/code&gt; is software that uses &lt;code&gt;makefiles&lt;/code&gt; to build projects.
&lt;code&gt;make&lt;/code&gt; has many benefits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One click build&lt;/li&gt;
&lt;li&gt;Reliable build (always build derived files that need to be built; i.e., ensure build is up to date)&lt;/li&gt;
&lt;li&gt;Fast build (i.e., don't build things that don't need to be built)&lt;/li&gt;
&lt;li&gt;Clean up a project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;make&lt;/code&gt; has won the &lt;a href="http://en.wikipedia.org/wiki/ACM_Software_System_Award"&gt;ACM Software System Award&lt;/a&gt;.
It shares this honour with two of my other favourite tools: &lt;code&gt;TeX&lt;/code&gt; and &lt;code&gt;S&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;make&lt;/code&gt; has also encouraged me to think more about dependencies, one-click builds, and project file structures.
Specifically, I use &lt;code&gt;make&lt;/code&gt; in conjunction with R, Sweave, LaTeX, and other command line tools to build reproducible research output.
I'll post some examples in the near future. &lt;/p&gt;

&lt;h3&gt;Installation on Windows&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Option 1: Install &lt;a href="http://www.cygwin.com/"&gt;Cygwin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Option 2: Install &lt;a href="http://www.murdoch-sutherland.com/Rtools/"&gt;Rtools&lt;/a&gt;
and add Rtools to the Windows path (installation can do this for you);&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to run Sweave on the command line on Windows using: &lt;code&gt;R CMD Sweave foo.Rnw&lt;/code&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add R binaries to the Windows Path (e.g., &lt;code&gt;C:\Program Files\R\R-2.11.1\bin&lt;/code&gt;;
&lt;a href="http://www.computerhope.com/issues/ch000549.htm"&gt;see here for instructions&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Have Rtools installed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="http://cran.r-project.org/doc/manuals/R-intro.html#Scripting-with-R"&gt;Introduction to R&lt;/a&gt; has more information about running R at the command line.  &lt;/p&gt;

&lt;h3&gt;Running makefiles in Eclipse&lt;/h3&gt;

&lt;p&gt;I use Eclipse to edit R and Sweave files.
To configure &lt;code&gt;make&lt;/code&gt; in Eclipse: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Run - External Tools - External Tools Configurations&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;New
&lt;ul&gt;&lt;li&gt;&lt;em&gt;Name:&lt;/em&gt; make&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Location:&lt;/em&gt; location of make file; e.g., &lt;code&gt;C:\Program Files\GnuWin32\bin\make.exe&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Working Directory:&lt;/em&gt; &lt;code&gt;${Project_loc}&lt;/code&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thus, with a &lt;code&gt;makefile&lt;/code&gt; in the root directory of a project, &lt;code&gt;Run - External Tools - Make&lt;/code&gt; runs the &lt;code&gt;makefile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also note:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whenever a directory is added to the Windows Path, Eclipse needs to be restarted for this to take effect.
Sometimes it seems that Windows itself has to be restarted.&lt;/li&gt;
&lt;li&gt;Editing makefiles in Eclipse requires the use of tabs. The following setting enables tabs instead of space substitution (&lt;code&gt;Window - Preferences - General - Editors - Text Editors - Insert Space for Tables (uncheck)&lt;/code&gt;); or edit the &lt;code&gt;makefile&lt;/code&gt; in another text editor such as &lt;code&gt;notepad&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;For LaTeX I have MikTeX installed; this should be on the Windows path&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Resources for Getting Started with makefiles for Sweave&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Ross Ihaka has a quick introduction to &lt;a href="http://www.stat.auckland.ac.nz/~stat782/downloads/make-tutorial.pdf"&gt;makefiles focusing on Sweave, R, and LaTeX&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Charlie Gibbons wrote a document with &lt;a href="http://cgibbons.berkeley.edu/Research/Papers/MakefileTutorial.pdf"&gt;LaTeX, Sweave, and Beamer examples of makefiles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Gregor Gorjanc shows an &lt;a href="http://ggorjan.blogspot.com/2009/01/using-makefile-to-ease-repeated.html"&gt;example Sweave make file&lt;/a&gt; using his custom Sweave command&lt;/li&gt;
&lt;li&gt;Documentation on &lt;a href="http://www.gnu.org/software/make/manual/make.html"&gt;GNU Make&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/03/running-command-line-programs-in.html"&gt;Running command line programs in Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jeromyanglim.blogspot.com/2010/02/getting-started-with-sweave-r-latex.html"&gt;Getting Started with Sweave: R, LaTeX, Eclipse, StatET, &amp;amp; TeXlipse&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-3400252866070924695?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ONlmVky2EkU:qCKOEeNOXL4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ONlmVky2EkU:qCKOEeNOXL4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ONlmVky2EkU:qCKOEeNOXL4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ONlmVky2EkU:qCKOEeNOXL4:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ONlmVky2EkU:qCKOEeNOXL4:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ONlmVky2EkU:qCKOEeNOXL4:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ONlmVky2EkU:qCKOEeNOXL4:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=ONlmVky2EkU:qCKOEeNOXL4:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=ONlmVky2EkU:qCKOEeNOXL4:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/ONlmVky2EkU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/3400252866070924695/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/3400252866070924695?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/3400252866070924695?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/ONlmVky2EkU/makefiles-for-sweave-r-and-latex-using.html" title="makefiles for Sweave, R and LaTeX using Eclipse on Windows" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/11/makefiles-for-sweave-r-and-latex-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QMQXg8cSp7ImA9Wx5aFUg.&quot;"><id>tag:blogger.com,1999:blog-8909074830238091680.post-7071227844645240144</id><published>2010-11-12T20:49:00.000+11:00</published><updated>2010-11-12T20:49:40.679+11:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-12T20:49:40.679+11:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="markup" /><category scheme="http://www.blogger.com/atom/ns#" term="blogging" /><title>Getting Started with Markdown: Benefits, Installation, Learning, and Conversion</title><content type="html">I've recently adopted Markdown as a markup language for editing my blog posts.
This post discusses 
(a) the benefits of Markdown,
(b) installing a Markdown editor,
(c) learning Markdown, and
(d) converting between formats.

&lt;a name='more'&gt;&lt;/a&gt;

&lt;h3&gt;Overview&lt;/h3&gt;

&lt;p&gt;Great features of Markdown are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's plain text (e.g., support for version control, create with code) &lt;br /&gt;&lt;/li&gt;
&lt;li&gt;It's simple to learn and use&lt;/li&gt;
&lt;li&gt;The source is highly readable (much more so than HTML or LaTeX; and arguably more so than other markup languages)&lt;/li&gt;
&lt;li&gt;It's quicker to type than HTML&lt;/li&gt;
&lt;li&gt;It's easy to convert to other formats&lt;/li&gt;
&lt;li&gt;Several websites such as Stack Exchange and Github use it&lt;/li&gt;
&lt;li&gt;HTML code can be interspersed when features such as tables are not supported&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's not for everything, but it's a good tool for certain tasks.
I'm still exploring the options, but in the case of blog posts and readme files it works well.&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;I chose to install the Markdown Editor plugin for Eclipse developed by Daniel Winterstein. 
Cool features include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Outline View&lt;/li&gt;
&lt;li&gt;Syntax highlighting&lt;/li&gt;
&lt;li&gt;Markdown HTML Preview&lt;/li&gt;
&lt;li&gt;Integration with Eclipse&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installation instructions can be found on the &lt;a href="http://www.winterwell.com/software/markdown-editor.php"&gt;winterwell&lt;/a&gt; website.&lt;/p&gt;

&lt;h3&gt;Learning the Syntax&lt;/h3&gt;

&lt;p&gt;The markup is simple to learn.
I first installed the Markdown Editor in Eclipse &lt;br /&gt;
 and associated &lt;code&gt;.md&lt;/code&gt; files with the Markdown editor.&lt;/p&gt;

&lt;p&gt;I then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;created a file called &lt;code&gt;test.md&lt;/code&gt; and opened it in the Markdown editor in Eclipse&lt;/li&gt;
&lt;li&gt;opened the Markdown HTML Preview: 
&lt;code&gt;Window -- Show View -- Other -- Markdown -- Markdown HTML Preview&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;worked through the &lt;a href="http://daringfireball.net/projects/markdown/syntax"&gt;Markdown syntax guide&lt;/a&gt;
creating simple proof of concept examples, bouncing between
the Markdown Editor and the Markdown HTML Preview.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;Conversion&lt;/h3&gt;

&lt;h4&gt;Markdown to HTML&lt;/h4&gt;

&lt;p&gt;Using the Eclipse Markdown plugin, a HTML version of the Markdown file
 can be obtained in several ways.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right click the Markdown HTML Preview and click "View Source"&lt;/li&gt;
&lt;li&gt;When in the Markdown editor, go to File -- Export HTML. 
This creates a HTML version of the file&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Other options&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://johnmacfarlane.net/pandoc/"&gt;Pandoc&lt;/a&gt; appears to be a good option for converting between document 
 formats such as Markdown, LaTeX, RTF, PDF, OpenDocument, and more. &lt;/p&gt;

&lt;h3&gt;Copy of this Post in Markdown&lt;/h3&gt;

&lt;p&gt;The code below shows the Markdown used to create this post (except of course for the Markdown shown below).    &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;I've recently adopted Markdown as a markup language for editing my blog posts.
This post discusses 
(a) the benefits of Markdown,
(b) installing a Markdown editor,
(c) learning Markdown, and
(d) converting between formats.

&amp;lt;!-- more --&amp;gt;
### Overview

Great features of Markdown are:

* It's plain text (e.g., support for version control, create with code)  
* It's simple to learn and use
* The source is highly readable (much more so than HTML or LaTeX; and arguably more so than other markup languages)
* It's quicker to type than HTML 
* It's easy to convert to other formats
* Several websites such as Stack Exchange and Github use it
* HTML code can be interspersed when features such as tables are not supported 

It's not for everything, but it's a good tool for certain tasks.
I'm still exploring the options, but in the case of blog posts and readme files it works well.


### Installation
I chose to install the Markdown Editor plugin for Eclipse developed by Daniel Winterstein. 
Cool features include:

* Outline View
* Syntax highlighting
* Markdown HTML Preview
* Integration with Eclipse

Installation instructions can be found on the [winterwell] website.

[winterwell]: http://www.winterwell.com/software/markdown-editor.php 


### Learning the Syntax
The markup is simple to learn.
I first installed the Markdown Editor in Eclipse  
 and associated `.md` files with the Markdown editor.

I then:

1. created a file called `test.md` and opened it in the Markdown editor in Eclipse
2. opened the Markdown HTML Preview: 
`Window -- Show View -- Other -- Markdown -- Markdown HTML Preview`
3. worked through the [Markdown syntax guide][msg]
  creating simple proof of concept examples, bouncing between
  the Markdown Editor and the Markdown HTML Preview.

[msg]: http://daringfireball.net/projects/markdown/syntax


### Conversion
#### Markdown to HTML
Using the Eclipse Markdown plugin, a HTML version of the Markdown file
 can be obtained in several ways.

* Right click the Markdown HTML Preview and click "View Source"
* When in the Markdown editor, go to File -- Export HTML. 
  This creates a HTML version of the file

#### Other options
[Pandoc] appears to be a good option for converting between document 
 formats such as Markdown, LaTeX, RTF, PDF, OpenDocument, and more. 

[pandoc]: http://johnmacfarlane.net/pandoc/
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8909074830238091680-7071227844645240144?l=jeromyanglim.blogspot.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Z4epKsguaAY:-MOmuNsqKRk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Z4epKsguaAY:-MOmuNsqKRk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=Z4epKsguaAY:-MOmuNsqKRk:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Z4epKsguaAY:-MOmuNsqKRk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Z4epKsguaAY:-MOmuNsqKRk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=Z4epKsguaAY:-MOmuNsqKRk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Z4epKsguaAY:-MOmuNsqKRk:4cEx4HpKnUU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?i=Z4epKsguaAY:-MOmuNsqKRk:4cEx4HpKnUU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/jeromyanglim?a=Z4epKsguaAY:-MOmuNsqKRk:I9og5sOYxJI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/jeromyanglim?d=I9og5sOYxJI" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/jeromyanglim/~4/Z4epKsguaAY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://jeromyanglim.blogspot.com/feeds/7071227844645240144/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://jeromyanglim.blogspot.com/2010/11/getting-started-with-markdown-benefits.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/7071227844645240144?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8909074830238091680/posts/default/7071227844645240144?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/jeromyanglim/~3/Z4epKsguaAY/getting-started-with-markdown-benefits.html" title="Getting Started with Markdown: Benefits, Installation, Learning, and Conversion" /><author><name>Jeromy Anglim</name><uri>https://profiles.google.com/100803004599943057656</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh3.googleusercontent.com/-xUmT1aa-RI0/AAAAAAAAAAI/AAAAAAAAASo/qyd_27EjI3Y/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://jeromyanglim.blogspot.com/2010/11/getting-started-with-markdown-benefits.html</feedburner:origLink></entry></feed>

