1a.
x<-seq(from=2,to=100,by=2)
rep(x)
## [1] 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38
## [20] 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76
## [39] 78 80 82 84 86 88 90 92 94 96 98 100
1b.
x<-(1:50)*2
rep(x)
## [1] 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38
## [20] 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76
## [39] 78 80 82 84 86 88 90 92 94 96 98 100
1c.
x<-cumsum(rep(2:2,50))
rep(x)
## [1] 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38
## [20] 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76
## [39] 78 80 82 84 86 88 90 92 94 96 98 100
Names <- c("Alana", "Bettie", "Consuela", "Dona", "Elaine", "Frances", "Gerri", "Helene", "Ichabod", "Jin", "Kenyatta", "Larry", "Mikahilo", "Nick", "Odin")
Sex <- c (rep("F", 8), rep("M", 7))
Grades <- round(runif(15, 50, 100))
Grades
## [1] 99 70 83 83 64 85 70 90 94 66 71 56 84 99 75
(2a) The object “Grades” was created using two functions round() and runif(). Describe how these two functions work and give examples of where you might choose to use these. round() is a code that allows you to round the vaules in its first argument to the specified numer of decimal places.You would want to use this function when you want to round data points to a certain level of specified level of precision. Where are runif() generates random deviated of the uniform distribution between min and max. We would want to use this code when we want to draw samples from our data which can be useful in simulations and model testing.
2b.
gt90<-Grades[Grades>=90]
2c.
Names[Grades<60]
## [1] "Larry"
2d.
Grades_M<-Grades[Sex=="M"]
Grades_F<-Grades[Sex=="F"]
2e.
sum(Grades_M)/length(Grades_M)
## [1] 77.85714
sum(Grades_F)/length(Grades_F)
## [1] 80.5
3a.
Pups<-read.csv("c:\\R_data\\PupTaggingData.csv",header=TRUE,sep=",")
3b.
head(Pups,1)
## Island TaggingDate ID Weight Length Girth BCI Sex Age DOB
## 1 Chirpoev 7/10/2005 Br800L 15.5 93 69 0.7419355 M NA <NA>
3c.
table(Pups$Island,Pups$Sex)
##
## F M
## Antsiferov 38 62
## Chirpoev 43 56
## Lovushki 50 50
## Raykoke 49 51
## Srednova 46 53
3d.
m<-table(Pups$Island,Pups$Sex)
m
##
## F M
## Antsiferov 38 62
## Chirpoev 43 56
## Lovushki 50 50
## Raykoke 49 51
## Srednova 46 53
4a. There are two vectors being added so 0 is being added to 3 and 2 is being added to 4 it is then recycled where 0 is added to 5 and 2 is being added to 6. This is called recycling in R studio.
4b.A vector is of similar class while a list can be of different class.
4c.attributes and Attr
4d. You can find the find a description of the type of object a function returns in the # comments.
5a. You can make text bold with two stars at the beginning and end of a statement
5b.Using one star will make the text in italics
5c. * you can use a plus sign * you can use a dash
5d. Using different numbers of hashtags will change the heading levels.