wordfeud_update=function(){
wf=read.table(pipe("pbpaste"),header=T,sep="\t",stringsAsFactors=FALSE) # read from the (Excel) clipboard
if(sum(nchar(paste(wf$used,wf$unused,sep=""))>7)>0)
stop(paste("Line",which(nchar(paste(wf$used,wf$unused,sep=""))>7),"has more than seven characters."))
cat(paste("Number of games: ",length(unique(wf$start)),".\n",sep=""))
cat(paste("Total score of the game started at ",wf$start[nrow(wf)],": ",
tapply(wf$points,wf$start,sum)[wf$start[nrow(wf)]],".\n",sep=""))
wf$turn=supply::casenumber(wf$start)
seconds=structure(sample(0:59,length(unique(wf$start)),replace=T),names=unique(wf$start))
wf$start=paste(wf$start,sprintf("%02.0f",seconds[wf$start]),sep=":")
wf$new=do.call(c,lapply(unique(wf$start),function(start){
dfr=wf[wf$start==start,]
c(sapply(1:((nrow(dfr))-1),
function(r){newletters(dfr[r,"unused"],paste(dfr[r+1,"used"],dfr[r+1,"unused"],sep=""))}),"")}))
if (!readline("Press \"n\" if the datafile should not be saved. ") %in% c("N","n"))
{save(wf,file="/Users/ling-jwe/Documents/R/PACKAGES/games/data/mygames.RData")
cat("Game saved to the package data folder. Have a nice day.\n")}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.