graphics with r

17
GRAPHICS WITH R A STATISTICAL TOOL FOR HIGH SCHOOL MATHS By: Jade Write, Garth Lo Bello, Andrew Roberts, Prue Tinsey and Tania Young

Upload: andyroberts89

Post on 26-Jun-2015

159 views

Category:

Education


0 download

DESCRIPTION

Lesson plan using "R' software

TRANSCRIPT

Page 1: Graphics with r

GRAPHICS WITH RA STATISTICAL TOOL FOR HIGH SCHOOL MATHS

By: Jade Write, Garth Lo Bello, Andrew Roberts, Prue Tinsey and Tania Young

Page 2: Graphics with r

• Using R, students have access to open source, professional quality software.

•Unlike Excel, this program requires knowledge of computing language. This is because excel is a modified program that has been made easy to use by the general population.

• Simple code can be provided by a teacher for the students to use with their own data.

• Not having “built in functions,” students have the chance to see more of what is involved in statistical procedures. This will allow students to understand what it would be like in the ‘real world’.

• R can perform all the tasks Excel can, but provided many more enhanced abilities, is free and is also used by professional statisticians.

Why Should We Use R?

Page 3: Graphics with r

THE TASK• Stage 4 and 5 in the draft NSW syllabus

• Students will be asked to collect data from the classroom

• Examples could include hours spent studying vs. Other activities, their height, the time it takes them to complete homework, etc.

• Then the students will run R using code given by their teacher andproduce relevant graphical displays for interpreting their findings.

• In doing so, students will have a choice of an appropriate display

Page 4: Graphics with r

Example 1:

Hours spent on various activities

Suppose a student spends:

5 hours at school3 hours with friends1 hour doing homework2 hours working at a job1 hour travelling8 hours sleeping4 hours watching TV

Page 5: Graphics with r

x <- c(5, 3, 1, 2, 1,8,4)

pie(x, main="Hours of Student Life", col=rainbow(length(x)), labels=c("School","Friends","Homework", "Job", "Travel", "Sleep", "TV"))

pie(x, main="Hours of Student Life", col=rainbow(length(x)),labels <- round(x/sum(x) * 100, 1))x_labels <- paste(labels, "%", sep="")

pie(x, main="Daily Hours as Percent of Day", col=rainbow(length(x)), labels=x_labels,)

legend("bottomleft", c("School","Friends","Homework","Job","Travel","Sleep", "TV"), cex=0.9,bty="n",fill=rainbow(length(x)))

Page 6: Graphics with r

The student is asked to produce a pie chart with legend to represent their daily lifestyle.

Page 7: Graphics with r

Now let’s look at the normal distribution

Suppose students compile data regarding the amount of time perDay they spend on homework in minutes.

Ex: 20, 25,....120

And the teacher asks the student to use R to represent this data inA histogram that shows the mean.

R can do this rather simply

Page 8: Graphics with r
Page 9: Graphics with r
Page 10: Graphics with r

A normal curve fittedTo a sample of 100

With R, simply change onenumber and students can see how sample size affects the shape

Page 11: Graphics with r

What if you have student’s measure their own heightsand want them to analyse that?

You could have them first collect the heights of allThe students in the class.....

Then compare the results when the separate the heights of boysFrom girls

This could spark a discussion about how certain displaysCan be more illustrative than others

And why, in statistics, knowing your target population has greatimportance.

Page 12: Graphics with r

RESULTSALL STUDENTS: Min. 1st Qu. Median Mean 3rd Qu. Max. 153.0 155.0 161.5 161.0 166.0 170.0

BOYS

Min. 1st Qu. Median Mean 3rd Qu. Max. 163.0 165.8 166.0 166.4 167.2 170.0

GIRLS

Min. 1st Qu. Median Mean 3rd Qu. Max. 153.0 154.0 155.0 155.5 156.2 160.0

Page 13: Graphics with r
Page 14: Graphics with r

CONFUSED OR WORRIED ABOUT USING A PROGRAM THAT REQUIRES CODE?

There are thousands

of free examples

online

Page 15: Graphics with r

Activity:

There are a number of activities that the students could do using ‘R’.For Example: Group the students so there are 4 students in each group. Have the students measure how far they can jump in ‘long jump’ and record the results. The students can then compute their results and compare against each other. In the same groups the students could then be given the results from the schools athletics carnival. The can then enter the data from all the age groups and present to the class their findings (using appropriate graphs). (The teacher could have different groups analyse different sports—eg shot put, 100m sprint, discus, etc).In their presentation the students will need to highlight any interesting trends they find (for example, is there a large jump in data from one age group to another age group?, etc)

Page 16: Graphics with r

SUMMARYR is a free program that not only does everything excel doesbut also provides the ability for the student to see the steps involved by avoiding built in functions.

This enhances learning and allows for creativity while at the same time providing students the chance to learn a piece of Software statisticians ACTUALLY use

Writing code can be daunting at first, but a simple Google searchprovides numerous scripts that can be amended to fit any task

The R website also provides free help and downloads at:

http://www.r-project.org/

Page 17: Graphics with r

QUESTIONS??????