title: “WPA” author: “Sabrina Englert” date: “23. April 2015” output: html_document

Exercise 1: my data <- rnorm(100, mean = 0, sd = -1) error: space between my data correct: mydata <- rnorm(100, mean = 0, sd = -1)

data.mean <- mean(my data) error: sd cant be -1 correct: my data <- rnorm(100, mean = 0, sd = 1)

“data.mean” # Print the value of data.mean error: “” correct: datamean

Exercise 2: mixed <- c(batman, 20, superman, 10) It doesnt work becaus we cant combine numbers and characters.

Exercise 3:

celcius <- c(17, 21, 18, 21, 14)
fahrenheit <- (celcius * 9/5 + 32)

fahrenheit [1] 62.6 69.8 64.4 69.8 57.2

Exercise 4:

a<-seq(10,50,10)
d<-seq(12,14,1)
c<-seq(97,137,10)
c(a,d,c)
##  [1]  10  20  30  40  50  12  13  14  97 107 117 127 137

Exercise 5:

rep(1:5, times = 2,each = 2)
##  [1] 1 1 2 2 3 3 4 4 5 5 1 1 2 2 3 3 4 4 5 5

Exercise 6:

squares<-seq(1,10,1)
squares<-(squares)^2
mean(squares)
## [1] 38.5
median(squares)
## [1] 30.5

Exercise 7:

normal.samp<-rnorm(50,30,5)
normal.samp
##  [1] 22.53118 17.80989 24.78767 26.19031 25.71560 35.07057 32.25467
##  [8] 28.77626 23.95596 26.68790 24.59302 36.57721 18.55749 29.43384
## [15] 30.75521 30.92861 28.62736 23.96216 29.46243 32.65482 28.67543
## [22] 23.61618 28.30701 36.98846 29.79150 28.56042 34.03357 23.59128
## [29] 31.92983 31.13692 24.59813 42.82864 33.02792 33.16556 31.60911
## [36] 34.79924 34.64590 30.53744 31.36158 33.58990 34.93093 30.85004
## [43] 32.18128 33.77139 31.17379 25.71784 35.53421 29.69108 33.39894
## [50] 23.86852

Exercise 8:

normal.samp.min <- min(normal.samp)
normal.samp.min
## [1] 17.80989
normal.samp.max <- max(normal.samp)
normal.samp.max
## [1] 42.82864
runif(25, normal.samp.min, normal.samp.max)
##  [1] 18.67211 21.94315 26.19322 39.29448 37.57119 19.40998 32.07935
##  [8] 30.36978 26.29295 36.06787 34.54969 40.90472 36.48261 37.94937
## [15] 24.08440 37.29618 28.67194 38.11955 25.09915 35.80776 34.38272
## [22] 37.27373 21.21043 35.46075 35.89429

Exercise 9:

unif<-runif(1e6, 0, 10)
norm<-rnorm(1e6,0,1)
mean(unif+norm)
## [1] 4.99929