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 html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<style> | |
article, aside, figure, footer, header, hgroup, |
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 html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
<style> | |
article, aside, figure, footer, header, hgroup, |
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
sed 's/abc/XYZ/g' <infile >outfile |
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
x1<-"2013-03-03 23:26:46.315558" | |
x2<-"2013-03-03 23:31:53.091022" | |
x1 <- strptime(x1, "%Y-%m-%d %H:%M:%OS") | |
x2 <- strptime(x2, "%Y-%m-%d %H:%M:%OS") | |
x2 | |
[1] "2013-03-03 23:31:53" | |
x1 | |
[1] "2013-03-03 23:26:46" | |
x2-x1 | |
Time difference of 5.112924 mins |
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
s="{'#JJ': 121, '#NN': 938, '#DT': 184, '#VB': 338, '#RB': 52}" | |
r1<-sapply(strsplit(s, "[^0-9_]+",as.numeric),as.numeric) | |
r2<-sapply(strsplit(s, "[^A-Z]+",as.numeric),as.character) | |
d<-data.frame(id=r2,value=r1) | |
r1 | |
[,1] | |
[1,] NA | |
[2,] 121 |
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
df <- data.frame(m = c( | |
"{'#JJ': 121, '#NN': 938, '#DT': 184, '#VB': 338, '#RB': 52}", | |
"{'#NN': 168, '#DT': 59, '#VB': 71, '#RB': 5, '#JJ': 35}", | |
"{'#JJ': 18, '#NN': 100, '#DT': 23, '#VB': 52, '#RB': 11}" | |
)) | |
parse.one <- function(s) { | |
require(rjson) | |
y <- fromJSON(gsub("'", '"', s)) | |
names(y) <- gsub("#", "", names(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
> authors | |
surname nationality deceased | |
1 Tukey US yes | |
2 Venables Australia no | |
3 Tierney US no | |
4 Ripley UK no | |
5 McNeil Australia no | |
> books | |
name title other.author | |
1 Tukey Exploratory Data Analysis <NA> |
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
subset(temp2,is.na(num_ne)) | |
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
time_spent <- function(from,to) { | |
op <- options(digits.secs = 3) | |
x<-as.numeric((strptime(to, "%Y-%m-%d %H:%M:%OS")-strptime(from, "%Y-%m-%d %H:%M:%OS")),units="secs") | |
data.frame(time_spent=x) | |
} | |
dane_evaluations<-data.frame(dane_evaluations,time_spent=apply(dane_evaluations[,c('documentevaluation_start','documentevaluation_end')],1,function(x) time_spent(x[1], x[2]))) |
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
# aggregate data frame mtcars by cyl and vs, returning means | |
# for numeric variables | |
attach(mtcars) | |
aggdata <-aggregate(mtcars, by=list(cyl,vs), | |
FUN=mean, na.rm=TRUE) | |
print(aggdata) | |
detach(mtcars) |
OlderNewer