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
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
#!/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
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 | |
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
#!/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
<!DOCTYPE connections> | |
<qgsWMSConnections version="1.0"> | |
<wms ignoreGetMapURI="true" smoothPixmapTransform="false" dpiMode="7" password="" ignoreGetFeatureInfoURI="false" referer="" username="" url="http | |
://218.244.250.80:8080/erdas-apollo/coverage/CGLC" invertAxisOrientation="false" ignoreAxisOrientation="false" name="China Land Cover"/> | |
</qgsWMSConnections> |
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
## make a data frame with a new class | |
d=data.frame(x=1:10,y=rnorm(10)) | |
class(d)=c("foo","data.frame") | |
class(d) | |
## [1] "foo" "data.frame" | |
## ordinary subsetting and subset preserve us: | |
## |
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
# load an object 'name' from a .RData file 'file'. | |
# eg | |
# x1 = loadFrom("foo.RData","x") | |
# x2 = loadFrom("bar.RData","x") | |
# | |
# useful when you want to load from two or more files with objects with the same name and | |
# load(file) would stomp on the second one. | |
loadFrom=function(file, name){e=new.env();load(file,env=e);e[[name]]} |
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
### | |
### superclassing is nice | |
### | |
require(dplyr) | |
require(testthat) | |
set.seed(310366) | |
classes = c("thingy","data.frame") |