**View:**

**Sorted by:**

### How to Work with Non-CSV Data Files in R

Despite the fact that CSV (comma-separated values) files are very widely used to import and export data in R, they aren’t always the most appropriate format. Some data formats allow the specification of [more…]

### How to Get Your Data Out of R

For the same reason that it’s convenient to import data into R using CSV (comma-separated values) files, it’s also convenient to export results from R to other applications in CSV format. To create a CSV [more…]

### How to Add Color and a Key to Lattice Charts in R

Many lattice graphics types in R — but bar charts in particular — tend to display multiple groups of data at the same time. Usually, you can distinguish different groups by their color or sometimes their [more…]

### How to Determine a Data Structure in R

The first decision you have to make before analyzing your data is how to represent that data inside R. If your data has only one dimension, then you already know that vectors represent this type of data [more…]

### How to Debug Your Code in R

Once you have written your code in R, it is important to know how to debug it. To err is human, and programmers fall into that “human” category as well. Nobody manages to write code without errors, so [more…]

### How to Read Errors and Warnings in R

If something goes wrong with your code, R tells you. We have to admit it: These error messages can range from mildly confusing to completely incomprehensible if you’re not used to them. But it doesn’t [more…]

### How to Know When to Care About Warnings in R

Errors and warnings have different functions in R You can’t get around errors, because they just stop your code. Warnings on the other hand are a whole different beast. Even if R throws a warning, it continues [more…]

### How to Hunt for Bugs in R

Hunting for Bugs in R can sometimes be a tricky situation. Although the error message always tells you which line of code generates the error, it may not be the line of code where things started going [more…]

### How to Tell R which Function to Debug

You can step through a function after you tell R you want to debug it using the debug() function, like this: [more…]

### How to Step Through Debugging an R Function

You can step through a function after you tell R you want to debug it using the debug() function. From then on, R will switch to the browser mode every time that function is called from anywhere in R, [more…]

### How to Generate Your Own Error Messages in R

Generating your own messages may sound strange, but you can actually prevent bugs in R by generating your own errors. Remember the logic error in the logitpercent [more…]

### How to Fix Data Reading Errors in R

Probably the most common mistakes in R are made while reading in data from text files using read.table()or read.csv(). Many mistakes result in R throwing errors, but sometimes you only notice something [more…]

### How to Identify and Correct Dropped Dimensions in R

Every function in R expects your data to be in a specific format. That doesn't mean simply whether it's an integer, character, or factor, but also whether you supply a vector, a matrix, a data frame, or [more…]

### How to Work with Factors and Numeric Vectors in R Models and Calculations

If you work with factors in R that have numeric values as levels, you have to be extra careful when using these factors in models and other calculations. For example, you convert the number of cylinders [more…]

### How to Use the R Help Files

Sometimes you don’t know the exact function to use in R. Other times, you may know exactly what you need. Either way, the R Help Files can be, well…helpful. [more…]

### How to Search the Web for Help with R

Sometimes the built-in R Help simply doesn’t give you that moment of inspiration to solve your problem. When this happens, it’s time to tap into the information available on the web. [more…]

### How to Find Help Using R Mailing Lists

The R Development Core Team actively supports four different mailing lists. At the R mailing list website, you can find up-to-date information about these lists, as well as find links to subscribe or unsubscribe [more…]

### How to Access Alternative Resources for Help with R

Sometimes getting help with R requires you to be a little creative. You may need to access resources that are not on your traditional list of where you usually find help. However, the following options [more…]

### How to Make a Minimal Reproducible Example to Get Help with R

When you ask the R community for help, you’ll get the most useful advice if you know how to make a minimal reproducible example. A *reproducible example* [more…]

### How to Provide the Right Information in an R Minimal Reproducible Example

One of the hardest parts of producing an R minimal reproducible example is to keep it minimal. Another is making sure that you provide the necessary information so your problem is indeed reproducible. [more…]

### How to Recognize and Fix List Errors in R

Although lists help with keeping data together and come in very handy when you’re processing multiple datasets in R, they can cause some trouble as well. [more…]

### How to Use the Formula Interface in R

Another very important idea in R is the formula interface. The formula interface allows you to concisely specify which columns to use when fitting a model, as well as the behavior of the model. [more…]

### How to Melt Data to Long Format in R

When using R, consider the words *wide* and *long* as visual metaphors for the shape of your data. In other words, wide data tends to have more columns and fewer rows compared to long data. The reshape package [more…]

### How to Cast Data to Wide Format in R

If you have a *molten dataset* (a dataset in long format), you’re ready to reshape it with R. To illustrate that the process of reshaping keeps all your data intact, try to reconstruct the original: [more…]

### How to Work With Dates in R

R has a range of functions that allow you to work with dates and times. The easiest way of creating a date is to use the as.Date() function. For example, you write the opening day of the 2012 London Olympic [more…]