Book: The Logic of Modern Physics (Bridgman, 1927)

Just found that this classic is available for free at the Internet Archive! Great!

A picture of the book from the internet archive

There are PDF and MOBI versions, among other formats.

I read some of the chapters several years ago. Yes, it was published nearly 90 years ago and may not be "modern" now. But some of the ideas were still adopted (or misunderstood?) by psychologists in the 21st century (yes, psychologists).

[R-mini] Help on help

Some common ways to find the documentation of a function.

To find the documentation of the function mean():


To search using a reserved word, such as else and if:


To find the documentation of a symbol, for example, the plus symbol +:


To find the documentation files with the string "weighted" somewhere in them:


To find the documentation files with the strings "weighted" and "mean" somewhere in them (fuzzy matching is used but I don't know what it is, :p):

??"weighted mean"

If we want to have the documentation returned as a text file instead of a page in the default web browser:

help(mean, help_type="text")

There are other ways to refine a search. But the ways above are what I usually use and are sufficient most of the times.

[R-mini] Convert a long string to a named list

Suppose I would like to convert this string, "N=100, NRep=200, K=10, P=5", to a named list, I can use eval() and parse(). This is useful when the arguments for a function is passed as one single string as the command line argument.
str <- "N=100,NRep=200,K=10,P=5"
x <- eval(parse(text=paste('list(', str, ')')))

This is the content of x:

[1] 100
[1] 200
[1] 10
[1] 5

I believe I learned about this somewhere, but I forgot the source.

If a value in the list is a string, just use single quotes, for example:

str <- "N=100,NRep=200,name='Test',P=5"

[R-mini] Read an SPSS data file

I still occasionally need to read an SPSS data file in R because some of my collaborators use SPSS. I usually use read.spss() from the foreign package:

fromSPSS.df <- read.spss(file.choose(), reencode=65001, use.value.labels=TRUE,

The output is the data frame fromSPSS.df.

file.choose() can be replaced by the file name in quotes if the SPSS data file in the working directory.

reencode=65001 is not necessary if all the content in the SPSS data file is in English. However, I found that I need this option to import some SPSS data files with Chinese characters correctly.

By default, use.value.labels=TRUE. I put it here to remind me of this argument, such that I can turn it off if necessary. For example, when some variables are Likert scale scores with value labels but should be treated as numbers.

I usually work with data frame and so I use This also converts all missing values to NA.

read.spss() is very old and cannot read some SPSS files I have. But it is good enough for most purposes.

More on read.spss() at

[R-mini] Scatter plots for Likert scales data in psychological studies: Binned scatter plot?

As mentioned in a previous post,
"Scatter plot is an important tool for data exploration. However, Likert scales, with only a few discrete possible values, are common in psychology. The usual scatter plot is not good for examining the association between two Likert scale variables. Cross-tabulation table can show the frequencies, but I like using graphs."
Bubble plot is introduced in that post. This post introduces binned scatter plot, using the shading to reflect the frequency of a cell. This is the sample code:

This is the result:

Latest version can be found at RNotes at GitHub.