If you haven’t already, you will need to download and install R and Rstudio from the following page: https://posit.co/download/rstudio-desktop/
Before you begin working with RStudio, you need to be sure that you’ve installed the packages that you need to perform the operations you desire.
For basic statistics, you will need to install the fBasics package. Follow these steps:
Now that you’ve installed the package you need to perform basic descriptive statistics, it is time to import your data. Complete the following steps:
The next step is to attach the file. In this step, R is given access to perform operations on the data. It is a good idea to type your commands into the text area (upper left window) then click on Run. When you click on Run, you’ll see the command executed in the console window (lower left window). The reason for following this procedure is to keep a record of what you’ve typed so you can save it or examine it for issues (debug your commands).
To attach the file, type the following:
attach(filename)
As you begin to type the filename, RStudio will automatically complete the file name for you. This is a great feature to be aware of as you work with variable names as well.
Now you will need to let RStudio invoke the library of tools that you want to apply. Since we have just installed fBasics, you will type the following:
library(fbasics)
To view the descriptive statistics for one variable, use the following command:
summary(variable)
As you type the name of the variable, RStudio will provide you with a selection to choose from so you can select the correct variable.
To view the descriptive statistics for ALL variables in the file, type the following:
basicStats(data.frame(variable1, variable2, …)
Please note, that if you get values in scientific notation, you can use the following command to put the numbers into normal numerical format:
options(scipen=999)
© Unity Environmental University 2025. “America’s Environmental University.™”