Go to the R console and install and load library RCommander, Deducer, etc ...
|
There are a bunch of ways in which we can slice and dice a data file. Here are some concepts that apply.
In R download
and read the content from the UCLA file "mmreg.csv"with info for 600
students. The psychological variables are measures of
control, self_concept and motivation. The academic variables are
standardized tests in reading (read), writing (write), math (math) and
science (science). Additionally, the variable sex codes female
students with "1", and males with "0".
First
let us create subsets of variables (i.e., columns 1-3 for spychological
measures, 4-7 for academic metrics) in which we designate row and
column descriptors using the syntax of [rows,columns], a blank
indicates the entire range
To
subset for specific rows we can use a boolean that tests for a specific
match, eg. all female students
...
and yes, you guessed it, the psychological measures for all male
students can then be obtained as ...
|
In same cases it may be appropriate to replace a missing value with
the mean for the variable. You can go into your text file with a text
editor and fille the missing valuews with the mean, or, alternatively,
you can do this in R.
In R download
and read the content from the cichlid brain data file
The
following code iterates through all columns (variable counter is i) and
tests whether the variable is of type numeric. If that is the case then
the code inside the squiggly brackets is execute. In our case it prints
the name of the variable to the console.
To access the values in a particular (in this case column 9) use ...
To substitute missing values in a single column (in this case column 9) with the value 3.14159 ...
...
and yes, you can combine all these clauses in any way you wish. For
instance to replace all missing values in any numerical variable of the
data frame with the variables mean use ...
|