whoami
kjhealy
Modern Plain Text Social Science: Week 1
September 30, 2023
But we can make it work
Multitasking: I mean, “Making different specialized applications and resources work together in the service of a single but multi-dimensional project”, not “Checking social media while also listening to a talk and waiting for an update from the school nurse.”
Paper_edits_FINAL_kh-1.docx
Object of type 'closure' is not subsettable
Each approach generates solutions to its own problems
You may never have actually used one of these.
/
: root. Everything lives inside or under the root./bin/
: For binaries. Core user executable programs and tools./sbin/
: System binaries. Essential executables for the super user (who is also called root
)/lib/
: Support files for executables./usr/
: Conventionally, stuff installed “locally” for users in addition to the core system. Will contain its own bin/
and lib/
subdirs./usr/local
: Files that the local user has compiled or installed/opt/
: Like /usr/
, another place for locally installed software to go.$PATH
, which is an environment variable that tells the system where executables can be found.:
and searched in order from left to right.which
/
: root. Everything lives inside or under the root./bin/
: For binaries. Core user executable programs and tools./sbin/
: System binaries. Essential executables for the super user (who is also called root
)/lib/
: Support files for executables./usr/
: Conventionally, stuff installed “locally” for users in addition to the core system. Will contain its own bin/
and lib/
subdirs./usr/local
: Files that the local user has compiled or installed/opt/
: Like /usr/
, another place for locally installed software to go./etc/
: Editable text configuration. Config files often go here./home/
or /Users/
: Where the accounts of individual system users live, like /Users/kjhealy/
/
tree├── Applications
├── bin
├── cores
├── dev
├── etc -> private/etc
├── home -> /System/Volumes/Data/home
├── Library
├── opt
│ ├── homebrew
├── private
│ ├── etc
│ ├── tftpboot
│ ├── tmp
│ └── var
├── sbin
├── System
├── tmp -> private/tmp
├── Users
│ ├── kjhealy
│ └── Shared
├── usr
│ ├── bin
│ ├── lib
│ ├── libexec
│ ├── local
│ ├── sbin
│ ├── share
│ ├── standalone
├── var -> private/var
└── Volumes
├── Applications
├── bin
├── Box
├── Creative Cloud Files
├── Desktop
├── Documents
│ ├── bibs -> /Users/kjhealy/Library/texmf/bibtex/bib
│ ├── bookdown
│ ├── comments
│ ├── completed
│ ├── courses
│ ├── data
│ ├── letters
│ ├── misc
│ ├── nonsense
│ ├── ordinal-society
│ ├── papers
│ ├── sites
│ ├── source
│ ├── talks
│ ├── teaching
│ ├── templates
│ ├── vita
├── Downloads
├── Dropbox
├── Library
├── Movies
├── Music
├── Pictures
├── Public
├── scratch
├── tmp
└── Zotero
Who am I?
Where am I?
What is in here?
total 352
drwxr-xr-x@ 8 kjhealy staff 256 Aug 15 16:35 R
-rw-r--r--@ 1 kjhealy staff 1967 Sep 18 21:38 README.md
-rw-r--r--@ 1 kjhealy staff 1764 Aug 30 12:28 README.qmd
drwxr-xr-x@ 3 kjhealy staff 96 Sep 18 21:38 README_files
drwxr-xr-x 6 kjhealy staff 192 Jan 8 13:32 _extensions
drwxr-xr-x 9 kjhealy staff 288 Jan 8 13:41 _freeze
-rw-r--r--@ 1 kjhealy staff 2946 Jan 8 13:38 _quarto.yml
drwxr-xr-x 2 kjhealy staff 64 Jan 8 13:41 _site
drwxr-xr-x@ 7 kjhealy staff 224 Jan 8 13:38 _targets
-rw-r--r--@ 1 kjhealy staff 2286 Jan 8 13:37 _targets.R
-rw-r--r--@ 1 kjhealy staff 840 Jan 8 10:27 _variables.yml
drwxr-xr-x@ 4 kjhealy staff 128 Jan 8 13:41 about
drwxr-xr-x@ 11 kjhealy staff 352 Sep 25 12:30 assets
drwxr-xr-x@ 6 kjhealy staff 192 Jan 8 13:41 assignment
drwxr-xr-x@ 14 kjhealy staff 448 Jan 8 13:41 content
drwxr-xr-x@ 4 kjhealy staff 128 Jan 8 10:38 data
-rwxr-xr-x@ 1 kjhealy staff 295 Sep 7 14:38 deploy.sh
drwxr-xr-x@ 15 kjhealy staff 480 Jan 8 13:41 example
drwxr-xr-x@ 8 kjhealy staff 256 Sep 8 11:14 files
drwxr-xr-x 14 kjhealy staff 448 Jan 8 10:23 html
-rw-r--r-- 1 kjhealy staff 42894 Jan 8 13:41 index.html
-rw-r--r--@ 1 kjhealy staff 6379 Oct 4 16:22 index.qmd
-rw-r--r--@ 1 kjhealy staff 258 Jan 8 13:33 mptc.Rproj
drwxr-xr-x@ 7 kjhealy staff 224 Aug 15 17:04 renv
-rw-r--r--@ 1 kjhealy staff 46675 Jan 8 13:38 renv.lock
-rw-r--r-- 1 kjhealy staff 46717 Dec 11 18:14 renv.lock.orig
drwxr-xr-x@ 4 kjhealy staff 128 Jan 8 13:41 schedule
drwxr-xr-x 9 kjhealy staff 288 Jan 8 13:41 site_libs
drwxr-xr-x@ 13 kjhealy staff 416 Jan 8 13:42 slides
drwxr-xr-x 3 kjhealy staff 96 Jan 8 10:39 syllabus
Note the idea of commands having options, or switches.
The ~
character is a shortcut to the top of your home directory:
/
, it is an absolute path, starting from the root.~
, it will usually be expanded into an absolute path name starting at your home directory (~
)./
or ~
/Users/kjhealy/Documents/papers
then ../data
means /Users/kjhealy/Documents/data
drwxr-xr-x@ 8 kjhealy staff 256 Aug 15 16:35 R
-rw-r--r--@ 1 kjhealy staff 1210 Aug 15 20:29 README.md
In Unix systems there are three kinds of owner: the user (here kjhealy
), the group (here staff
), and others or other users on the system.
drwxr-xr-x@ 8 kjhealy staff 256 Aug 15 16:35 R
-rw-r--r--@ 1 kjhealy staff 1210 Aug 15 20:29 README.md
Three things you can do:
cd
❯ ls -l README.md
-rw-r--r--@ 1 kjhealy staff 1210 Aug 15 20:29 README.md
These permissions say rw-r--r--
or
rw-
read and write this filer--
read this filer--
read this fileExecutable permissions are irrelevant here because it’s a text file.
chmod
command. So e.g. chmod 644 README.md
means “change the permissions to rw-r--r--
”.ls
:We can send, or pipe, this output to another command, instead of to the terminal:
wc
command counts the number of words in a file, or in whatever is sent to it via STDIN
.-l
switch to wc
means ‘just count lines instead of words’Like with pipelines in R, we can compose sequences of actions at the prompt:
❯ head access.log
192.195.49.31 - - [27/Aug/2023:00:01:11 +0000] "GET / HTTP/1.1" 200 19219 "https://www.google.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:12 +0000] "GET /libs/tufte-css-2015.12.29/tufte.css HTTP/1.1" 200 2025 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:12 +0000] "GET /libs/tufte-css-2015.12.29/envisioned.css HTTP/1.1" 200 888 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:12 +0000] "GET /css/tablesaw-stackonly.css HTTP/1.1" 200 1640 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:12 +0000] "GET /css/nudge.css HTTP/1.1" 200 1675 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:12 +0000] "GET /css/sourcesans.css HTTP/1.1" 200 1492 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:13 +0000] "GET /js/jquery.js HTTP/1.1" 200 30464 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:13 +0000] "GET /js/tablesaw-stackonly.js HTTP/1.1" 200 2996 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
192.195.49.31 - - [27/Aug/2023:00:01:13 +0000] "GET /js/nudge.min.js HTTP/1.1" 200 937 "https://socviz.co/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.54"
52.13.187.67 - - [27/Aug/2023:00:01:13 +0000] "GET /dataviz-pdfl_files/figure-html4/ch-03-fig-lexp-gdp-10-1.png HTTP/1.1" 200 308830 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0"
Like with pipelines in R, we can compose sequences of actions at the prompt:
Like with pipelines in R, we can compose sequences of actions at the prompt:
❯ awk '// {print $11}' access.log | sort | uniq -c | sort -nr | head -n 15
9729 "https://socviz.co/lookatdata.html"
4851 "-"
4212 "https://socviz.co/"
1719 "https://socviz.co/makeplot.html"
1477 "https://bookdown.org/"
1466 "https://socviz.co/gettingstarted.html"
1373 "https://socviz.co/groupfacettx.html"
864 "https://socviz.co/workgeoms.html"
794 "https://socviz.co/maps.html"
733 "https://socviz.co/refineplots.html"
671 "https://socviz.co/index.html"
349 "https://socviz.co/appendix.html"
228 "https://socviz.co/modeling.html"
153 "https://www.google.com/"
50 "http://vissoc.co/"
We can do a lot with a pipeline:
curl -s 'http://api.citybik.es/v2/networks/citi-bike-nyc' |
jq '.network.stations[].free_bikes' |
gpaste -sd+ |
bc
36747
This is the number of Citi Bikes available in New York City at the time these slides were made.
xcode-select –install
https://brew.sh
https://learn.microsoft.com/en-us/windows/wsl/install
https://www.cygwin.com