본문 바로가기
R Basics

파일 데이터

by Nowkeeh Ahc

파일 형식 변환

  • 엑셀 파일에 테이블 형태의 데이터가 저장되어 있는 경우를 가정
  • 엑세 파일을 .csv 형태로 변환하여 저장 후 R에서 .csv 파일을 읽음
  • 읽어온 파일은 데이터 프레임 형태로 저장

파일 데이터 읽기

setwd("D:/source") 				# 작업 폴더 지정 
air <- read.csv("airquality.csv", header=T) 	# .csv 파일 읽기 
head(air)

setwd("D:/source") # 작업 폴더 지정 

air <- read.csv("airquality.csv", header=T) # .csv 파일 읽기 

head(air)

 

파일 데이터 쓰기

setwd("D:/source") # 작업 폴더 지정 
my.iris <- subset(iris, Species='Setosa’) # Setosa 품종 데이터만 추출 write.csv(my.iris, "my_iris.csv", row.names=F) 	# .csv 파일에 저장하기

 


This post was written based on what I read and studied the book below.

http://www.yes24.com/Product/Goods/92851804

댓글