'Name: Erin Dane
Course: MSCI3230'
## [1] "Name: Erin Dane\nCourse: MSCI3230"
#Question 1
Housing <- read.csv("~/Desktop/R Studios /Table2.1HousePrices-NoID.csv")
SQFT <- Housing$SqFt
BNB <- Housing$Brick
function1 <- function(x,y) {
z <- which(SQFT >= x & BNB == y)
w <- mean(Housing$Price[z])
print(paste('The average price of the home is',w))
}
function1(2000,"Yes")
## [1] "The average price of the home is 157986.956521739"
#Question 2
Housing <- read.csv("~/Desktop/R Studios /Table2.1HousePrices-NoID.csv")
SQFT <- Housing$SqFt
BNB <- Housing$Brick
NBH <- Housing$Neighborhood
function2 <- function(x,y,q) {
z <- which(SQFT >= x & BNB == y & NBH == q)
w <- mean(Housing$Price[z])
print(paste('The average price of the home is',w))
}
function2(2000,"Yes","West")
## [1] "The average price of the home is 182620"
#Question 3
Housing <- read.csv("~/Desktop/R Studios /Table2.1HousePrices-NoID.csv")
hist(Housing$Price,
main="Histogram of House Prices",
xlab="House Prices",
col="purple",
las=1,
breaks=20,)

#Question 4
Housing <- read.csv("~/Desktop/R Studios /Table2.1HousePrices-NoID.csv")
BEDR <- Housing$Bedrooms
PRICE <- Housing$Price
function3 <- function(x) {
w <- x:x
for (i in w) {
z <- which(BEDR == x)
print(mean(PRICE[z]))
}
}
function3(2)
## [1] 115260
#Question 5
Housing <- read.csv("~/Desktop/R Studios /Table2.1HousePrices-NoID.csv")
BEDR <- Housing$Bedrooms
PRICE <- Housing$Price
COUNT <- 0
function3 <- function(x) {
while (x > COUNT) {
z <- which(BEDR == x)
w <- mean(PRICE[z])
print(paste('The average price of the home is',w))
COUNT <- COUNT + x
}
}
function3(3)
## [1] "The average price of the home is 125732.835820896"