Code · 1 file
Sample R File
R is a language for statistics and data visualization. The R sample is a small program — a customer record, a VIP check and a formatted total — that is the same in every language we offer, so you can compare them side by side.
R · 417 B
Sample R file
An idiomatic R example: a customer record type, a VIP check, a total and a formatted loop — the same program in every language we offer.
CC0 · free for any use · Verified by an independent tool · Report a problem
# Sample R script — samplefiles.com
customers <- data.frame(
id = 1:3,
name = c("Ada", "Grace", "Linus"),
balance = c(12500, 830.5, 10000)
)
customers$vip <- customers$balance >= 10000
for (i in seq_len(nrow(customers))) {
c <- customers[i, ]
cat(sprintf("%-6s %10.2f %s\n", c$name, c$balance, if (c$vip) "VIP" else ""))
}
cat(sprintf("Total: %.2f\n", sum(customers$balance)))
summary(customers$balance)File details
Download from the command line
curl -L -o sample.R https://files.samplefiles.com/code/r/sample.Rwget https://files.samplefiles.com/code/r/sample.Rhttps://files.samplefiles.com/code/r/sample.Rprintf '%s %s\n' ded79efdab213cb258bd688e4f8d603c8cf356640f67841bfaab63edacefacf0 sample.R | shasum -a 256 -cOr check the download in your browser with the checksum calculator.