This file contains 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
### | |
### tach (c) Barry Rowlingson, 2012, pronounced like "tash" | |
### | |
### tach("file.R") will source that file into an environment and | |
### put it on the search path, thus including any function | |
### definitions without polluting your GlobalEnv | |
### | |
### retach() will scan your search path for any tach'ed files and | |
### if they have been modified since they were loaded they'll be | |
### re-tached. |
This file contains 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
require(rgeos) | |
require(sp) | |
makeRect <- function(origin, l1, l2, angle){ | |
sa = sin(angle) | |
ca = cos(angle) | |
x=origin[1] + c(0,l1*ca,l1*ca-l2*sa,-l2*sa,0) | |
y=origin[2] + c(0,l1*sa,l1*sa+l2*ca,l2*ca,0) | |
return(SpatialPolygons(list(Polygons(list(Polygon(cbind(x,y))),"Rectangle")))) | |
return(cbind(origin[1]+x,origin[2]+y)) |
This file contains 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
select TagName, | |
avg(cast(ResponseTime as bigint)) as Average, | |
stdev(cast(ResponseTime as bigint)) as StandardDev | |
from | |
(SELECT | |
Questions.CreationDate, | |
Questions.Title, | |
Tags.TagName, | |
Answers.CreationDate as ResponseDate, | |
datediff(minute, Questions.CreationDate, |
This file contains 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
# Author: Joona Lehtomäki <[email protected]> | |
# Updated: 13.11.2011 | |
# Version: 0.0.1 | |
if (!require("rgdal")) { | |
install.packages("rgdal") | |
} | |
if (!require("raster")) { | |
install.packages("raster") |
This file contains 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
# You want to show users the code to make a plot. | |
# BUT you dont want to show them the png() function call you used to make the plot | |
# for your documentation. | |
# | |
# dexy doesn't. You have to open/close the graphics device in your code: | |
### @export "graph" | |
png("plot.png") | |
plot(c(1,2,3), pch=19, col="purple") | |
dev.off() |
This file contains 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
abuff <- function(f, percent, precision, maxsteps = 20){ | |
require(rgeos) | |
A0 = gArea(f) | |
targetA = A0 + A0 * (percent/100) | |
e = bbox(f) | |
w0 = 0 | |
w2 = diff(e[1,])/10 # initial w | |
## initial expansion until we pass the solution: |
This file contains 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") |
This file contains 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 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 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> |
OlderNewer