One way to create a csv data file is with MS Excel or other worksheet application. 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 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 a worksheet, under the File option, do a Save As and choose the csv format.
---
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
.