Skip to content

Instantly share code, notes, and snippets.

@rogerallen
Created January 24, 2012 15:53
Show Gist options
  • Save rogerallen/1670804 to your computer and use it in GitHub Desktop.
Save rogerallen/1670804 to your computer and use it in GitHub Desktop.
Roger's Utility Functions for R
# Roger's Utility Functions for R
#
# source("Documents/Devel/R/utils.R")
#
isMac <- function()
{
x <- Sys.info()[1]=="Darwin"
x
}
# http://personality-project.org/r/Rfunc/read.clipboard.R
#
# Read clipboard from Excel for use as table
# (copy range in Excel, then run this function)
# foo <- readClipboardExcel()
# names(foo)
#
tableFromClipboardExcel <- function()
{
if(isMac()) {
x <- read.table(pipe("pbpaste"),header=TRUE,sep="\t")
} else {
x <- read.table(text=readClipboard(), sep="\t", header=T)
}
x
}
# read csv from url
tableFromUrlCsv <- function(url,UPW) {
myCsv <- getURL(url,ssl.verifypeer = FALSE,userpwd=UPW)
myData <- read.csv(textConnection(myCsv))
myData
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment