<file_sep>install.packages("readxl")
library(readxl)

df_exam <- read_excel("excel_exam.xlsx")
df_exam

mean(df_exam$english)
mean(df_exam$science)

df_novar <- read_excel("excel_exam_novar.xlsx", col_names = F)
df_novar

df_s <- read_excel("excel_exam_sheet.xlsx", sheet = 3)
df_s


df_csv <- read.csv("csv_exam.csv", stringsAsFactors = F)
df_csv

df_midterm
write.csv(df_midterm, file = "df_midterm.csv")
save(df_midterm, file = "df_mid.rda")

rm(df_midterm)
df_midterm
load("df_mid.rda")
df_midterm # 저장할 때 사용한 변수로 다시 되살아남
<file_sep>a <- 1
a + 2




b <- 2
b*3

var1 <- seq(1, 70, by = 2)
var1

var2 <- c(1:5)
var2

var3 <- seq(1,5)
var3

var4 <- seq(1,10,by = 2)
var4 + 2

var2 + var2

str1 <- "a"
str1

str2 <- c("Hello", "world")
str2

mean(var2)
max(var2)
min(var2)

paste(str2, collapse = ",")

<file_sep>grade <- c(80, 60, 70, 50, 90)
mean(grade)
total_m <- mean(grade)
total_m

# 데이터 프레임 만들기
english <- c(90,80,60,70)
math <- c(50,60,100,20)

df_midterm <- data.frame(english, math)
df_midterm

class <- c(1,1,2,2)
df_midterm <- data.frame(english, math, class)
df_midterm

mean(df_midterm$english) # df_midterm의 english변수 
mean(df_midterm$math)

# 데이터 프레임 한번에 만들기
df_midterm <- data.frame(english = c(90,80,60,70),
                         math = c(50,60,100,20),
                         class = c(1,1,2,2))


df_a <- data.frame(제품 = c("사과", "딸기", "수박"),
                     가격 = c(1800, 1500, 3000),
                     판매량 = c(24, 38, 13))
df_a
mean(df_a$가격)
mean(df_a$판매량)
