#1
credit <- read.csv("/var/folders/0m/3pfyxq_51d3ccbk96pflc2d80000gn/T//RtmpsLUeqr/databc549ea353b", dec=",")

#2
#credit$amount
hist(x=credit$amount, col="blue", border="green", ylim = c(0, 500))
abline(v=2319.5,col="black")
text(x=2319.5, y=400, adj= 0, labels= paste('Median = ', median(credit$amount)))

#3
#credit$age
#credit$amount
plot(x=credit$age, y=credit$amount, main= "Borrower age and loan amount", xlab= "Borrower age", ylab= "Loan amount (inDM)", xlim= c(20,80), ylim= c(0,20000), col="pink", pch= 8)

#4
#install.packages("beanplot")
library("beanplot")
#credit$years_at_residence
beanplot(amount~ years_at_residence, data=credit,
         main="number of years at residence and loan amount", 
         xlab="Years at Residence", 
         ylab="Loan amount in DM (log-transformaed", 
         xlim= c(0,5), 
         ylim= c(100, 50000), 
         col="grey")
## log="y" selected

#5
plot(x=credit$months_loan_duration, y=credit$amount, pch=8, xlab="Loan Duration (in months)", ylab="Loan amount (in DM)", col= "orange", xlim= c(0,80), ylim= c(0,15000))
abline(col="grey",h=seq(0,15000,1000),v=seq(0,80,10))
skilled<- subset(credit, months_loan_duration == 1)
points(skilled$months_loan_duration, skilled$amount, pch=16, col="purple")