반응형

데이터 프레임(Data Frame)은 가장 많이 사용하는 데이터 형태로, 행과 열로 구성된 사각형 모양의 표처럼 생김

 

행 - 정보

열 - 속성

성별 나이
남자 20 167
여자 22 160

 

R을 사용하여 데이터 프레임 만들기

<code>

english <- c(90, 80, 60, 70) # 영어 점수 변수 생성

english

## [1] 90 80 60 70



math <- c(50, 65, 80, 30)   # 수학 점수 변수 생성

math

## [2] 50 65 80 30





df_score <- data.frame(english, math) # 데이터 프레임 생성

df_score



##    english  math

## 1       90      50

## 2       80      65

## 3       60      80

## 4       70      30

 

데이터 프레임 분석하기

<code>

mean(df_score$english)  # df_score의 english 평균 산출

 

CSV 파일 저장하기

<code>

write.csv(df_score, file = "CSV_test.csv")

 

CSV 파일 불러오기

<code>

df_csv <- read.csv("csv_test.csv")

df_csv

 

반응형

+ Recent posts