Solution to Exercise 1
See if you were right in exercise 1!
Task: Data about height and weight
Use c() to create the three vectors. Here, height is in metres, weight is in kilograms, and state contains the state labels in the same order as the exercise.
height <- c(1.67, 1.8, 1.58, 1.83, 1.65,
1.74, 1.8, 1.6, 1.76, 1.8)
weight <- c(62, 78, 56, 85, 58, 70, 70, 120, 62, 90)
state <- c("NRW", "Bayern", "Sachsen", "Hessen", "Hessen",
"MV", "Hessen", "Brandenburg", "Hessen", "Berlin")
Print each vector. Run the R commands; the separate output blocks show the results. Line wrapping may vary with the width of your R console.
height
[1] 1.67 1.80 1.58 1.83 1.65 1.74 1.80 1.60 1.76 1.80
weight
[1] 62 78 56 85 58 70 70 120 62 90
state
[1] "NRW" "Bayern" "Sachsen" "Hessen" "Hessen"
[6] "MV" "Hessen" "Brandenburg" "Hessen" "Berlin"