CREATE csv FILE
By default rad
reads csv
data files. One way to create a csv data file is by entering the data into a text editor. A more structured method is to use a worksheet application such as MS Excel, LibreOffice Calc. Place the variable names in the first row of the worksheet. Each column of the worksheet contains the data for the corresponding variable. Each subsequent row contains the data for a specific observation, such as for a person or a company. All numeric data in the worksheet should be displayed in the General format, so that the only non-digit character for a numeric data value is a decimal point. The General format removes all dollar signs and commas, for example, leaving only the pure number, stripped of these extra characters which R will not properly read as part of a numeric data value.
To create the csv file from Excel, under the File option, do a Save As and choose the csv format.
MECHANICS
Given a csv data file, read the data into an R data frame called mydata
with rad
, which first invokes one of two R statements.
Call with no arguments, as in rad()
, to invoke:
mydata <- read.csv(file.choose())
Or, call with non-null ref
option, rad("file_reference")
,
to invoke:
mydata <- read.csv("file_reference")
Then, rad
invokes the subsequent R statements: attach(mydata, warn.conflicts=FALSE)
,
head(mydata, n=3)
and tail(mydata, n=3)
. Output of these statements is
directed to the console. Also listed are the R statements invoked by rad
.
Because rad
calls the standard R function read.csv
, which just provides a wrapper for read.table
, the usual options that work with read.table
, such as row.names
also can be passed through rad
.
SPSS DATA
To read data in the SPSS .sav
format, rad
calls the read.spss
function from the foreign
package. To invoke this option, specify format="SPSS"
.
MISSING DATA
By default, rad
provides a list of each variable and each row with the display of the number of associated missing values, indicated by the standard R missing value code NA. When reading the data, R automatically sets any empty numeric and logical values as missing. Null character string values are left as null, unless the R na.strings=""
option is invoked. Of course any other valid value can be set to missing as well.
To not list the variable name or row name of variables or rows without missing data, invoke the miss.zero=FALSE
option, which can appreciably reduce the amount of output for large data sets. To view the entire data table in terms of 0's and 1's for non-missing and missing data, respectively, invoke the miss.matrix=TRUE
option.