mkdir m170Protect the directory so that nosey students will not have access with the unix command:
chmod 700 m170Now move to that directory and start up emacs.
cd m170 emacs &
Einstein, Albert 0034567 Laird, Nan 0056745 Bernoulli, Jacob 0098453 Camus, Albert 0089452and that it's called roll_F99 in the m170 directory. It's easiest to add a row of column labels to the top of the file, so edit it in emacs to make it look like this:
Lname Fname idno Einstein, Albert 0034567 Laird, Nan 0056745 Bernoulli, Jacob 0098453 Camus, Albert 0089452Save the file with C-X C-S.
Now start up R within emacs by typing Meta-X R. Note that the R is uppercase. A question appears in the minibuffer asking which directory to use. Make it your m170 course directory. Soon you are going to need to know more about commands available in R and their proper invocation. Usually you would To read the data into a data frame (like a fancy matrix) use this command in R:
> roll <- read.table("roll_F99",head=TRUE)
If the rows of the data file have different numbers of fields,
this step will fail, and it will tell you that there are
lines with different numbers of fields. This will happen if
some students are listed with a middle name, and others have
only two names. Go back to the original file and edit it. If
some data are missing, fill in with the capital letters, NA,
which R interprets as missing. Save the corrected file and
try again:
> roll <- read.table("roll_F99",head=TRUE)
To see the data, type it's name:
> rollwill display all rows and columns.
Lname Fname ID Q1 Einstein, Albert 0034567 4 Laird, Nan 0056745 10 Bernoulli, Jacob 0098453 10 Camus, Albert 0089452 2 Possible Im 0000 10
> roll <- read.table("roll_F99",head=TRUE)
## attach the data frame so you can refer to each part of it.
## The parts can be seen with the names command:
> names(roll)
[1] "Lname" "Fname" "ID" "Q1"
> attach(roll)
## get summaries:
> summary(Q1)
## stem and leaf plots or histograms
> stem(Q1)
> motif()
## before using a good graphics plot, we need to open a
## graphics device.
> hist(Q1 )
## sort output into order:
> detach()
> roll <- roll[order(roll$Lname),]
> attach(roll)
Back to MSU Math Department Home Page