100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Lecture 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.

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

Document information

Uploaded on
June 23, 2021
Number of pages
7
Written in
2020/2021
Type
Lecture notes
Professor(s)
Sarah griffith
Contains
All classes
£7.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
hannahkim2001

Also available in package deal

Thumbnail
Package deal
Research methods Exam Review
-
4 2021
£ 68.96 More info

Get to know the seller

Seller avatar
hannahkim2001 University College London
View profile
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

Trending documents

Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight 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 smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions