lecture_03_ho

# lecture_03_ho - BIOS 735: Statistical Computing Michael Wu...

This preview shows pages 1–4. Sign up to view the full content.

BIOS 735: Statistical Computing Michael Wu Lecture 3: Data Frames, Factors and Tables August 30, 2011 Michael Wu (Lecture 3) BIOS 735 August 30, 2011 1 / 9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Data Frames Practically: behave like Matrices (rows and columns), but columns can have different modes Technically: data frames are lists of vectors Example students = read.table("Students.txt", header = T, sep = "\t") students class(students) students[3,2:4] students\$Nickname students[3] students[,-(1:4)] scores = students[-(1:4)] # Note difference from previous line class(scores) class(students[1]); class(students[4]); class(students[5]) class(students[,1]); class(students[,4]); class(students[,5]) Key point to remember: list of equal-length vectors. Michael Wu (Lecture 3) BIOS 735 August 30, 2011 2 / 9
Data Frames: Using Matrix Operations Many matrix operations can still be used on data frames: dim(students) rowMeans(scores) works if all of the vectors are numeric modes rbind(students, students[2,]) and cbind(scores, 1:nrow(scores)) scores * 2 and scores +99 Indexing can be done exactly like using a matrix. Other Matrix Operations will work, but may cause problems:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/18/2011 for the course BIOS 735 taught by Professor Staff during the Spring '10 term at UNC.

### Page1 / 9

lecture_03_ho - BIOS 735: Statistical Computing Michael Wu...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online