티스토리 뷰

언어/R

엑셀파일 읽고 csv 파일 저장

newlibra 2025. 2. 2. 00:49
library(readxl)
forest_example_data <- read_excel("forest_example_data.xls")
summary(forest_example_data)

#--0 또는 빈값(나중에 csv 전환시)
forest_example_data$number[is.na(forest_example_data$number)] <- "" 
forest_example_data$number <- as.numeric(forest_example_data$number)
forest_example_data$area <- as.numeric(forest_example_data$area)

str(forest_example_data)
colnames(forest_example_data) <- c("name", "city","gubun", "area", "number","stay","city_new","code","codename")
head(forest_example_data)

library(descr)
freq(forest_example_data$city, plot=T, main='city')
city_table <- table(forest_example_data$city)
barplot(city_table)

library(dplyr)
count(forest_example_data, city) %>%  arrange(desc(n))

#-- csv전환시 e표기 없이 숫자표현  options(scipen=0)
options(scipen=999)
write.csv(forest_example_data,"forest_example_data.csv")

'언어 > R' 카테고리의 다른 글

R foreach  (0) 2025.03.26
R BlackSholes  (0) 2025.02.19
ggplot2  (0) 2025.01.28
단축키  (0) 2025.01.12
shiny web 2  (0) 2024.11.01
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함