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
# setwd( "C:/My Directory/wwow/" ) | |
path.to.7z <- normalizePath( "C:/Program Files (x86)/7-zip/7z.exe" ) | |
library(stringr) | |
library(downloader) | |
library(raster) | |
library(rasterVis) | |
source_url( |
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 file containing SAS input procedure | |
SASinput <- readLines(file.choose()) | |
##find the first INPUT line | |
firstline<-min(grep("INPUT @1",toupper(SASinput))) | |
##find the first semicolon ending that input line | |
a<-grep(";",toupper(SASinput)) | |
lastline<-min(a[a>firstline]) |
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
#replace my birthday with yours | |
birthday <- strptime(c("8.18.1982"), format = "%m.%d.%Y", tz="EST") | |
#r counts everything in seconds, so this code multiplies by 60 seconds in a minute, 60 minutes in an hour, 24 hours in a day. | |
days <- function(u) { | |
x <- u * 60 * 60 * 24 | |
return(x) | |
} | |
#change these numbers to whichever days you'd like to see, separated by commas |
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(snowfall) | |
bigProcess <- function( x ) { | |
mean( replicate ( 10^6 , max( rnorm( 100 , x ) ) ) ) | |
} | |
#run the function twice in parallel | |
start <- Sys.time() | |
sfInit(cpus=2,type='SOCK',parallel=TRUE) | |
sfSapply( c(1,5) , bigProcess ) |
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
#three reasons to use R- | |
#it's free | |
#it's open source- package system | |
#it's a programming language for statistics. | |
x <- 1:5 |
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
# calculate the percent of fractions that are repeating vs. non-repeating | |
# install stringr if you don't already have it | |
#install.packages("stringr") | |
library( stringr ) | |
options( digits=22 ) | |
# this program looks at.. | |
# 1/1, 1/2, 1/3, 1/4.. up to 1/x |
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 large csv into SQL DB | |
######################################## | |
#set to the number of GB of RAM on computer | |
gbram <- 0.5 | |
#set to CSV file directory | |
setwd("C:\\American Community Survey\\2009\\") |
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
#roger peng's listlabeling challenge from | |
#http://simplystatistics.tumblr.com/post/11988685443/computing-on-the-language | |
#create three example variables for a list | |
x <- 1 | |
y <- 2 | |
z <- "hello" | |
#create the function | |
makeList <- function(...) { |
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
title = "Let it be" | |
wow = "words of wisdom" | |
Verse.1 = | |
c( "When I find myself in times of trouble" , | |
"Mother Mary comes to me" , | |
paste( "Speaking" , wow ) , | |
title ) | |
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) | |
url <- "http://www.paperbackswap.com/api/v1/index.php?RequestType=RecentlyPosted&Limit=100" | |
u <- xmlParse( url ) | |
v <- getNodeSet( u , "/Response/Books/Book/ISBN-10" ) | |
w <- sapply( v , xmlValue ) |
OlderNewer