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
| ### THE SCRIPT TO RUN -- MAKE SURE IT'S NOT INDENTED -- script goes bretween EOS's @input_file and @output_file are replaced with input and output files. | |
| task :default=>"brownbag:install" | |
| desc %{builds slides.md for use by reval} | |
| task :reveal=>"brownbag:reveal" | |
| namespace :brownbag do | |
| ### | |
| SCRIPT_TO_RUN =<<EOS | |
| Rscript -e 'require(knitr);options("revealout"="n");render_markdown();knit("@input_file", output="@output_file")' |
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
| #! #!/usr/bin/env python3 | |
| import io, os, re | |
| os.chdir('/Users/tom/Desktop/tmp') | |
| e=open('questiondb.xml','rt') | |
| search_string=e.read() | |
| e.close() | |
| outfile=open("out.txt",'w') | |
| matches=re.findall(r"(<item d2l_2p0:id=.*\n(.+?\n(?!</item))+?.*?questiontype(.*?\n)+?.*Multiple Choice\n(.*\n)+?.*/item>.*?\n)",search_string) |
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
| #!/usr/bin/env ruby | |
| require 'date' | |
| dates=Array.new() | |
| c = Date.new(2014,07,04) | |
| b= Date.new(2014,06,02) | |
| max_weeks= (c-b)/7.to_f | |
| max_weeks=max_weeks.ceil | |
| course_day=0 | |
| (c-b).to_int.times do |t| |
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
| require "rubygems" | |
| require "bundler/setup" | |
| require "stringex" | |
| ## REQUIRED OPTIONS | |
| octopress_home = '~/Desktop/jb' # Path go jekyll site goes here. This shoudl work eqally well on octopress as on jb or vanilla jekyll | |
| my_rmd_files=FileList[Dir.glob("./**/*.Rmd", File::FNM_CASEFOLD)] | |
| # This assumes the rakefile is in the base of the directory where knitr docs are |
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
| # First, you need to install the boxcar app, | |
| # then subscribe to the generic feed by running this in your 'os x' terminal | |
| curl -d "[email protected]" http://boxcar.io/devices/providers/MH0S7xOFSwVLNvNhTpiC/notifications/subscribe | |
| # then, in the boxcar app, you need to confirm that you want to get notifications from the generic monitoring provider (it will ask in a popup) | |
| # now, you can put the following commands in your R script and it will send you a notification when that command runs (this is all one line of code): |
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
| #------------------------------------------------------------------------------- | |
| # #generate periodic data: | |
| #------------------------------------------------------------------------------- | |
| #{{{ | |
| #set number of data points to generate | |
| n<-500 | |
| x<-runif(n,1,5) | |
| # coefficient | |
| # next line is the key for the DGP of Y: |
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
| #!/usr/bin/env ruby | |
| require 'rserve' | |
| import rserve | |
| require 'rserve' | |
| include Rserve | |
| c = Connection.new # from here out, all calls to R will occur in the method: "c.eval()" | |
| out_args = c.eval %{ |
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
| my_table=File.open("this.txt","r") |
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
| # Save file as eps | |
| setEPS() | |
| postscript(file="testplot.eps", | |
| ) | |
| ## PLOT COMMAND GOES HERE: FOR EXAMPLE: | |
| plot(hist(prestige,freq=FALSE),main=NULL,ylab="Density",xlab="Occupational Prestige") | |
| dev.off() |
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
| #assume data.frame(dat) | |
| data.frame( model.matrix(~lp_legor-1,data=dat))->tmp | |
| names(dat)->tmpnames1 | |
| names(tmp)->tmpnames2 | |
| data.frame(dat,tmp)->dat | |
| names(dat)<-c(tmpnames1,tmpnames2) |