Question
Reading chapter : R Functions Used In This Chapter Chapter 5 c() Combines data elements together.
Reading chapter : R Functions Used In This Chapter
Chapter 5
c() Combines data elements together.
<- Indicates an assignment arrow.
data.frame() Makes a dataframe from separate vectors.
head() Lists the first row in a dataframe.
str() Reports the structure of a data object.
summary() Reports data modes/types and a data overview.
tail() Lists the last row of a dataframe.
$ Use to address a column by name.
Gather some basic "demographic" information from about five friends or family members and then enter those data into a dataframe using the appropriate R commands.
2. Finally, summarize the contents of the dataframe, again using the appropriate R commands. Keep the demographics "light" to avoid getting too personal.
3. For each person report (1) the number of pets that they have (dogs, cats, etc.); (2) their birth order in their family (i.e., 1 for first born, etc.); and (3) the number of siblings they have.
4. Collect the necessary data from your friends and family members; write, test, and submit the necessary code in R to accomplish the following:
- Create three vectors of integers (whole numbers) as described above, using the c( ) (concatenate/combine) command to store data reported by group members, with these variable names: Pets, Order, and Siblings.
- Also create a vector of user IDs for the friends and family members.
- Bind those four vectors together into a dataframe called myFriends. (Just as we did in Chapter 5 with myFamily-LEARN: Rows & Columns)
- Use the appropriate R command to report the structure of your dataframe as well as a summary of the data (with minimums, means, maximums, etc. as shown on page 39). The result should show, "X obs. Of 4 variables," where X is the number of friends and family members who reported their data.
- Use the $ notation explained on page 39 to list all of the values for each of the variables in the myFriends dataframe (e.g. myGroup$Pets).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started