What is your science good for?

What is your science good for? What can your project do — and what can’t it do? We often start with lofty goals like inspiring and motivating people to help the environment. But in reality, the work we do is smaller and more down to earth. It’s often very interesting, but it’s not about to inspire broad, sweeping change.

So what is our science good for, if it doesn’t inspire action? We can help figure out which actions would do the most good. We can help make the most efficient use of our resources and efforts. Plus, people are much more willing to take action if you can tell them which specific actions will be effective and worthwhile.

One of my interns is exploring what her project could be useful for, and she started out with some broad ideas that conveyed the spirit of why this project matters to her. They didn’t quite match what her science could actually do, so we worked together to refine and focus them into a compelling case for why her specific project is meaningful and valuable.

Continue reading

Leave a comment

Filed under Uncategorized

Keeping Quarto and RMarkdown webpages out of search engines

I have a quarto-based website (coded in R) that I don’t want popping up in search engines. I can’t password-protect it, so I’ve added a “noindex” tag to each page to ask search engines not to crawl it. Not all search engines respect that, but Google and other main ones say they do.

My website has some pages rendered from .qmd files, and others from .Rmd files. Adding the “noindex” tag works differently for each:

For .qmd pages, you can include the “noindex” tag directly in the YAML header:

---
format:
html:
include-in-header:
text: |
<meta name="robots" content="noindex">
---

For .Rmd pages, I haven’t found a way to do it directly, so I use the “metathis” R package to do it for me. In a code chunk (not in the YAML header):

# Add noindex tag to prevent search engines from crawling
metathis::meta() %>%
  metathis::meta_name("robots" = "noindex")

I’m using quarto.pub, which is a great free web hosting service specifically designed for quarto websites. These directions aren’t specific to quarto.pub, however, and will work for pages rendered from .qmd or .Rmd documents no matter where they’re hosted.

Leave a comment

Filed under Uncategorized

Reading back data in Windows

When I enter data from field sheets, I like to have the computer read it back to me so I can double-check it. There are different text-to-speech accessibility features built in to various programs and operating systems, as well as stand-alone screenreaders, and some work better than others.

My work computer is Windows 11, and I’m entering data in Excel. The “speak cells” tools in Excel are painfully, painfully slow — it’ll only read back about one number a second, whether I advance it manually or automatically. Fortunately, I found a better way!

Copy a block of data into Notepad. It’s going to be read row-by-row. Only copy over what you want to have the computer read to you, whether that’s just the data, or some/all of the identifier columns.

Start Windows Narrator. The shortcut key to turn Narrator on or off is the Windows/Start key + Control + Enter.

In Notepad, put your cursor on the first row of data, and Narrator should read it to you. (If not, use the arrow keys to move down a row and back up.) Use the down arrow key to advance to the next row, and it’ll read that one. Repeat, moving quickly and efficiently down the data, and there you go!

You can change the voice and the reading speed by going into the Windows “Speech” control panel (different from “Speech Recognition”).

Why copy the data into Notepad? If you use Narrator in Excel, it reads out the cell’s column and row (e.g., “A-23”) before reading the cell’s contents. That’s important for other accessibility uses, but it gets in the way if all you want is to have the computer read back the data.

There is a way to kinda-sorta change the reading speed in Excel, but it’s not very helpful. In the “Speech Recognition” control panel (the one that looks like a holdover from an earlier version of Windows), there is a “Text to Speech” tab. And that controls the Excel voice. But the problem isn’t really the speed of speaking the number, it’s that Excel pauses for most of a second before speaking the number (even with advancing manually by pressing enter to speak). Changing the speed of the voice doesn’t seem to speed up that pause at all. So speeding up the voice with that option ends up giving you a long pause, a very quickly spoken number, and then a long pause before the next number is spoken.

Leave a comment

Filed under Uncategorized

Climate change certainty

So how certain is climate change, really?

Turns out the global scientific community is a lot more certain than you might expect, given how much climate change gets denied in politics.

Here’s the basic run-down of what we know:

  • Global warming has been happening — and the evidence is unequivocal.
  • Human activities have definitely contributed to global warming.
  • It’s 95% certain that human activities have caused most of the global warming since 1950.
  • The best estimate is that human activities have caused all or nearly all of the global warming since 1950.

Or to sum up in a single sentence: Global warming is unequivocally happening, and humans have caused most — maybe all — of it.

Continue reading for details and citations.

Continue reading

1 Comment

Filed under Uncategorized

R: Heatmap plots

I’m working with a dataset of trace-metals concentrations in different streams, and I wanted to see the overall mean concentration for each metal, in each stream. I used a heatmap to plot a grid of streams vs. metals, with a color shading in each cell representing the mean concentration.

Heatmap - wet weather metals

Light blue values are lower concentrations, dark red values are higher concentrations (grey cells contain no data). Since some metals occur at much higher concentrations than others (by a few orders of magnitude), all the data have been scaled (more on the methods below) — which is why the heatmap does not have a legend with actual values. It’s purely a high-low gradient.

Metals are in alphabetical order down the left-hand side. Streams are across the top, sorted so that the streams with the overall highest metals concentrations are on the left, going to the overall lowest metals concentrations on the right.

There are several webpages with instructions on how to build a heatmap like this in R, using ggplot2, and I’ve made my own modifications to both the aesthetics and the data-handling. Continue reading

Leave a comment

Filed under Data graphs, R

R: How to fix column names containing spaces

A basic rule of R is to avoid naming data-frame columns using names that contain spaces. R will accept a name containing spaces, but the spaces then make it impossible to reference the object in a function. Neither single or double quotes can work around this problem, and other data structures also share this limitation. (Note that commas also cause similar problems, as do many special characters.)

> select(x, Date, Depth, Total Phosphorus)
Error: unexpected symbol in "select(x, Date, Depth, Total Phosphorus"
> select(x, Date, Depth, "Total Phosphorus")
Error: All select() inputs must resolve to integer column positions.
The following do not:
*  "Total Phosphorus"

When I’m creating my own column names it’s easy to avoid the issue, but often I’m working with data that comes from other sources — and contains spaces in problematic places.

At the moment I’m working with lab data where every water-quality parameter (nitrogen, phosphorus, copper, temperature, etc.) is its own line in the dataset, with one column for the parameter name and another column for the value — often called “long” or “molten” format. The names-with-spaces problem comes when I spread out the data into “wide” format, where each row is a complete sampling date and each parameter becomes its own column.

Many of the parameters have spaces (and sometimes commas) in the name the lab uses, such as “Ammonia Nitrogen” or “Copper, Dissolved”. When I use the spread() function (from the “tidyr” package), these become column names containing spaces and commas. After trying a few approaches, I found a simple, elegant way to do it in a single line using the “stringr” package.

To fix a dataframe (or any other named structure) “x” that already has names containing spaces and/or commas:

names(x)<-str_replace_all(names(x), c(" " = "." , "," = "" ))

This replaces spaces with periods, and commas with nothing (to avoid creating double periods like “Copper..Dissolved”). Spaces and commas are the only two problematic characters I have in my dataset; if you have others, add them to the str_replace_all() call. The result from a names() call is a vector of strings, which the stringr functions can manipulate easily before passing it back through the names() function.

Another approach is to remove the spaces from the long/molten dataset before spreading it out. It’s very similar code, only on a column of parameter names:

y$Parameter<-str_replace_all(y$Parameter, c(" " = "." , "," = "" ))

 

UPDATE: I’ve discovered that tibbles — the tidyverse version of the dataframe — can handle names with spaces and other special characters. To refer to those non-standard names in functions, surround the name with backticks (on my keyboard, the backtick is on the  ~  key):

`​Copper, Dissolved`

 

Even though I’m working primarily with tibbles now, I’m going to keep renaming my columns so they’re easier to work with as I go through the rest of the data analysis. I prefer not to have to type the backticks all the time.

4 Comments

Filed under R

When hatred isn’t urgent

I don’t think that Trump’s platform of hatred and bigotry got him elected. I think that too many decent people were willing to vote for him despite his racism, sexism and all the rest — because they thought other things were more important. The hatred simply didn’t seem like an urgent problem.

But when racism means that I could get shot by the police, it threatens my basic ability to survive. When sexism keeps me from getting a job, it threatens my basic ability to survive. And when something threatens my basic ability to survive, it’s urgent.

Too many of us with privilege don’t see hatred as urgent. We know racism and sexism are sorta problematic, sure  — but other things are more pressing. We’ll deal with them later, when we’ve got time and energy. If we remember to. If it doesn’t get in the way.

We need to change. 

Continue reading

Leave a comment

Filed under Uncategorized

You don’t know what’s in your cleaning products

8115464937_bc1a808bfb_zWhat’s in your household cleaning products? Even if you’ve read the label, there’s probably still a lot left off. No law requires a complete list of ingredients on the labels of household cleaning products, unlike food or cosmetics. And what they’re not telling you about could still hurt you.

Continue reading

Leave a comment

Filed under Uncategorized

Wading through the red tape to get a government job

Now that I work for the county, I’m getting questions about how to apply for jobs here. Government job applications play by different rules than the rest of the world, so most of the advice you find out there on resumes and cover letters don’t quite apply. I’d like to expand this further (with collaborative input) to cover the whole job application process, but here are some tips for now:

The first round of screening is a “minimum qualifications” round where anyone who doesn’t meet each and every one of the listed qualifications will get excluded. It can be brutal.

To help pass the qualifications screening, HR recommends copying the list of qualifications verbatim from the job posting and answering each one. I do this in the cover letter. I write a normal one-page cover letter, and then on the next page(s) I address the qualifications.

If you’re applying for a job that requires X years of experience, address that with a table that lists each position title, years in the position, and totals them up. Either include a statement that all jobs were full-time, or include an hours-per-week column and a full-time-equivalent column. Also, on your resume put the hours-per-week for each position. (It’s in the online application, but most people will use either the online or the paper copy, not both.)

For resumes, the usual “short and sweet” approach that works everywhere else is counterproductive when applying for government jobs. Your resume has to stand alone to prove that you’re well qualified for the job (if you’re hired, it actually gets submitted to the state for oversight). That means that it needs a fair bit of detail to show that you do indeed have all the skills, knowledge, and experience you need for the job. Yes, your resume will get long in the process.

The advice I was given by HR when I was applying is to make sure that all the keywords in the job description and qualifications are addressed in your resume. You don’t necessarily need to use the exact words, but you do need to make it very clear – the first screener may be an HR person who doesn’t understand the field well enough to understand specific terms — and in any case the screener will be working bleary-eyed through a stack of ~150 applications.

1 Comment

Filed under Uncategorized

Fertilizing streams to save salmon?

forest stream - Barka FabianovaIt’s not often I read a technical report that’s jaw-dropping, but this one sure was. It’s the Fraser Valley Stream Nutrient Enrichment effort, where they’ve been adding phosphorus fertilizer to salmon-bearing streams. Much of my work focuses on keeping excess phosphorus (and nitrogen) out of lakes and streams — and here’s a big effort dumping it directly in?!? What’s up with that? Continue reading

Leave a comment

Filed under water