Reading data from csv file and creating a data frame mydata
mydata <- read.table("~/Bootcamp/Untitled-spreadsheet.csv", header=TRUE, sep=";", dec=",")
head(mydata)
## gender genderLooking Age Name count.pict counts_profileVisits verified
## 1 0 1 25 daeni 4 8279 No
## 2 0 1 22 italiana 92 5 663 No
## 3 0 1 21 Lauraaa 4 1369 No
## 4 0 none 20 Qqkwmdowlo 3 22187 No
## 5 0 1 21 schaessie {3 12 35262 No
## 6 0 1 24 Baby dee 18 7339 No
Description: The data set contains user profile infos of female users of the website Lovoo.The data set was gathered during spring 2015 (April) - Gender: 1:Male , 0:Female - Gender looking: Users looking to date other genders - Age : Age in years of users - Name : Username of the profile - Count Pict : Number of photos on the profile - Count Profile Visits: Number of visits on a profile in a month - Verified : Whether profile is verified or not
Allocating F for Females where it is mentioned the gender is 0
mydata$GenderNew <- factor(mydata$gender,
levels = 0,
labels = "F")
Giving an Id to all users in the data frame
mydata$Id <- seq.int(nrow(mydata))
Arranging the data so Id comes first
mydata1 <- mydata[c(9,8,2,3,4,5,6,7)]
Putting M for males where the gender mentioned is 1
mydata1$genderLnew<- factor(mydata1$genderLooking,
levels = 1,
labels = "M")
Removing those users who wants to date both genders or not any gender and arranging the data in more readable format
mydata2 <- drop_na(mydata1)
mydata2 <- mydata2[c(1,2,9,4,5,6,7,8)]
summary(mydata2[,c(4,6,7)])
## Age count.pict counts_profileVisits
## Min. :19.00 Min. : 1.000 Min. : 52
## 1st Qu.:20.00 1st Qu.: 4.000 1st Qu.: 6554
## Median :22.00 Median : 7.500 Median :12692
## Mean :21.92 Mean : 9.674 Mean :17733
## 3rd Qu.:24.00 3rd Qu.:13.000 3rd Qu.:27126
## Max. :26.00 Max. :30.000 Max. :54332
The average age of the users is 21.92 years.The youngest user is of 19 years old while the oldest is 26 years old.Half of the users are below 22 years old and the other half are older than 22 years.
On average a user has 9.67 photos on her profile.The maximum photos a user has is 30 while the minimum is 1.Half of the users have more than 7.5 photos on her profile while the other half has less than 7.5 photos.
On average a profile has 17733 visits on her profile in a month.The maximum visits on a profile is 54332 while the minimum visits are just 52.Half of the users have more than 12692 visits in a month while the other half has less than 12692 visits.
scatterplot(y = mydata2$counts_profileVisits,
x = mydata2$count.pict,
ylab = "No. of Profile visits in a month",
xlab = "No of photos on a profile",
smooth = FALSE ,
regLine = F)
This scatter plot shows that on average users having less than 15 photos are getting more visits in their profile
Importing data set from csv file in data frame mydata21
mydata21 <- read.table("~/Bootcamp/Task 2/Body mass.csv", header=TRUE, sep=";", dec=",")
head(mydata21)
## ID Mass
## 1 1 62.1
## 2 2 64.5
## 3 3 56.5
## 4 4 53.4
## 5 5 61.3
## 6 6 62.2
Description: Mass : Weight of student in kg ID: ID of the student
summary(mydata21[,-1])
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 49.70 60.23 62.80 62.88 64.50 83.20
The average weight is 62.88 kg. Half of the students weigh less than 62.8 kg and the other half weigh more than 62.8 kg. 25% of students weigh less than 60.23 kg and 75% of students weigh less than 64.5 kg
hist(mydata21$Mass,
main = "Distribution of the weight",
ylab = "No.of students",
xlab = "Weight of the students in kg",
breaks = seq(0, 100, 10),
)
Creating a random sample of 31 students from mydata21
mydata22 <- mydata21[sample(nrow(mydata21), 31), ]
Testing the hypothesis 𝐻0:𝜇=59.5
t.test(mydata22$Mass,
mu=59.5,
alternative = "two.sided")
##
## One Sample t-test
##
## data: mydata22$Mass
## t = 1.9515, df = 30, p-value = 0.0604
## alternative hypothesis: true mean is not equal to 59.5
## 95 percent confidence interval:
## 59.39956 63.91657
## sample estimates:
## mean of x
## 61.65806
𝐻0:𝜇=59.5 kg. Here p=0.107 % which is less than alpha = 5%. Therefore we reject 𝐻0
Calculating coefficient of correlation r
t=2.16
r=sqrt(t*t/{t*t+32})
round(r,1)
## [1] 0.4
Here r=0.4 i.e it is having medium effect.It can be said that on average the weight of the Ninth graders have increased to 62.88 kg
mydata31 <- read_xlsx("~/Bootcamp/Task 3/Apartments.xlsx")
head(mydata31)
## # A tibble: 6 × 5
## Age Distance Price Parking Balcony
## <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 7 28 1640 0 1
## 2 18 1 2800 1 0
## 3 7 28 1660 0 0
## 4 28 29 1850 0 1
## 5 18 18 1640 1 1
## 6 28 12 1770 0 1
Description:
mydata31$ParkingNew <- factor(mydata31$Parking,
levels =c(0,1),
labels=c("No","Yes"))
mydata31$BalconyNew <- factor(mydata31$Balcony,
levels = c(0,1),
labels=c("No","Yes"))
mydata32 <- mydata31[sample(nrow(mydata31), 31), ]
t.test(mydata32$Price,
mu=1900,
alternative = "two.sided")
##
## One Sample t-test
##
## data: mydata32$Price
## t = 1.429, df = 30, p-value = 0.1633
## alternative hypothesis: true mean is not equal to 1900
## 95 percent confidence interval:
## 1857.088 2142.912
## sample estimates:
## mean of x
## 2000
Here p=2.68 % which is less than alpha = 5%. Therefore we reject H0
scatterplot(y = mydata31$Price,
x = mydata31$Age,
ylab = "Price",
xlab = "Age",
smooth = FALSE ,
regLine = T)
scatterplotMatrix(mydata31[,c(1,2,3)],
smooth = FALSE)