R uses vectors and data frames to store data. A data frame is two dimensional matrix that can contain all different types of data (categorical, ordinal, discrete numeral, continuous numeral, binary and free text). Each column (vertical) contains a variable and each row (horizontal) a case or patient.
To enter data manually, make sure the Data Viewer in JGR is open. If the Data Viewer is not visible, make the Console the active window and select from the menu bar: Packages & Data and then Data Viewer.
If no data are loaded, the Data Viewer looks like this:
(If a data frame is open, the data viewer will show that data frame. To create a new data frame, make sure the Data Viewer window is active and select File and then New Data from the menu bar).
This will create a new Data Set called heights:
Select Variable View:
Change the default name Var1 to an appropriate name for the variable (for example height). Also define the type of data. The default of Logical can be changed to the following data types:
- Character (text)
- Factor (different groups, categorical variable)
- Double (double precision floating point, for decimal numbers)
- Integer (for integer numbers, discrete numeral data)
- Logical (a binary variable, true / false, yes / no etc)
Select the Data View tab and the data can be entered. For example enter the following heights:
You can now use the data for analysis. Selecting the Console will change the menu bar to perform statistical analysis, create plots etc.
The data frame can also be saved by selecting File and then Save Data from the menu bar when the Data Viewer is the active window.
A previously saved data frame can also be loaded by selecting File and then Save Data from the menu bar when the Data Viewer is the active window.
Data can be entered directly as a vector in the console using the c command and then create a data frame: