Category Archives: Tips & Best Practices

Save ggplot Graphics at Intended End-use Dimensions and Resolutions for Best Results

Users of ggplot2 often run into issues with their saved graphics not having the expected resolution or font sizes.

By default, when using RStudio, ggsave() saves graphics at the last dimensions of the plot preview pane and at screen resolution. As a demo, try

library(ggplot2)

ggplot(mtcars, aes(hp, mpg)) + geom_point()

ggsave("graphic.png")

Then resize the plot preview pane and ggsave() again. And again. You’ll get three very different graphics as a result. Your font sizes are likely to be different from what you expect, if you drag those saved graphics into an MS Word or PowerPoint document, since the graphic will have to resize to fit the container (page, slide, or content area).

The solution is to be explicit about what your intended end-use is. I wrote a utility function to save a given graphic with proper dimensions and resolution for a number of use cases: for use in MS Word (U.S. Letter) documents at half- and full-page sizes, both portrait and landscape; and in both standard and widescreen slide formats. The code uses a default sent of dimensions and resolutions, but you can provide your own data.frame, if needed. U.S. users will recognize 8.5-2 as letter-width less 2 inches for standard 1 inch margins and 11-2 as letter-height less the same 2 inches for margins. Half page height is then (11-2)/2.

Now, your “10pt” axis labels will actually be 10pt when you place your graphics. Always use your graphics at 100% scale, otherwise all bets are off.

Quick Notes About Citations and References in APA Style

I often see a similar set of issues related to proper citation… some of them are quite understandable, while others perplex me in their consistency. When I cite myself, below, it’s not ego; it’s to demonstrate how I would typically expect to see a citation or reference appear. And the references are fictional.

In-text Citations

  • Every in-text idea that isn’t yours must be cited. Failure to do so is theft of intellectual property, typically known as plagiarism.
  • Every in-text idea that’s taken directly from source material must be “wrapped in quotation marks and cited” (Doane, 2023).
  • If a quotation comes from a paged document (PDF, book, etc.), then “the quoted in-text citation should include a page number” (Doane, 2023 p.45).
  • In APA style, the punctuation for the sentence being cited goes AFTER the citation (Doane, 2023).
    • not punctuated like this. (Doane, 2023).
  • The label used in the in-text citation (Doane, 2023) must match the beginning of the alphabetized entry in the References section.
    • Doane, W. E. J. (2023). How to Cite to Ensure a Chain of Evidence to Support Your Claims. Penguin Press. (nb: this is fictional) 
  • Every in-text citation must lead directly to an entry in your References section.

Your References Section

  • Every entry in your References section must match an in-text citation.
  • The References section must be arranged in alphabetical order by first author’s last name (or source, if no author).
  • Multiple references from the same author in the same year may need an added letter designation: (Doane, 2023a) for example, with the letter also added to the reference entries to help your reader disambiguate.
    • Doane, W. E. J. (2023a). How to Cite to Ensure a Chain of Evidence to Support Your Claims. Penguin Press. (nb: this is fictional) 
    • Doane, W. E. J. (2023b). More Tips on How to Cite. Saratoga Press. (nb: this is fictional) 
  • Institutional authors should be spelled out (unless it’s a very common abbreviation: IBM, NASA, etc.).
  • Never list institutional authors as if they were first and last names:
    • BAD: “Machines, I.B.”
    • GOOD: “IBM” or “International Business Machines”
  • Check how to cite an organization as the author in your citation manager of choice.

Your Sources

Purpose and Reasoning

  • The purpose of citing is to draw a map for your reader from the material in the body of your document, to a reference, to the original source.
    • If you claim that the U.S. National Debt is only $31 dollars, then I need to know where you got that information, so that I can fact check you and point out that you left off “trillion”. (See https://www.usdebtclock.org/)
  • Your job as a writer is to make it as easy as possible for your reader to believe and be persuaded by your writing.
  • As such, accurate attribution and guiding your reader to the source material you rely upon for your claims is vital to the writing process.

As an analogy to Web technology, the concept of citations are the pre-electronic version of web links: the text in the body of your document links to a reference which in turn links to a source document. Each step in that chain of evidence needs to be immediately apparent and easy to follow.

Apple’s iOS/iPadOS/WatchOS Medical ID

PSA: You should absolutely setup or update your iOS Medical ID information and select your emergency contacts right this very minute.

This feature, found in the Health app on your iPhone or iPad, makes your medical information—medications, allergies, organ donor status— available to first responders and allows calls to your emergency contacts even when your device is locked.

This could save your life. For instructions on how to setup this feature, see support.apple.com/en-us/HT207021

Spreadsheets are Just OK for Data, Bad for Data Analyses

There are plentiful examples of spreadsheet applications leading analysts astray. Believe all the scary stories. Spreadsheets can silently damage your data, converting numbers to dates or dropping leading zeros from what should be fixed-length identifier (where did the U.S. Zip Code 01002 go?).

The U.K. Lost 16,000 COVID Cases Because It Doesn’t Understand Microsoft Excel

The Reinhart-Rogoff error or how not to Excel at economics

For a set of best practices when working with data in spreadsheets, take to heart the advice offered by Data Organization in Spreadsheets. Please!

Learn to Love Writing

You will be asked to write. Think about your writing process carefully and be open to new ideas about how to approach it.

Writing is, at a minimum, a two-step process: you write, you edit. Writing and editing are distinct steps. Don’t try to edit your writing as you write your first draft; you’ll trip over your own creativity. Get your ideas down, then edit. Then get more ideas down and edit them.

Ideally, you would repeat the writing-editing process several dozen times to further refine your prose. After you’ve written and edited your work, you’ll need to share your draft with others, who will edit it and rewrite portions of it. Set your ego aside. Focus on improving the writing and, through that experience, your default writing style.

This takes time.

Continue reading Learn to Love Writing

My RStudio Configuration

I help a few of dozen users install RStudio and learn R regularly. Whenever I need to install RStudio on a new machine, I have to think a bit about the configuration options I’ve tweaked. Invariably, I miss a checkbox that leaves me with slightly different RStudio behavior on each system. This post includes screenshots of my currently preferred standard RStudio configuration and custom keyboard shortcuts for RStudio 1.3, MacOS.

If you need an exact copy of your settings, consider the discussion at https://stackoverflow.com/questions/55903423/export-import-rstudio-user-preferences-global-setting-etc/55940249 (h/t: liebrr)

Continue reading My RStudio Configuration

Stay Secure

Security is a tricky affair: it’s difficult to establish, to maintain, and to verify. Take all the steps you can to keep your data and devices secure.

  • Backup, keeping a copy in your home and somewhere outside your home that you consider safe and are likely to be able to access in an emergency.
  • Secure, so that only you and those you trust can get access to your information and accounts.
  • Plan for routine recovery, such as when you’re away from your computer, but need to gain access to your information and accounts.
  • Plan for extreme recovery, such as when you are disabled and unable to communicate, or when you pass away.

Continue reading Stay Secure

Thinking about data-driven visualizations

When you’re creating a visualization based on data, it often seems as if the possibilities are endless. Realistically, however, your best option is to think carefully about each of the variables with which you’re working—typically represented as the columns in a spreadsheet—and the limited number of aesthetic dimensions of your visualization—for each data point: the x position, the y position, possibly the z position, color, transparency, shape, and size.

Your goal is to map each aesthetic to one variable. If you’re using an aesthetic dimension in your graphic that isn’t tied to your variables, then why do you have that dimension? After all, it’s not communicating any information.

Leland Wilkinson’s seminal book, A Grammar of Graphics.

Hadley Wickham’s classic: A Layered Grammar of Graphics.

and a discussion that applies Hadley’s ideas.

What Software Developers Get Wrong About Enterprise Users

For the past few years, I’ve been working in an enterprise computing environment that has both striking similarities and dissimilarities from the open source freelance and the academic institutional environments. I’ve been frustrated a number of times by products that either haven’t thought about their enterprise users or, perhaps, don’t care.

So, how is the enterprise different? Continue reading What Software Developers Get Wrong About Enterprise Users

What Students Say

A note to myself

I believe that I can be a better educator through reflection and active engagement. I believe that I can better serve my students and colleagues by being honest with them. I believe that reflection, engagement, and honesty can help other educators improve their praxis, should they feel so inclined.

It has always been about the students

A note to students

Continue reading What Students Say

Adding a keyboard shortcut for Save to PDF… in OSX

When I’m commenting on electronic documents, I find it useful to be able to quickly generate a PDF of the marked-up version of the document to return to authors for review. I annotate the document using track changes and adding comments (using the INSERT > COMMENT feature… not by adding text to the body of the document!!!), then

Save as PDF…

to keep a copy for myself and to email (or post to a course management system) for the author to review.

Unfortunately, OSX doesn’t have a built-in keyboard shortcut for Save to PDF…, but it’s easy to add one.

[Note: you can’t Save to PDF… from an Adobe Acrobat print dialog box… it would bruise their ego]

httpvh://youtu.be/HDhiGZKbicQ

Digital Voice Recorders

Digital voice recorders can be a handy tool for dictation or recording research interviews. Here are some of the things I consider when looking for a recorder.

Connectivity Make sure the recorder you choose has a USB port or (even better) a built-in plug. Some recorders do not allow you to transfer your recordings to your computer.
File format The default recording file format should be something that is easily playable on your computer’s already installed software, such as Quicktime, iTunes, or Windows Media Player. WAV and MP3 work well, but many recorders use WMA, a windows format that requires additional software on the Mac to playback.
Microphones You generally want dual (or quad) built-in MICs for stereo recording— invaluable in interview sessions. You can play your recordings with headphones and perceive directionality. Not all recorders record in stereo. Also, an external MIC jack, in case you ever want to use an external microphone (a lapel clipped mic or shotgun mic, e.g.)
Placement A tripod mount screw is handy for setting up your recorder for standalone operation.

Two models I’m fond of:

Zoom H2 http://www.amazon.com/Zoom-H2-Portable-Stereo-Recorder/dp/B000VBH2IG
Olympus WS-600s http://www.amazon.com/Olympus-WS-600S-Digital-Recorder-142610/dp/B000NM8DI6

Know Your Libraries and Librarians

One of the first lessons any successful graduate student (and that should read “undergraduate student”) learns is to introduce themselves to the reference librarian who is responsible for their favorite subject areas. They can serve as guides to the existing collection, alert you to new acquisitions, and help you to acquire books that you may be interested in reading.

Know the LOC system, know which sections interest you, and know who is responsible for maintaining those sections at your institutions. You’ll make a librarian’s day when you introduce yourself as being “particularly interested in the QAs” or any other category.

For me, I always visit these sections, at least:

  • K7555 – Copyright
  • LB – Theory and practice of education
  • Q – Cybernetics/Information Theory
  • QA – Computers/Programming Languages
  • TK – Electronics/Computer Engineering

History of the LOC system: http://www.loc.gov/catdir/cpso/lcc.html

The categories: http://www.loc.gov/catdir/cpso/lcco/