Data Frames In R

## Description

Due to its nature as a statistical analysis language, R has several data types created to store multiple of individual values. One of these types is data.fram, which is essentially a matrix with labeled columns of equal length. Data frames are used in tests where data is passed directly to the test method, such as oneway.test or confint, as opposed to methods where summary statistics are passed in.

A data frame is created using the data.frame() command, and takes the arguments value, which is a single object or set of objects combined with {c(), and/or tag=value, where tag is a custom name for that set of values. For example, to make a data frame of the first five prime numbers named primes, you would use the code data.frame(primes=c(2, 3, 5, 7, 11). In the cell, we'll make a list with 3 labeled rows: data, data from some hypothetical study, group, the group or treatment each sample was taken from, and ID, the number of the sample from within the group.

## Sage Cell

The NULL is not normally necessary, and is merely included to keep the cell from printing the frame twice due to the way it interacts with returned values from R code.

#### Code

``````info <- data.frame(data = c(2.1, 9.6, 2.9, 2.6, 6.8, 0.2, 4.6, 3.8, 4.7, 7.9, 8.9, 8.7, 1.1, 2.5, 3.5, 12.2, 5.2, 13.1, 12.9, 11.5),
group = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
ID = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
print(info)```
```

none

## Tags

Primary Tags:

Secondary Tags:

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

## Related Cells

Any related cells go here. Provide a link to the page containing the information about the cell.