To ward off disease or recover health, men as rule find it easier to depend on the healers then to attempt the more difficult task of living wisely.

Rene Dubos, 1959

“To ward off disease or recover health, men as rule find it easier to depend on the healers then to attempt the more difficult task of living wisely.”

Rene Dubos, 1959

Fixing a y-axis that is too short in barplot function in R

Over the holidays I invested some time in learning R and RStudio, something I have wanted to do for some time now. The opportunity presented itself when needing to help a family member run chi-square tests, something more involved in Excel than I would have guessed (Excel requires you to manually calculate the expected values table). The experience learning R has been fun but there are occasional head-scratching frustrations. As I go through the learning process I’ll be posting here mainly as a reference for me so I can remember how I solved various problems, but hopefully it will provide help to others who have hit stumbling blocks.

One issues I had a problem with was with the barplot function. Take for example this code that contains 100 observations (we’ll say it’s the number of times a person visits a particular store in a month), produces a table from these data, and then creates a barplot from the table.

visits <- c(2, 2, 3, 7, 10, 3, 1, 0, 8, 7, 11, 14, 1, 3, 0, 8, 9, 4, 3, 3, 20, 9, 2, 5, 12, 3, 6, 1, 1, 2, 4, 2, 2, 3, 9, 13, 7 ,11, 15, 15, 19, 7, 8, 7, 6, 0, 6, 0, 1, 4, 2, 9, 0, 6, 12, 7, 6, 14, 5, 0, 4, 0, 0, 8, 0, 4, 4, 1, 3, 5, 6, 15, 1, 6, 13, 2, 1, 3, 5, 3, 19, 12, 3, 0, 7, 0, 2, 4, 2, 2, 2, 5, 1, 4, 3, 0, 6, 11, 0, 3)

visits.table <- table (visits)
barplot(visits.table)

This is the resulting chart.

Chart with bad x-axis

At first I thought I had a nice looking bar chart, only to notice that, while the data had a maximum frequency of 13, the y-axis cut short at 12. Also when the x-axis legend numbers become double digits they become too wide, leading R to begin skipping every other one. (A low tech way to fix this is widen the plot window.)

Continue reading “Fixing a y-axis that is too short in barplot function in R”

Run Python 3 in TextMate (Mac)

I was having an issue with TextMate 2.0 in that it runs Python 2, even after installing IDLE with Python 3. For example:

a=5
print("Total:", a)

Resulted in: (‘Total:’, 5)

Instead of: Total: 5

From what I read, it is best to have TextMate use Python 3 on a per project basis; changing defaults can break other parts since it uses Python 3. 

The solution here from “philbernt” was the most straight-forward solution.

First, launch terminal and type:

which python3

On my machine the following was returned:

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

In your TextMate document, after selecting Python as the document type, copy and past the result from Terminal, proceeded by “#!”. In my example this would be:

#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

Use Command R to run and it should now run with the latest version of Python.

The invisible profession

I recall my professor for Public Health Practice, Dr. Cheryll Lesneski, telling the class that public health is often called the “invisible profession” because its affects are rarely noticed by the public. Only when it fails, like in the current lead water crisis in Flint, MI, do people notice public health. 

In Cheryl’s class I had forgotten about this wonderful quote from Bernard Turnock that I came across again today. Emphasis mine.

[Public health] prevention efforts often lack a clear constituency because success results in unseen consequences. Because these consequences are unseen, people are less likely to develop an attachment for or to support the efforts preventing them. 

Advocates for mental health services, care for individuals with development disabilities, organ transplants, and end-stage renal disease often make their presence felt. But few state capitols have seen candlelight demonstrations by thousands of people who did not get diphtheria.

From: “Public Health: What It Is and How It Works”, Third Edition by Bernard J. Turnock, MD, MPH

The invisible profession

I recall my professor for Public Health Practice, Dr. Cheryll Lesneski, telling the class that public health is often called the “invisible profession” because its effects are rarely noticed by the public. Only when it fails, like in the current lead water crisis in Flint, MI, do people notice public health.

In Cheryl’s class I had forgotten about this wonderful quote from Bernard Turnock that I came across again today. Emphasis mine.

[Public health] prevention efforts often lack a clear constituency because success results in unseen consequences. Because these consequences are unseen, people are less likely to develop an attachment for or to support the efforts preventing them.

Advocates for mental health services, care for individuals with development disabilities, organ transplants, and end-stage renal disease often make their presence felt. But few state capitols have seen candlelight demonstrations by thousands of people who did not get diphtheria.

From: “Public Health: What It Is and How It Works”, Third Edition by Bernard J. Turnock, MD, MPH

The Passing of Dr. Sharon Elliott-Bynum, CAARE Inc. Executive Director

The Passing of Dr. Sharon Elliott-Bynum, CAARE Inc. Executive Director