tex extension probably already gave you a clue that I am reducing redundancy in a file. Where would this come in handy? Well, the. Output = File.open(filename+'2.tex', 'w') tex files in mind, but easily adaptable: puts 'Filename?'
If a line is not in the dictionary, it must be new, so write it to the output file. You just iterate over the file, putting all lines the computer has already “seen” into a dictionary. For safety’s sake, you would rather make an abbreviated copy of the file rather than replace it.
Say you have a file with many repeated, unnecessary lines that you want to remove. Thank to Trey Causey on Twitter and Zachary Jones in the comments for sharing this. Update: If you’re interested in your own automated project setup, check out ProjectTemplate by John Myles White. As a final note, this is the second New Year’s Eve in a row that I have posted a tech tip. H/T to Josh Cutler for encouraging me to write a post about my project structure and automation efforts. If you decide to make major customizations to this file or already have your own structure for projects like this, leave a link in the comments for other readers. You can add (or remove) text in the R files by changing the echo lines. You can add more (or fewer) directories by modifying the mkdir lines in the Makefile. If you want to change this structure, there are two main ways to do it. Because of the way the setup.R file works, you could have multiple users working on the same project and not need to change any of the other scripts. For example, after running setup.R in your analysis file you can switch to the data directory with setwd(pathData), then create a plot and save it after running setwd(pathGraphics). This takes the current user and sets relative paths to the project directories with simple variable references in R.
LATEX AQUAMACS TUTORIAL CODE
It also supplies some starter code for the setup.R file in the main directory and a start.R file in the rcode directory. a graphics library for storing plots and figures to include in your article.a drafts directory for LaTeX, including a generic starter article.a data directory for storing files (csv, rda, etc).a setup.R file for clearing the workspace, setting paths, and loading libraries.Running the Makefile with the example article in an otherwise-empty project directory will create:
LATEX AQUAMACS TUTORIAL HOW TO
This post explains the structure of that project and explains how to modify it for your own purposes. That’s why I set up an example project on Github using a Makefile and sample article (inspired by Rob Hyndman).
Automating repetitive steps is one of the great benefits of knowing a bit about coding, even if the code is just a simple shell script. You have a finite amount of keystrokes in your life.