1. Simple data frame
- Create a character vector with the names of your schoolmates
- Create a numeric vector with the ages of your classmates (make sure the order is the same as in previous exercise).
- Create a logical vector showing if your classmate owns a pet.
- Create a date vector showing your classmate's expected graduation date.Create a character vector with the city people were born.
- Name the last vector as Birthplace and add it to the data frame.
2. Factor/merge data
- Create a vector length 100 with random values between 1 and and 7.
- Create a vector length 100 with random numbers between 1 and 2
- Create a data frame to hold these two vectors
- Create a data frame with two columns, two rows. First column a sequence of numbers between 1 and 7, the second with names of the week.
- Merge the two data frames by the indexing (1:7) column.
- Create a histogram showing the frequency of week days in your data frame.
3. Matrix / Markov Chain exercise
- Create a matrix to represent the following markov process.
- After a clear day, we have a 20% chance of clouds and 30% chance of rain
- After a cloudy day, we have 40% chance of clear sky, and 30% chance of rain
- After a rainy day, we have 20% chance or clear sky and 70% chance of clouds.
- What are the chances of rain after 10 days if today is clear
- What are the chances of clouds after 2 days if today is raining
- What are the chances that it is going to keep raining in two days from today if it is raining today?
- What are the values from the equilibrium vector?
- How long (how many stages) does it take to reach an equilibrium?