SOCI 3238 Digital Sociology · Tutorial 1
Sep 28, 2026 (Mon) 12:30–14:00 · Sino Building 408B
Xuanlong QIN (Teaching Assistant)
dplyr
ggplot2
igraph
quanteda
httr
"Input"
"Output"
The four panes
Run the current line with ⌘ + Enter or click Run
⌘ + Enter
Run
Tips
Create an R Project per course
Use relative paths: read_csv("data/x.csv")
read_csv("data/x.csv")
Path
Relative Path
You can use the provided .Rmd file to follow the tutorial.
.Rmd
#
Basic Data Types
Type Conversion
Why we need convert types?
Operators
Logistic variable
R divides the operators in the following groups:
==
!=
>
<
&
|
!
:
The if Statement
While Loop
For Loop
A function is a block of code which only runs when it is called.
You can pass data, known as parameters, into a function.
A function can return data as a result.
Why we need structures?
R provides many built-in data structures. Each is used to handle data in different ways:
plot() function can solve most visualizaton issue.
You can use AI to help enhance your images. - Generally, it is better than human.
Statistics is the science of analyzing, reviewing and conclude data.
The R language was developed by two statisticians.
Data → table → plot (5 -10 mins)
mtcars
Titorial_1.Rmd
Do: the hands-on exercise end-to-end on your own machine
Slides & materials: course content on Blackboard or Download from Github.
Questions → email (xuanlong@link.cuhk.edu.hk)
Python is also available for researcher; R is classic of Social Scientist.