This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| . /etc/profile | |
| usage () { | |
| printf "Usage: %s: [-h] -m -d -c -n name -j jobname -b Bfile -e Efile <Rfile> [Rargs]\n" $(basename $0) >&2 | |
| } | |
| mflag= | |
| nflag= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| mkdir -p pages | |
| rm pages/image*png | |
| convert -verbose -colorspace RGB -units PixelsPerInch -resize 1024 -geometry 1224 -interlace none -density 200 -quality 80 $1 pages/image.png | |
| npages=`ls pages/image-*.png| wc -l` | |
| for (( i=0 ; i<$npages ; i++ )) | |
| do | |
| echo '' | |
| echo " " |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| readit = function(filename){ | |
| lines = readLines(filename) | |
| whichdata = grep("^[0-9]{4}",lines) | |
| headers = read.table(textConnection(lines[min(whichdata)-1])) | |
| datalines = lines[whichdata] | |
| dmat = read.table(textConnection(datalines),na.strings=c("***","****")) | |
| names(dmat)=t(headers)[,1] | |
| dmat | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ "$#" == "0" ]; then | |
| echo "diff [file1] [file2] ..." | |
| echo " Does diff file1 file2 ; diff file2 file3 ; diff file3 file4 ; etc" | |
| exit 1 | |
| fi | |
| first="$1" | |
| shift |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| areaLL <- function(r){ | |
| ## cell areas in km^2 | |
| areas = area(r) | |
| ## area of non-NA in km^2 | |
| ## this is the flat area | |
| a = sum(values(area(r)*(!is.na(r)))) | |
| centre = cellFromRowCol(r, nrow(r)/2, ncol(r)/2) | |
| ## compute w/h of middle cell | |
| a1 = areas[centre] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Colours of old Smarties with lovely artificial colouring, derived from: | |
| ### | |
| ### | |
| ### "Smarties old new" by John Penton and Paul Hughes - Own work. Licensed under CC BY-SA 2.5 via Wikimedia Commons - https://commons.wikimedia.org/wiki/File:Smarties_old_new.jpg#mediaviewer/File:Smarties_old_new.jpg | |
| ### | |
| ### image was loaded into gimp, representative parts of each Smartie were isolated, the image converted to indexed palette | |
| ### with 9 colours, the palette then saved. | |
| ## | |
| ### "Smarties" is a trademark of Nestle | |
| ## |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| Maps... | |
| Normally when using the leaflet package you do: | |
| leaflet(data) %>% addTiles() %>% addPolygons() | |
| and the html is saved in a new place and your web browser gets another tab appear. | |
| After the 26th attempt to get the map right I have 25 tabs to close. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## lets use this nearest neighbour package: | |
| require(RANN) | |
| ## create a village as a cluster of houses around x,y: | |
| village <- function(x, y, n, id, sd){ | |
| ## return a data frame of x, y, and id values: | |
| data.frame(x=x+rnorm(n,0,sd), | |
| y=y+rnorm(n,0,sd), | |
| id=id | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| for f in $* ; do | |
| libreoffice "-env:UserInstallation=file:///tmp/LibO_Conversion" --headless --invisible --convert-to pdf "$f" | |
| done | |
| rm -rf /tmp/LibO_Conversion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(sp) | |
| library(rgdal) | |
| library(ggplot2) | |
| library(spdep) | |
| library(ggpolypath) | |
| usq = data.frame(x=c(0,1,1,0),y=c(0,0,1,1)) | |
| pts1 = | |
| structure(list(x = c(-0.380226816911908, -0.368506824640174, |