Post

R table 내보내기

Write.table()

CSV로 저장 / 불러오기

R 내장 함수 write.csv / read.csv사용

1
2
write.csv([R_table_obj], file="file_name.csv")
xxtable <- read.csv("file_name.csv")

엑셀로 저장 / 불러오기

엑셀 확장자 (xlsx, xls)로 저장하고 불러오는 법.

저장하기 : xlsx 패키지

OR openxlsx 패키지

1
2
3
4
5
6
7
8
9
10
## Installation
install.packages('xlsx') 

library(xlsx)
write.xlsx(x = [R_table_obj],
           file="[file_name.xlsx]", 
           sheetName="[sheetName]",
           col.names=TRUE,
           row.names=TRUE,
           append=FALSE # 원래 있는 파일에 덧붙일때)

불러오기 : readxl 패키지

1
2
3
4
5
6
7
8
9
## Installation
install.packages("readxl")

## Usage
library(readxl)
read_excel(path='[경로명]', 
           sheet='[시트명]',
           range='[범위]', #행:cell_rows(1:2) / 셀: A1:B2 / 행열: R1C1:R2C2
           col_names=c('[Column_name]','')




Reference

  • https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=jdusans&logNo=221692243738
  • https://jobmanager1.tistory.com/
This post is licensed under CC BY 4.0 by the author.

© Subin Cho. Some rights reserved.

Using the Chirpy theme for Jekyll.