Week 1 Drill

Problem 1

Here is an excerpt from the baby-name data in "DCF::BabyNames".

name sex count year
Taffy F 19 1970
Liliana F 162 1973
Stan M 55 1975
Nettie F 45 1978
Kateria F 8 1980
Nataki F 5 1982
Danyell M 13 1984
Ahmet M 6 1986

For each of the following, say whether the variable is quantitative or categorical:

  • Taffy:
  • year:
  • sex:
  • name:
  • count:

Problem 2

Newcomers often get confused about the difference between a quoted character string and an object name. You’re going to explore the difference using the View() function. View() lets you see the contents of objects.

  1. Look briefly at the documentation, via the help() function, for the data table msleep (in the ggplot2 package).
  2. Look at the data table itself: View( msleep )
  3. Now do the same thing, but using the quoted character string "msleep" rather than the name of the object. That is, `View( “msleep” ).

In your own words, briefly explain the difference between msleep and "msleep".

Problem 3

Bring into your R session the data table named WorldCities from the DCF package. Use View( WorldCities ) to look at the data.

  • How many cases are there?
  • What are the variables?
  • Using the documentation provided by help(), say what the date variable means.

Problem 4

There are several small, example data tables in the ggplot2 package. Look at the msleep data table by using the View() function with the name of the object as an argument.

  • What is the meaning of the brainwt variable?
  • How many cases are there?
  • What is the real-world meaning of a case?
  • What are the levels of the vore variable?

Problem 5

There are several small, example data tables in the datasets package. Look at the Seatbelts data table using the View() function and the name of the object as an argument.

  • What is the meaning of the front variable?
  • How many cases are there?
  • What is the real-world meaning of a case?
  • How many letters are there in a typical entry for country?

Problem 6

Say what content is associated each of the following filename extensions.

.csv

.Rmd

.jpg

.Rdata

.docx

.html

.ppt

.png

.txt

.xls

Problem 7

What is the path name of the files in this directory?

Directory contents

Problem 8

Which characters can be used in an object name?

Problem 9

Here are a few characters: . , ; _ - ^ [space] ( )

  • Which of those characters can be used in the name of an R object?

  • Which of those characters can be used in a quoted character string?

Problem 10

The date() function returns an indication of the current time and date.

  • What arguments does date() take? How did you find out?
  • What kind of object is the result from date().

Problem 11

For each of the following assignment statements, say what is the mistake.

  • ralph <- sqrt 10

  • ralph2 <-- "Hello to you!"

  • 3ralph <- "Hello to you!"

  • ralph4 <- "Hello to you!

  • ralph5 <- date()

Problem 12

These questions should be easy to answer if you use the appropriate commands to load, view, or get documentation on the datasets.

  • How many variables are there in CountryData?
  • What does the variable tfat measure in the NHANES data table?
  • How many cases are there in WorldCities?
  • What’s the third variable in BabyNames?
  • What are the codes for the levels of the categorical variable party in the registeredVoters data table, and what does each code stand for?

Please use the comment system to make suggestions, point out errors, or to discuss the topic.

comments powered by Disqus