\

2) 함수의 개념

a<-c(1,2,3) a mean(a) # 평균 max(a) # 최댓값 min(a) # 최솟값 median(a) # 중앙값

3) 패키지

install.packages(‘ggplot2’) library(ggplot2) data(“diamonds”) df<-diamonds df install.packages(‘Rtools’) library(Rtools)

x<-c(1,2,3) mode(x) is.numeric(x) is.logical(x) is.character(x) length(x)

a<-10 a class(a)

x<-c(1,10) y<-c(‘apple’,‘melon’) xy<-c(x,y) xy

1:5 5:1

a<-c(1,3,1,3) a class(a) a3 b <- factor(c(1,3,1,3)) b class(b) levels(b) b3

x<-c(“a”,“b”,“c”) x[1] x[-1] x[c(1,2)]

gender<-c(“male”,“female”,“male”) bloodtype<-c(“ab”,“0”,“b”) height<-c(170,175,165) weight<-c(70,65,55) df<-data.frame(gender,bloodtype,height,weight) df

class(df)

car<-c(“kia”,“bmw”,“toyota”) df2<-data.frame(df,car) df2

data(iris) # 데이터 불러오기 head(iris) str(iris)

iris[,c(1:2)] iris[,c(1,3,5)] iris[,c(“Sepal.Length”,“Species”)] iris[1:5,] iris[1:5,c(1,3)] iris[ ,-5]

str(iris) iris\(Species iris\)Sepal.Length iris\(Sepal.Width iris\)Petal.Length iris$Petal.Width