Professional Documents
Culture Documents
# : justification notes
Blue font : output from R
> : command
INTRODUCTION TO R
R Console
➢ Write a command line here
➢ PLEASE BEWARE!!
• The command line will be
lost once close the RStudio
CREATE PROJECT
2 3
1
Click “Browse”
to set directory
IMPORTING DATA FROM EXCEL TO R
1 2
4
Create Data Name
CHECKING DATA
> names(data) #list all variables name
[1] "patientid" "date" "enddate" "ptage" "ptgender" "ptrace" "q1"
[8] "q2" "q3" "q4" "q5" "height" "weight" "sysbp"
[15] "diasbp"
> table(data$ptgender,data$gender)
Male Female <NA>
1 17 0 0
2 0 9 0
3 0 0 2
Exercise
Please label the ptrace, q1, q2, q3, q4 and q5.
B. Compute variables
> data$bmi=data$weight/(data$height^2)