Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I NEED ANSWER FOR EXERCISE 2 ONLY PLEASE. EITHER FULL ANSWER FOR ALL POINTS OR L

ID: 3600180 • Letter: I

Question

I NEED ANSWER FOR EXERCISE 2 ONLY PLEASE. EITHER FULL ANSWER FOR ALL POINTS OR LEAVE IT TO SOMEONE ELSE IF YOU CANNOT FINISH IT ALL AND THANKS IN ADVANCE


Exercise 1: Determine if the task given below is a machine learning task and if it is Descriptive or Predictive 1. Finding if a football team will win or lose Finding the customers of a company based on their gender 3. 4. 5. Finding if person will live past the age of 100 Sorting a student database based in student ID Determining the type of trips married people usually take 6. Determning if an applicant will default on a loan Finding the topic of a collection of articles 8. Predicting if an earthquake will strike next year 9. Predicting the outcomes of tossing a (fair) pair of dices. 10. Finding if the heart rate of a patient is abnormal Exercise 2: Add a comment with your name and T number. Tom Honk T00463354 Calculate the square root of 729. Find the log base 10 of 100 Divide 10 by 3, quotient of 10 by 3, remainder of 10 by 3 -Assign 10 to A -Create a new variable B with value 1947 -find the datatype of A and B, print the value of A and B -Convert B from a numeric variable to a character variable. -Write the commands to get documentation on the function "merge" and examples of its use. A working directory is the reference directory from which R has direct access to read in files. You can read in and write files directly to the working directory without using the full file path. The directory names should be separated by forward slash ) or double back slash (U) instead of Q) even for a windows PC. -Find the R command to display the curret working directory (similar to UNIX) -Create a new directory called RPractice and make it your working directory. -Create a vector with 10 elements, all initialized to 10 -Save your environment into a text file

Explanation / Answer

Exerice 2:

1. Add a comment with your name and T number.
#Tom Honk T00463354

2.Calculate the Square root of 729. Find the log base 10 of 100

Sol: sqr=sqrt(729) # sqrt() function finding Square Root of value
print(sqr) # print sqrt(729) value
output: 27
  
lg=log10(100) # log10() function used to find log base 10 of value
print(lg) # print log base 10 of 100 value
output: 2

3. Divide 10 by 3, quotient of 10 by 3, remainder of 10 by 3

Sol: 10/3=3.33333
10%/%3=3 # calculate Quotient value of 10 by 3
10%%3=1 # calculate Remainder value of 10 by 3

4. Assign 10 to A

Sol: A=10

5. Create a new Variable B with value 1947

Sol: B=1947

6. Find the datatype of A and B, print the value of A and B

Sol: print of A and B is
print(A) # using print function to print the value
print(B)
(or)
Just type A in the console and print the value simillarly type B print the value

Data type:
using typeof() function determines a type of variable
typeof(A) # print "double"
typeof(B) # print "double"
(or)
using class() function
class(A) # print "numeric"
class(B) # print "numeric"

7. Convert B from a numeric variable to a character variable

Sol: using as.character() function to convert numeric value to character
as.character(B) # where B=1947
this will print value like this
"1947"

8. merge() function is used to merging of two data frame into cross product that is mapping first data frame values is mapping second dataframe of one by one set for example we take two data frame such as "df1" and "df2"

df1=data.frame(id=c(100,200,300,400,500),name=c('xxx','yyy','zzz','ttt','ppp'))
df2=data.frame(country=c('us','uk','aus','ger','china'),gpa=c(5.3,2.4,5.5,6.7,8.4))

merge(dataframe1,dataframe2);

merge(df1,df2)

output:

> merge(df1,df2)
id name country gpa
1 100 xxx us 5.3
2 200 yyy us 5.3
3 300 zzz us 5.3
4 400 ttt us 5.3
5 500 ppp us 5.3
6 100 xxx uk 2.4
7 200 yyy uk 2.4
8 300 zzz uk 2.4
9 400 ttt uk 2.4
10 500 ppp uk 2.4
11 100 xxx aus 5.5
12 200 yyy aus 5.5
13 300 zzz aus 5.5
14 400 ttt aus 5.5
15 500 ppp aus 5.5
16 100 xxx ger 6.7
17 200 yyy ger 6.7
18 300 zzz ger 6.7
19 400 ttt ger 6.7
20 500 ppp ger 6.7
21 100 xxx china 8.4
22 200 yyy china 8.4
23 300 zzz china 8.4
24 400 ttt china 8.4
25 500 ppp china 8.4

If any unique column between two data frames can't match for examples

df1=data.frame(id=c(100,200,300,400,500),name=c('xxx','yyy','zzz','ttt','ppp'))
df2=data.frame(id=c(100,200,300,400,500),gpa=c(5.3,2.4,5.5,6.7,8.4))

merge(df1,df2,by="id") # here id is common of both data frame "by" is specification of two data frames

output:
> merge(df1,df2,by= "id")
id name gpa
1 100 xxx 5.3
2 200 yyy 2.4
3 300 zzz 5.5
4 400 ttt 6.7
5 500 ppp 8.4

Note: not only single column more than one column we can merge(e.g.,using merge(df1,df2,by=c("id","name"...))


9. Find the R command to display the current working directory(similar to UNIX)

Sol: getwd() # This function finding Current Working directory in Windows

output: "C:/Users/xxxx/yyyyy"

10. Create a new directory called R Practice and make it your working directory

Sol: dir.create("xxx") # this is creating new directory name "xxx"

setwd("xxx") # this is set working directory to "xxx"

11. Create a vector with 10 elements, all initialized to 10

Sol: Using rep() Replicate elements of Vectors

Example:  
> x=seq(1:10)
> rep(x,10)
[1] 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5
[26] 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10
[51] 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5
[76] 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10

12. Save your environment into a text file

Sol: To Savel all Environment variable into to file using dump() function

dump(ls(),file="filename")
once you clear all envrionment variable by using rm(list=ls()) function the previous variable will be stored in "filename" that can be loaded by using
"load() function (e.g., load("filename"))