# Welcome to R!
# The present file is a script
# and is used to write the commands that will be run in the R command space.
# We wrote the first lines for you.
# In order to save your work in R, it is essential for you to open up a script file R
# (in R:file->new document, or in RStudio: file -> new -> R script).
# The script is what allows you to easily recreate your work,
# and can be built on over time (for example, saving you time in tomorrowâ€™s exercise).
# Commonly, rather than saving the output directly,
# you save the recipe for producing the output in a script.
# (You can also save the output, e.g., plots, directly.)
# You can send commands in the script directly to the console
# by pressing Command + Enter while the cursor is
# on a line with a command in the script.
# Let's start by running the commands below.
# R as a Calculator
5 + 5 + 5
7 * 10 / 2
sqrt (25)
# Assigning Values in R
x = 12
y = c(1,2,3,4,5,6,7,8,9,10)
x
y
# Basic Statistical Functions
mean(y) #Finds the mean
median(y) #Finds the median or the number exactly in the middle of the data set
range(y) #Finds the range
min(y) #Finds the minimum
#######################################################
# To make it easier for us to see what you've done,
# please copy the script below (with your comments!)
# of the tasks of the tutorial in here:
#######################################################
# WORKING WITH DATA
# Before you start to work with any dataset, you need to know what the data represent.
# Be sure to look carefully at the meta-data (description of the data) to know how to interpret what you plot.
#######################################################
# Script for task 1 - mean, median, standard deviation:
# Life expectancy:
# mean (add script in empty space, you may use more space by adding lines):
# median:
# standard deviation:
# For what year do 50% of the countries fall below? How about 75%?
# answer:
# Happy Life Years:
# mean:
# median:
# standard deviation:
# For what year do 50% of the countries fall below? How about 75%?
# answer:
#########################################################
# Script for task 2 - Plot a histogram:
# Plot a histogram for a variable other than gdpcap.
# Add title, x-axis & y-axis label, color, number of bins
#######################################################
# Script for task 3 - Customize a plot:
# Add a meaninful title, x-axis & y-axis label, & color
# to the plot(hpidata$gdpcap,hpidata$footprint)
#######################################################
# Script for task 4 - Relationship life expectancy and ecological footprint:
# What is the relationship between life expectancy and ecological footprint ?
# Use the plot function to show the relationship graphically.
# Use each of the options (i.e., pch, cex, font, las etc.)
# to create a highly customized graphic.
########################################################
# For the rest of the turorial,
# you should type the commands from the tutorial in this script (modifying as needed),
# and SAVE IT early and often (there is no Auto Save in R!).
# Be sure to add your own comments (preceded by #) to document your work
# and explain it to yourself as needed.
# Have fun! Let's start to R!