Training on Educational Research and Statistical Analysis for Teachers - Sessions 8–9 R Practice

힘센캥거루
2025년 12월 27일(수정됨)
1
challenge

This part was hands-on practice with R.

We tried out simple calculations and using libraries.

For example, let’s say we have the following Python code.

def add(a, b):
	return a + b
x = 1
y = 2
sum(x, y)

If we convert this to R, it looks like this.

add <- function(a, b){
	return a + b
}
x <- 1
y <- 2
sum(x, y)

And the basic data types are as follows.

Data type

Example

Description

Numeric

x <- 10

double by default

Character

name <- "R"

Strings use quotation marks

Logical

flag <- TRUE

TRUE / FALSE

Vector

v <- c(1,2,3)

Basic data structure in R

List

lst <- list(a=1, b="hi")

Can contain different types

Data frame

df <- data.frame(x=1:3, y=c("a","b","c"))

Table-like form

Instead of lists, you use the vector type, and you can perform operations on all of its values at once.

x <- c(1,2,3)
x + 1     # [1] 2 3 4
x * 2     # [1] 2 4 6
x == 2    # [1] FALSE TRUE FALSE

At one point we loaded csv and sav files, and I was surprised that the function names were very similar to those in pandas.

That made me wonder if it wouldn’t be fine to just analyze everything with Python instead of using R, but according to ChatGPT it’s still good to learn R.

Training on Educational Research and Statistical Analysis for Teachers - Sessions 8–9 R Practice-1

I feel like once I do one proper data analysis project, I’ll get the hang of it.

댓글을 불러오는 중...