# R Dataset / Package robustbase / salinity

Webform
Help

## Description

Describes how to create a bar plot based on count data. For an example of count data, see the email50 curated data set which was taken from the Open Intro AHSS textbook (not affiliated). An example of count data in this dataset would be the spam column.

## Usage

Select one (1) column to create its barplot and then click 'Submit'. If you do not choose count data, you may get unexpected results.

Students may also be interested in creating barplots for contingency tables.

For a stacked side-by-side barplot, see the other barplot app.

Category

Webform
Help

## Usage

Select 1 (one) column from a contingency table like the Gender and Politics or VADeaths curated datasets.

If you do not choose a contingency table, you may get unexpected results. You can import a dataset if you are logged-in.

## Details

Shows the student how to create a single stacked bar plot based on a column in a contingency table.

For a basic barplot (single column) based on count data see the count data barplot app.

For a stacked side-by-side barplot see the other stacked barplot app for categorical data.

Category

Webform
Help

## Usage

Select 1 (one) column from a contingency table. If you don't have your own dataset, you can choose the Gender and Politics or VADeaths curated datasets. If a contingency table is not chosen, you may get unexpected results.

A contingency table has columns like a regular dataset, but the first row contains row names that categorize and "split-up" the dataset. An example of a contingency table would be something like this:

LIBERAL CONSERVATIVE
F 762 468
M 484 477


This contingency table is take from the Gender and Politics dataset. You can get a preview by selecting the dataset from the Curated Data dropdown above.

## Details

This app shows the student how to create a pie chart from a contingency table by hand using a Quadstat dataset.

A pie chart shows proportions of a sample or population. Each piece of a pie chart corresponds to some subset of the sample or population. In this case, we will use the contingency table rows to subset the sample.

Students may also want to view the app for creating a pie chart from count data.

Category

Webform
Help

## Usage

Click "Submit" after selecting one column to see how to compute the arithmetic mean (average) of data (vectors).

## Description

If all the values of a sample were plotted on a number line, the average would be the point in the middle that would balance the two sides.

The average is greatly influenced by outliers, meaning extreme points can pull the average to the left or right.

If we are referring to the average of population (all observations), the symbol for the average (arithmetic mean) is $\mu$.

If we are referring to the average of a sample (a subset of the population), the symbol for the average (arithmetic mean) is $\bar{x}$.

## Computing the average

Suppose we have a sample consisting of $x_1, x_2, x_3,...,x_n$. This means we have $n$ observations. Then,

$$\bar{x}=\frac{x_1, x_2, x_3,...,x_n}{n}.$$

The formula tells us that we need to add all the observations and then divide by the number of observations to compute the mean.

## Example 1

Compute the mean of $A = \{1,2,3\}$.

$$\bar{x} = \frac{1+2+3}{3} = 2.$$
Category

Webform
Help

## Usage

Select two columns which are to be used in the scatterplot. The first column clicked will be the independent variable (X-axis).

## Description

This web application describes how to create a scatterplot of two dataset variables plotted on the xy-axes.

Category

Webform
Help

## Median Value

### Description

Compute the sample median.

### Usage

median(x, na.rm = FALSE, ...)


### Arguments

 x an object for which a method has been defined, or a numeric vector containing the values whose median is to be computed. na.rm a logical value indicating whether NA values should be stripped before the computation proceeds. ... potentially further arguments for methods; not used in the default method.

### Value

The default method returns a length-one object of the same type as x, except when x is logical or integer of even length, when the result will be double.

If there are no values or if na.rm = FALSE and there are NA values the result is NA of the same type as x (or more generally the result of x[FALSE][NA]).

### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

Category

## Visual Summaries

Attachment Size
506 bytes
GNU General Public License v2.0
Documentation

## Salinity Data

### Description

This is a data set consisting of measurements of water salinity (i.e., its salt concentration) and river discharge taken in North Carolina's Pamlico Sound, recording some bi-weekly averages in March, April, and May from 1972 to 1977. This dataset was listed by Ruppert and Carroll (1980). In Carrol and Ruppert (1985) the physical background of the data is described. They indicated that observations 5 and 16 correspond to periods of very heavy discharge and showed that the discrepant observation 5 was masked by observations 3 and 16, i.e., only after deletion of these observations it was possible to identify the influential observation 5.

This data set is a prime example of the masking effect.

### Usage

data(salinity)

### Format

A data frame with 28 observations on the following 4 variables (in parentheses are the names used in the 1980 reference).

X1:

Lagged Salinity (‘SALLAG’)

X2:

Trend (‘TREND’)

X3:

Discharge (‘H2OFLOW’)

Y:

Salinity (‘SALINITY’)

### Note

The boot package contains another version of this salinity data set, also attributed to Ruppert and Carroll (1980), but with two clear transcription errors, see the examples.

### Source

P. J. Rousseeuw and A. M. Leroy (1987) Robust Regression and Outlier Detection; Wiley, p.82, table 5.

Ruppert, D. and Carroll, R.J. (1980) Trimmed least squares estimation in the linear model. JASA 75, 828–838; table 3, p.835.

Carroll, R.J. and Ruppert, D. (1985) Transformations in regression: A robust analysis. Technometrics 27, 1–12

### Examples

data(salinity)
summary(lm.sali  <-        lm(Y ~ . , data = salinity))
summary(rlm.sali <- MASS::rlm(Y ~ . , data = salinity))
summary(lts.sali <-    ltsReg(Y ~ . , data = salinity))salinity.x <- data.matrix(salinity[, 1:3])
c_sal <- covMcd(salinity.x)
plot(c_sal, "tolEllipsePlot")## Connection with boot package's version :
if(requireNamespace("boot")) { ## 'always'
print( head(boot.sal <- boot::salinity        ) )
print( head(robb.sal <- salinity [, c(4, 1:3)]) ) # difference: has one digit more
## Otherwise the same ?
dimnames(robb.sal) <- dimnames(boot.sal)
## apart from the 4th column, they are "identical":
stopifnot( all.equal(boot.sal[, -4], robb.sal[, -4], tol = 1e-15) ) ## But the discharge ('X3', 'dis' or 'H2OFLOW')  __differs__ in two places:
plot(cbind(robustbase = robb.sal[,4], boot = boot.sal[,4]))
abline(0,1, lwd=3, col=adjustcolor("red", 1/4))
D.sal <- robb.sal[,4] - boot.sal[,4]
stem(robb.sal[,4] - boot.sal[,4])
which(abs(D.sal) > 0.01) ## 2 8
## *two* typos (=> difference ~= 1) in the version of 'boot': obs. 2 & 8 !!!
cbind(robb = robb.sal[,4], boot = boot.sal[,4], D.sal)
}# boot

--

Dataset imported from https://www.r-project.org.

GNU General Public License v2.0

## From Around the Site...

Title Authored on Content type
R Dataset / Package gap / mfblong March 9, 2018 - 1:06 PM Dataset
R Dataset / Package HSAUR / aspirin March 9, 2018 - 1:06 PM Dataset
R Dataset / Package DAAG / nsw74psid3 March 9, 2018 - 1:06 PM Dataset
R Dataset / Package MASS / birthwt March 9, 2018 - 1:06 PM Dataset
R Dataset / Package robustbase / foodstamp March 9, 2018 - 1:06 PM Dataset