Skip to content

Instantly share code, notes, and snippets.

@iwi
iwi / ggplot curve
Created April 7, 2018 15:39
How to plot a function in ggplot2 as you would do with curve
curve(dnorm(x, 178, 20), from = 100, to = 250)
# is the same as
ggplot(tibble(x = seq(100, 250, 10)), aes(x)) +
stat_function(fun = function(x) dnorm(x, 178, 20))
```
"+y
```

Keybase proof

I hereby claim:

  • I am iwi on github.
  • I am iwi (https://keybase.io/iwi) on keybase.
  • I have a public key whose fingerprint is 84CA 8143 F460 D544 1165 ACB4 970F C10F E9EE 4056

To claim this, I am signing this object:

@iwi
iwi / R_read_csv_multi_length.md
Last active September 21, 2016 21:17
# reading a csv with multiple length rows into an R data frame

In R, if you ever want to read a csv file where the rows have different lengths, and the csv does not have a header row with all the column names, neither read.csv from {base} nor read_csv from {readr v.1.0.0}, will read the columns as (I would have) expected.

For example, given the following csv:

A,B
C,D
E,F
G,H
docker run --rm -it -v $(pwd)/cv:/root/torch-rnn/cv crisbal/torch-rnn:base bash
@iwi
iwi / untar.md
Created February 27, 2016 13:06
How to untar file

How to untar Open a terminal and type: tar xvjf filename.tar.bz2 Which will untar it to the current directory. Normally (99% of the time) it will create it's own subdirectory so you don't need to worry about that. Just so you know: tar - Tape ARchiver And the options: x - extract v - verbose output (lists all files as they are extracted) j - deal with bzipped file

@iwi
iwi / get_html_dirs.md
Last active February 27, 2016 12:56
get html directories

wget -r -np -nH --cut-dirs=3 -R index.html http://hostname/aaa/bbb/ccc/ddd/

Explanation:

It will download all files and subfolders in ddd directory: recursively (-r), not going to upper directories, like ccc/… (-np), not saving files to hostname folder (-nH), but to ddd by omitting first 3 folders aaa, bbb, ccc (--cut-dirs=3) excluding index.html files (-R index.html)

###################################################
### 0.Preparación de los datos
###################################################
###################################################
### 0.1.Asignación de directorios
###################################################
setwd("/<...>/PEC1")
workingDir <-getwd()
dataDir <-file.path(workingDir, "data")