Question

In: Statistics and Probability

3. R has a built-in character vector of US State names, state.name. Use this character vector...

3. R has a built-in character vector of US State names, state.name. Use this character vector and R's character functions to answer the following questions.Show R code

(a) List all the US State names that are more than one word. How many are there?

(b) What is the longest US State name(s) (including spaces) and how long is it?

(c) What is the longest single word US State name and how long is it?

(d) List all the US State names, where all of the upper and lower case “a"s are replaced with a capital “Z".

Solutions

Expert Solution

Data sets related to the 50 states of the United States of America.

Usage

state.abb
state.area
state.center
state.division
state.name
state.region
state.x77
Details

R currently contains the following “state” data sets. Note that all data are arranged according to alphabetical order of the state names.

state.abb:

character vector of 2-letter abbreviations for the state names.

state.area:

numeric vector of state areas (in square miles).

state.center:

list with components named x and y giving the approximate geographic center of each state in negative longitude and latitude. Alaska and Hawaii are placed just off the West Coast.

state.division:

factor giving state divisions (New England, Middle Atlantic, South Atlantic, East South Central, West South Central, East North Central, West North Central, Mountain, and Pacific).

state.name:

character vector giving the full state names.

state.region:

factor giving the region (Northeast, South, North Central, West) that each state belongs to.

state.x77:

matrix with 50 rows and 8 columns giving the following statistics in the respective columns.

Population:

population estimate as of July 1, 1975

Income:

per capita income (1974)

Illiteracy:

illiteracy (1970, percent of population)

Life Exp:

life expectancy in years (1969–71)

Murder:

murder and non-negligent manslaughter rate per 100,000 population (1976)

HS Grad:

percent high-school graduates (1970)

Frost:

mean number of days with minimum temperature below freezing (1931–1960) in capital or large city

Area:

land area in square miles


Related Solutions

Using built in R functions to calculate mean and standard deviation. Simulate the X vector with...
Using built in R functions to calculate mean and standard deviation. Simulate the X vector with a length of 50 from a normal distribution with mean 2 and variance 1. Using a for() loop, create 100 different confidence intervals and also create a variable that keeps a count of how many of these confidence intervals contain the true mean 2. Hint: Use If/else statement to keep track of whether the confidence interval contains the true mean or not within the...
a. In R there is an built in data frame Nile. This has the annual flow...
a. In R there is an built in data frame Nile. This has the annual flow in river Nile for year 1871 to 1971. Produce a time series plot. Print graph(s). b. add the title as "Nile River Annual Flow", x axis label as "Year" and y axis label as "Flow". Print graph(s). c. Add a horizontal line showing the average flow over these years. Print graph(s). d. Add text as: "Average Flow:" with the calculated average flow on the...
Use R code Create a vector V with 8 elements (7,2,1,0,3,-1,-3,4): Transform that vector into a...
Use R code Create a vector V with 8 elements (7,2,1,0,3,-1,-3,4): Transform that vector into a rectangular matrix A of dimensions 4X2 (4- rows, 2-columns); Create a matrix transpose to the above matrix A. Call that matrix AT; Calculate matrix products: A*AT and AT*A. Present the results. What are the dimensions of those two product matrices; Square matrixes sometimes have an inverse matrix. Try calculating inverse matrices (or matrixes, if you prefer) of above matrices (matrixes) A*AT and AT*A; Extend...
Use R functions search and objects to find all possible R built-in functions related to exp...
Use R functions search and objects to find all possible R built-in functions related to exp distribution. rexp should be one of them. dexp is another one. Explain what the following two lines of codes do: curve(dexp, from=0, to=4)
Instructions tell you how to get the data in R R has built in dataset called...
Instructions tell you how to get the data in R R has built in dataset called Iris. This famous (Fisher's or Anderson's) iris data set gives the measurements in centimeters of the variables sepal length and width and petal length and width, respectively, for 50 flowers from each of 3 species of iris. The species are Iris setosa, versicolor, and virginica. We are interested in estimating the length of Petal (Y) using the length of Sepal (X). First, load the...
Determine if the vector(s), polynomial(s), matrices are linearly independent in R^3, P3(R), M 2x2 (R). Show...
Determine if the vector(s), polynomial(s), matrices are linearly independent in R^3, P3(R), M 2x2 (R). Show algebraically how you found your answer. a. < 2, 1, 5 > , < -2, 3, 1 > , < -4, 4, 1 > b. x^3 - 3x^2 + 2x +1, -2x^3 + 9x^2 -3, x^3 + 6x c. | 1 2 | | -3, -1 | | -4  2 | , | 2 1|
R has a number of datasets built in. One such dataset is called mtcars. This data...
R has a number of datasets built in. One such dataset is called mtcars. This data set contains fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973-74 models) as reported in a 1974 issue of Motor Trend Magazine. We do not have to read in these built-in datasets. We can just attach the variables by using the code attach(mtcars) We can just type in mtcars and see the entire dataset. We can see the variable...
Hadoop has HDFS, which is the default built in FileSystem. Cloudera use this built-in default Java...
Hadoop has HDFS, which is the default built in FileSystem. Cloudera use this built-in default Java implementation. MapR has taken a different approach. What approach has MapR taken in its FileSystem implementation, and what may be the advantages and disadvantages of MapR's approach versus other vendors? If there are disadvantages, how can they be addressed? Look at the advantages and disadvantages from user, developer, administrator and risk perspective.
Considering a Character vector called statusDesc=c(“senior”,”sophomore”,”junior”,”freshman”). Write R code(s) to create a factor called statusFac that...
Considering a Character vector called statusDesc=c(“senior”,”sophomore”,”junior”,”freshman”). Write R code(s) to create a factor called statusFac that will take statusDesc as an argument and has four levels in the order of “freshman,” ”sophomore,” ”junior,” and “senior.” Use the following codes to generate 10 random numbers to represent 10 random ages. set.seed(1) ages=rnorm(10,24,24) Based on the variable ages, use cut() to create a factor called ageFac that has 4 levels “child”,”teen”,”adult”, and “senior”.   The corresponding age ranges are (3,13],(13,18],(18,60],and (60,120]. For example,...
The State of DeNile built a new toll road 3 years ago for $900 million. The...
The State of DeNile built a new toll road 3 years ago for $900 million. The state can charge tolls on the road for the next 20 years and expects to spend $3 million per year on maintenance and toll collection. Toll revenue is expected to be $80 million per year. The state has recently received an offer from the Otto Corporation to lease the road for 20 years. The company will pay DeNile $1 billion and will receive exclusive...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT