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
case class ToastedBread(slices: Int) | |
case class FriedEggs(num: Int) | |
case class CrispyBacon(strips: Int) | |
case class OrangeJuice(glasses: Int) | |
case class HotCoffee(mugs: Int) | |
case class MainDish(eggs: FriedEggs, bacon: CrispyBacon) | |
case class SideDish(toast: ToastedBread) | |
case class Drinks(juice: OrangeJuice, coffee: HotCoffee) |
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
object JsonImplicits extends DefaultJsonProtocol { | |
//main dish | |
implicit val impCrispyBacon = jsonFormat1(CrispyBacon) | |
implicit val impFriedEggs = jsonFormat1(FriedEggs) | |
implicit val impMainDish = jsonFormat2(MainDish) | |
//side dish | |
implicit val impToastedBread = jsonFormat1(ToastedBread) | |
implicit val impSideDish = jsonFormat1(SideDish) |
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
CREATE KEYSPACE ks WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } ; | |
create table ks.tb ( | |
a1 TEXT, | |
b1 TEXT, | |
b2 INT, | |
d INT, | |
v INT, | |
PRIMARY KEY ( a1, b1, b2 ) | |
); |
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
#function | |
myfunc.x.a.b.c = function(x,a,b,c) { | |
a*x*x+ b*x +c | |
} | |
myfunc.x.a.b.c(1,2,3,4) | |
myfunc.x.a.b = function(x,a,b){ | |
function(c) {myfunc.x.a.b.c(x,a,b,c)} | |
} |
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
library("ggplot2") | |
#function | |
myfunc = function(x,a,b,c) { | |
a*x*x+ b*x +c | |
} | |
#basic plot, fixed parameter a = 1, b=0, c=0 | |
p = ggplot(data.frame(x = c(-10, 10)), aes(x)) | |
p + stat_function(fun=function(x) { myfunc(x,1, 0, 0) } ) |
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
CREATE KEYSPACE iot WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } ; | |
USE iot; | |
create table signals ( | |
sid bigint, | |
year int, | |
month int, | |
day int, | |
hour int, |
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
library('XML') | |
library('RCurl') | |
# Save the URL of the xml file in a variable | |
fileUrl="http://data.treasury.gov/feed.svc/DailyTreasuryYieldCurveRateData?$filter=year(NEW_DATE)%20eq%202010" | |
###Using the rcurl package, first download, then parse | |
#Get the content | |
fileContent = getURL(fileUrl) |
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
# read in ducth election file as provided by http://www.engagedata.eu/dataset/14399 | |
# https://engagefp7.s3.amazonaws.com/resources/dataset_14399/TK2010.csv | |
dat = read.csv2('http://engagefp7.s3.amazonaws.com/resources/dataset_14399/TK2010.csv', skip=31, header=FALSE) | |
#define column names | |
columns = ' | |
Gemeente; | |
geldige stemmen; | |
ongeldige stemmen; |
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
library('ggplot2') | |
#basics | |
3*4 | |
2^3 | |
1/2 + 1/2*sqrt(5) | |
#those two are identical | |
(1+2+3+4)/4 |
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
library("MASS") | |
write.csv(Cars93, 'cars93.csv') |