1 of 40

10 R functions that replace your Excel

Yevheniia Drozdova, Texty.org.ua

2 of 40

3 of 40

4 of 40

5 of 40

To execute a row use:

Control + Enter (Windows)�Command + Enter (Mac)

If row starts with # R ignores it

6 of 40

This is the path to the folder where you saved your file. This path will be different for each of you — it depends on your operating system, your computer name, and other settings.

It will give you a clue how

to set a path for you files

7 of 40

8 of 40

9 of 40

You can name variables however you like, but it’s good practice to use descriptive ones

name of your file

(it would be different)

10 of 40

Data Playground

11 of 40

12 of 40

13 of 40

14 of 40

  1. try to use descriptive names (variables)
  2. It is your dataset

%>% �Shift+CTR+M (Windows)

�Shift+Command+M

(Mac)

2

1

15 of 40

16 of 40

17 of 40

18 of 40

19 of 40

admin1 is a column name. It should be presented in your data

20 of 40

21 of 40

& AND operator 一 both conditions must be true

| OR operator 一 at least one must be true

22 of 40

23 of 40

24 of 40

Functions are small tools that do specific jobs for you. R already has many built-in ones — for example, month.name[10] returns the 10th month, or month() helps you extract the month from a date

25 of 40

26 of 40

27 of 40

28 of 40

29 of 40

30 of 40

31 of 40

32 of 40

33 of 40

34 of 40

35 of 40

36 of 40

Important: the values in the admin1 column of your data and the admin1 column in election_data must be written the same way

37 of 40

38 of 40

39 of 40

Clean your environment from extra files. It doesn’t impact real files on your computer.

40 of 40

Final notes:

# Always use pipe (%>%) for readable code

# Combine functions for complex analyses

# Document your code with comments for future use

# ChatGPT or other LLM can help you with R code

# Add ggplot2 library for data visualization

gives you a quick scatterplot — no other tools needed