# Statistics

View:
Sorted by:

### How to Create a Data Frame from Scratch in R

The conversion from a matrix to a data frame in R can’t be used to construct a data frame with different types of values. If you combine both numeric and character data in a matrix for example, everything

### How to Work with Variable Names in R

Variables in a data frame in R always need to have a name. To access the variable names, you can again treat a data frame like a matrix and use the function

### An Overview of the Base Plot Function in R

The base graphics function to create a plot in R is simply called plot(). This powerful function has many options and arguments to control all kinds of things, such as the plot type, line colors, labels

### How to Add Points to a Plot in R

To illustrate some different plot options and types, like points and lines, in R, use the built-in dataset faithful. This is a data frame with observations of the eruptions of the Old Faithful geyser in

### How to Add Lines to a Plot in R

In R, you add lines to a plot in a very similar way to adding points, except that you use the lines()function to achieve this.

But first, use a bit of R magic to create a trend line through the data, called

### How to Create Different Plot Types in R

The plot function in R has a typeargument that controls the type of plot that gets drawn. For example, to create a plot with lines between data points, use

### How to Add Titles and Axis Labels to a Plot in R

You can easily add the main title and axis labels with arguments to the plot() function in R to enhance the quality of your graphic.

### How to Change Plot Options in R

To convey a more powerful and impactful message to the viewer, you can change the look and feel of plots in R using R’s numerous plot options.

You can find all the documentation for changing the look and

### How to Put Multiple Plots on a Single Page in R

To put multiple plots on the same graphics pages in R, you can use the graphics parameter mfrow or mfcol. To use this parameter, you need to supply a vector argument with two elements: the number of rows

### How to Save Graphics to an Image File in R

If you want to publish your results, you have to save your plot to a file in R and then import this graphics file into another document. Much of the time however, you may simply want to use R graphics

### How to Create a Lattice Plot in R

To explore lattice graphics in R, first take a look at the built-in dataset mtcars. This dataset contains 32 observations of motor cars and information about the engine, such as number of cylinders, automatic

### How to Print and Save a Lattice Plot in R

You need to know three essential things about lattice plots in R: how to assign a lattice plot to an object, how to print a lattice plot in a script, and how to save a

### Base, Grid, and Lattice Graphics in R

Perhaps confusingly, the standard distribution of R actually contains three different graphics packages. Once understood, these tools will greatly enhance the impact of your work in R.

### How to Change Lattice Plot Options in R

R has a very good reputation for being able to create publication-quality graphics, however if you want to use your lattice graphics in reports or documents, you’ll probably want to change the plot options

### How to Make Common Graphs with Lattice in R

While the lattice graphics package features a long list of graphic types in R, bar charts and box-and-whisker plots are among the most commonly used.

### How to Use Data in Tall Format in Lattice Plots in R

When you have data in tall format in R, you can easily use lattice graphics to visualize subgroups in your data. For instance, what happens when you want to analyze more than one variable simultaneously

### How to Configure R

Apart from accepting the options in the installation procedure for R, you can change a number of startup options by adapting the Rprofile.site file. This file is located inside the installation directory

### How to Install and Configure RStudio

RStudio is a relatively new and shiny editor for R. It’s easy to use, it has a decent Help page, it has very good support, and it incorporates R in a practical way. Of course, you’re free to work with

### How to Install and Load ggplot2 in R

Because ggplot2 isn’t part of the standard distribution of R, you have to download the package from CRAN and install it.

### How to Use Layers in ggplot2 in R

The basic concept of a ggplot2 graphic in R is that you combine different elements into layers. Each layer of a ggplot2 graphic contains information about the following:

### ggplot2 in R: How to Map Data to Lines, Points, Symbols and More

After you’ve told ggplot() what data to use in R, the next step is to tell it how your data corresponds to visual elements of your plot. This mapping between data and visual elements is the second element

### How to Define the Data Display Mode in R

A ggplot2 geom in R tells the plot how you want to display your data. For example, you use geom_bar() to make a bar chart. In ggplot2, you can use a variety of predefined geoms to make standard types of

### How to Create Subsets of Your Data in R

Often the first task in data processing is to create subsets of your data in R for further analysis. You’re already familiar with the three subset operators:

### How to Subset Data Frames in R

Now that you’ve reviewed the rules for creating subsets, you can try it with some data frames in R. You just have to remember that a data frame is a two-dimensional object and contains rows as well as

### How to Take Samples from Data in R

Statisticians often have to take samples of data and then calculate statistics. Taking a sample is easy with R because a sample is really nothing more than a subset of data. To do so, you make use of