title | author | output | ||||
---|---|---|---|---|---|---|
Programming with dplyr |
Andy Reagan |
|
library(dplyr)
Alabama::Nick Saban::Head football coach::University of Alabama::8,307,000 | |
Alaska::James Roland Johnsen::President::University of Alaska Statewide System::384,599.99 | |
Arizona::Sean Miller::Head basketball coach::University of Arizona::2,700,000 | |
Arkansas::Chad Morris::Head football coach::University of Arkansas::3,500,000 | |
California::Chip Kelly::Head football coach::University of California, Los Angeles::3,300,000 | |
Colorado::Mike MacIntyre::Head football coach::University of Colorado Boulder::2,878,500 | |
Connecticut::Randy Edsall::Head football coach::University of Connecticut::1,100,000 | |
Delaware::Mark T. Brainard::President::Delaware Technical Community College::245,954.82 | |
Florida::Dan Mullen::Head football coach::University of Florida::6,070,000 | |
Georgia::Kirby Smart::Head football coach::University of Georgia::6,603,600 |
from math import prod | |
from itertools import product | |
import click | |
LETTERS = "abcdefghijklmnopqrstuvwxyz" | |
assert len(LETTERS) == 26 | |
def get_all_possibilities(guesses: list, results: list) -> list: | |
bad_letters_global = [ |
title | author | output | ||||
---|---|---|---|---|---|---|
Programming with dplyr |
Andy Reagan |
|
library(dplyr)
import random | |
def decrypt(plain: str, key: list): | |
short_key = [y for y in key if y < len(plain)] | |
return ''.join([plain[y] for y in [z for z in sorted(range(len(plain)),key=short_key.__getitem__)]]) | |
def encrypt(plain: str, key: list): | |
''' |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=900, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
body { | |
font-family: sans-serif; |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=900, initial-scale=1.0"> | |
<title>Document</title> | |
<style> | |
body { | |
font-family: sans-serif; |
Here's how to use an R script like a Python script, relying on box. While there are reasons to use R, there are also two very bad parts of the R language, avoid them: (1) never use source
and (2) never use library
. These encourage patterns of code that are difficult to test or maintain. Using source
comes along with changing the working directory sometimes, which should also be avoided. I'll quote Jenny Bryan, who, among other things says
Have setwd() in your scripts? PLEASE STOP DOING THAT. ... I will come into your lab and SET YOUR COMPUTER ON FIRE.
She has also written a whole post on why setwd()
is, and I quote again, "so problematic and often associated with other awkward workflow problems".
There are three files here:
src/main/myscript.R
: the main script, has functions that can be used elsewhere and also can be run standalone.day | game | KD | Accuracy | match | Kills | |
---|---|---|---|---|---|---|
1 | 1 | 0.56 | 07.60 | TDM | 9 | |
1 | 2 | 0.48 | 04.40 | TDM | 12 | |
1 | 3 | 0.50 | 09.80 | TDM | 13 | |
1 | 4 | 0.90 | 09.40 | TDM | 27 | |
1 | 5 | 0.36 | 03.50 | TDM | 4 | |
1 | 6 | 0.71 | 04.70 | TDM | 10 | |
1 | 7 | 1.38 | 00.00 | TDM | 18 | |
1 | 8 | 1.00 | 20.00 | TDM | 2 | |
2 | 1 | 0.78 | 15.30 | TDM | 7 |
<?xml version="1.0" encoding="UTF-8"?> | |
<gpx creator="StravaGPX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd" version="1.1" xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3"> | |
<metadata> | |
<time>2020-09-13T10:04:30Z</time> | |
</metadata> | |
<trk> | |
<name>Virtual Boston Marathon!</name> | |
<type>9</type> | |
<trkseg> | |
<trkpt lat="42.4211140" lon="-72.4243420"> |
[flake8] | |
max-line-length = 88 | |
max-complexity = 12 | |
select = C,E,F,W,B,B950 | |
ignore = E203, E501, W503 |