Skip to content

Instantly share code, notes, and snippets.

View nharrell04's full-sized avatar

Nick nharrell04

View GitHub Profile
best <- function(state, outcome){
outcome_data <-read.csv("outcome-of-care-measures.csv", colClasses = "character")
##
state_options <- outcome_data[,7]
if(state %in% state_options){}
else
{
stop("invalid state")
}
if(outcome !="heart attack"){break}
pollutantmean <- function(directory, pollutant, id = 1:332) {
files <- sprintf("%s/%03d.csv", directory, id)
measurements <- c()
for (file in files) {
frame <- read.csv(file)
file_measurements <- frame[[pollutant]]
measurements <- c(measurements, file_measurements)
}
mean(measurements, na.rm = TRUE)
}
pollutantmean <- function(directory, pollutant, id) {
currentdir <- getwd()
if (currentdir != ~directory){
setwd(~directory) ## returns Error in setwd(directory): cannot change working directory
}
monitorinfo <-read.csv(id)## takes id and reads that .CSV file
## will monitorinfo work if given a sequence e.g, 1:10?
pollutantcol <- monitorinfo[,pollutant]
pollutantcolnoNAs <- pollutantcol[!is.na(pollutantcol)] ## gets rid of NAs
meanpol <- mean(pollutantcolnoNAs)
makeVector <- function(x = numeric()) {
m <- NULL
set <- function(y) {
x <<- y
m <<- NULL
}
get <- function() x
setmean <- function(mean) m <<- mean
getmean <- function() m
list(set = set, get = get,
> setwd("~/Downloads")
> hw1_data <- read.csv("hw1_Data.csv", header = TRUE)
> colnames(hw1_data)
[1] "Ozone" "Solar.R" "Wind" "Temp" "Month" "Day"
> tworows <- hw1_data[1:2,]
> tworows
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
> nrow(hw1_data)
oztemp <- hw1_data[,hw1_data$Ozone > 31 && hw1_data$Temp > 90] ## hw1_data is the full data fram I'm working with
## I'm trying to get all of the rows where the value in the Ozone column is above 32 and the values in the Temp column are above 90
## instead oztemp is a data frame w/ 0 columns and 153 rows (there are 153 rows in the data frame)
<?php // login.php
$db_hostname = 'localhost'; // whatever hostname actually is
$db_database = 'law_lib_guides';
$db_username = 'username'; //possibly root?
$db_password = 'password'; // also possibly root
?>
<?php
require_once 'login.php';
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database, $db_server)
or die("Unabale to select database: " . mysql_error());
$url_query = "SELECT url FROM guides";
from urllib2 import urlopen
def gethtml(url):
return urlopen(url).read()
def extract(url):
html = gethtml(url)
return html.find('guides')
# finds the location of the first mention of "guides"
from urllib2 import urlopen
from hashlib import md5
from collections import namedtuple
class research_guides:
def __init__(self, url, hashes, title, author, subject):
self.url= url
self.hashes = hashes
self.title = title
self.author = author