Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Introduction to Coding notes

Rating
-
Sold
-
Pages
7
Uploaded on
23-06-2021
Written in
2020/2021

Brief notes on coding. Easy short cut to view R Studio commands plus additional example questions and answers from assignments.

Institution
Course

Content preview

Organizing data
● select()– include or exclude certain variables (columns)
● filter()– include or exclude certain observations (rows)
● arrange()– change the order of rows
● summarise()– produce descriptive statistics
● group_by()– organize observation into groups
● mutate()– create new columns
● Inner_join – combines two dataframes on specified columns
● gather()– change data from wide to long format
● pull()– takes variable out of data frame and converts it into a vector

Data visualization
● ggplot(dataframe, aes(x=variable))+geom_histogram()
● ggplot(dataframe,aes(x=variable, y= dependent variable)) + geom_point
● ggplot(dataframe,aes(x=variable, y= dependent variable)) +geom_boxplot()
○ geom_violin() → used to visualise distribution of data
● ggplot(dataframe,aes(x=variable, y= dependent variable)) + geom_bar(stat=”identity”)
○ fill=as.factor → for each occasion
● geom_errorbar(aes(ymin= Mean – SD, ymax=Mean + SD)
● facet_wrap(~variable1 + variable 2) → split the figure by certain category
● tibble() → creates new dataframe
○ tibble(first_column_name= column_contents, second_column_contents…)
● n() → counts up number of rows

Probability → use binomial distribution to display probability because data variables are discrete
● Chance of 1 girl in a 3 child family when the prob of a girl each time is 0.5
○ dbinom(x=1, size=3,prob=0.5)
● Chance of getting 1 or fewer girls in a family of 3
○ pbimom(q=1, size=3, prob=0.5)
● Chance of getting at least 2 girls in a family of 3
○ pbimom(q=1, size=3, prob=0.5, lower.tail=FALSE)
● How few number of heads in 5 flips should people get to win?
○ qbinom(p=0.1, size=5, prob=0.5)
■ p= desired number

Descriptive statistics
● Standard deviation<-standard error * sqrt(samplesize)
● dnorm()– density function for normal distribution
○ x= values of variable
○ mean= mean
○ sd= standard deviation
● pnorm() – probability or distribution function; gives prob that a value will be above a cut-off
point

, ○ Probability of a woman shorter than 150cm
■ pnorm(q=150, mean= m_fem, sd= sd_fem)
● qnorm() – proportion of values below or above a given-cutoff
○ How short does a woman need to be to be in the bottom 10%?
■ qnorm(p=0.1, mean= x, sd= y)
● rnorm() – simulate data from random normally distributed variable
○ rnorm(n=5, mean= x, sd= y)
● na.rm=TRUE – when summarising data and the columns have missing values

Written for

Institution
Study
Course

Document information

Uploaded on
June 23, 2021
Number of pages
7
Written in
2020/2021
Type
Class notes
Professor(s)
Sarah griffith
Contains
All classes

Subjects

$11.09
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
hannahkim2001

Also available in package deal

Get to know the seller

Seller avatar
hannahkim2001 University College London
Follow You need to be logged in order to follow users or courses
Sold
1
Member since
4 year
Number of followers
1
Documents
21
Last sold
4 year ago

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions