Day 22 — work on a remote computer and bring the result back
Yesterday’s single-cell table needs about 24 GB of RAM; your laptop has 16 GB or less. Research groups solve this by logging in to a bigger, shared Linux computer and running the same R analysis there. But then there are two computers, each with its own files. You rendered a report remotely: where is it, and how do you get it back?
Today you will:
This is a hands-on day. The remote service details (host, login, transfer method) will be supplied separately; until then you rehearse locally. On Day 23 you run a small study from question to report.
course project with a report.Rmd. They are separate copies.$ ssh student@remote
student@remote:~$ hostname
remote
student@remote:~$ pwd
/home/student
student@remote:~$ mkdir introcomputing-practice
student@remote:~$ ls
introcomputing-practice
student@remote:~$ exit
logout
Connection to remote closed.
$ pwd
/home/anna
student@remote stands for your login and the computer’s name from the service guide; yours will differ.student@remote:~$ means the remote computer is listening.hostname names the computer that answered; pwd the folder you are in on that computer.exit ends the connection. Back on the laptop, pwd shows a laptop folder again.reports/remote-log.txt.$ ssh student@remote
student@remote:~$ ls
introcomputing-practice
exit closed the session (the connection), not the remote disk.In the remote R console:
> getwd()
[1] "/home/student/introcomputing-course"
> file.exists("data/algae.csv")
[1] TRUE
> algae <- readr::read_csv("data/algae.csv",
+ show_col_types = FALSE)
> nrow(algae)
[1] 24
> sum(!is.na(algae$biomass_mg))
[1] 23
> algae$biomass_mg[algae$culture_id == "A19"]
[1] NA
getwd(): R works in the copied project (placeholder path).student@remote:~$ cd introcomputing-course
student@remote:~/introcomputing-course$ Rscript -e 'rmarkdown::render("report.Rmd")'
processing file: report.Rmd
...
Output created: report.html
student@remote:~/introcomputing-course$ ls
data introcomputing.Rproj output report.html report.Rmd reports
Rscript starts a fresh R and renders the saved report, like Knit after a restart.ls shows the new report.html, on the remote disk. Download it to a named laptop folder and open that copy.The report rendered remotely, but local Downloads is empty. Before rendering again, check:
An empty Downloads folder does not mean the render failed. Rendering again only makes another copy in the same unexpected place.
Write reports/transfer-plan.txt first:
data/algae.csv) and the checks to repeat;receipt.txt can hold different versions.report.Rmd does not change an old HTML until you render again.> writeLines("version 1", "output/receipt-a.txt")
> writeLines("version 2", "output/receipt-b.txt")
> file.size(c("output/receipt-a.txt",
+ "output/receipt-b.txt"))
[1] 10 10
> identical(readLines("output/receipt-a.txt"),
+ readLines("output/receipt-b.txt"))
[1] FALSE
identical(readLines(a), readLines(b)) compares the actual text.| Idea | Key fact |
|---|---|
| Why remote | data larger than laptop RAM need a bigger computer (Day 21) |
| Two computers | each has its own disk; same folder names are separate copies |
| SSH / remote desktop | a terminal or a screen on the remote computer; neither copies files |
hostname, pwd, exit |
which computer, which folder; leave without deleting saved files |
| Transfer | makes a copy; name source, destination and direction |
| Checks | repeat nrow, available counts and named records after copying; equal size ≠ equal contents |
| Missing result | find it on the remote side, then check the transfer and destination |
Next (Day 23, mini-study): plan and analyse a small biological study from question to report.
Now: Open exercises · Quiz. Leave with reports/remote-log.txt, reports/transfer-plan.txt, the receipt and the audit. Until access details arrive, do the local rehearsal and mark the remote steps pending.