Programming R/ Datacamp - Summary - Tilburg university - Economics
88 views 3 purchases
Course
Programming for ECO
Institution
Tilburg University (UVT)
Instagram: ECOsummaries
DM me for 20% discount!
Summary for the course ''Programming R / Datacamp''. This summary was written in order to study for the midterm as well as for the final. Everything you need to know is available in this summary.
Advice: this summary alone will not be enough, the tut...
, Introduction to R
Chapter 1
Math:
Addition: +
Subtraction: -
Multiplication: *
Division: /
Exponentiation: ^
Modulo: %%
Variable assignment:
my_var <- 4
my_fruit <- my_oranges + my_apples
Data types:
Numerics: decimal values 4.5
Integers: natural numbers 4
Logical: boolean values (TRUE or FALSE)
Characters: text / string
Class(‘something’) = gives data type of variable
Chapter 2
Vectors:
Combine function: c(1, 10, 49) or c(‘a’, ‘b’, ‘c’)
Assign names: names(roulette_vector) <- (‘Monday’, etc.)
Adding vectors: A_vector = c(1, 2, 3) and B_vector = c(4, 5, 6) → total_vector = c(5, 7, 9)
Sum: total_poker <- sum(poker_vector) → sums all values inside of the vector
Comparing: total_poker > total_roulette → TRUE
Vector selection: poker_vector <- c(140, -50, 20) with names ‘Mon’, ‘Tue’, ‘Wed’
poker_vector[1] = 140
poker_vector[c(1,3)] = (140, 20)
poker_vector[1:3] = (140, -50, 20)
poker_vector[c(‘Monday’, ‘Wednesday’)] = (140, 20)
Comparison:
Comparison operators: <, >, <=, >=, ==, !=
selection vector <- poker_vector > 0 → will give TRUE or FALSE for each day
poker_vector[selection_vector] → will give only the amounts on TRUE days
2
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller ecosummaries. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $4.24. You're not tied to anything after your purchase.