Date: Friday, 13 Sep 2013 22:06:37 -0500 (CDT) From: Mark Jacobson To: Frodo B Baggins Subject: Trouble with R Graphs assignment On Fri, 13 Sep 2013, Frodo Baggins wrote: > Mark,  > > I am having trouble figuring out the graphs for the assignment. I have > been referring to the book for code, but it seems that Andy Field has > his own way of setting up the data into ways of producing the graphs. I have > the data read in, I'm stuck on where to go from there. If > there's any advice you can give, or help as to what will work for this, > that would be great. Thank you!  > > Frodo Frodo, I just did the section 4.5.1 Simple Scatterplot section of the textbook. Pages 136 to 141. Page 141 has the scatterplot with TWO REGRESSION lines, one for Female and one for Male. Your assignment has you make a Scatterplot with TWO REGRESSION lines, one for lecturers and one for students. "A scatterplot with regression lines of alcohol consumption and neuroticism grouped by lecturer/student." ---> Page 164 and also on your handout... What would the x-axis be? neuroticism is the independent variable. What would the y-axis be? alcohol consumption. Page 141 has the syntax you need to do this. Page 121 has the install.packages("ggplot2") and the library(ggplot2) Do 4.5.1 Simple Scatterplot and 4.5.2 Adding a Funky Line and 4.5.3 Grouped Scatterplot Here are a few of the commands that I did from 4.5.1 and 4.5.3. > examData <- read.delim("C:/R/AndyField/Exam Anxiety.dat", header = T) > attach(examData) > names(examData) [1] "Code" "Revise" "Exam" "Anxiety" "Gender" ***** The following command was done by checking the checkbox ***** for the Packages tab ggplot2 choice. This command R code ***** just shows up in the Console panel. > library("ggplot2", lib.loc="C:/Users/Mark/Documents/R/win-library/3.0") > scatter <- ggplot(examData, aes(Anxiety, Exam)) > scatter + geom_point() + geom_smooth(method = "lm", aes(fill = Gender), alpha = 0.1) + labs(x="Exam Anxiety", y="Exam Performance %", colour = "Gender") This last command is from page 141 and it is the syntax that you will adopt to process the PAGE 164 assignment part 5. ------------------------------------------------------------ "A scatterplot with regression lines of alcohol consumption and neuroticism grouped by lecturer/student." ------------------------------------------------------------ The best advice is to do the example in the chapter step by step for the GENDER, Exam anxiety and exam performance and see that resulting scatterplot. After you read and do that example, it then is easier to apply that experience and success where the book led you through doing it with an example, to apply that experience to your HW problem. > names(examData) ---- ------- ------ [1] "Code" "Revise" "Exam" "Anxiety" "Gender" ---- ------- ------ I will try to look at te Error Bar Chart and the Error Line Chart examples this weekend and see how that goes. We will probably extend the due date for the assignment until Thursday of next week instead of having it be due on Tuesday. Mark