Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
前処理R 第2回資料
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mitti1210
April 23, 2022
Programming
440
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
前処理R 第2回資料
第2回 前処理R オンライン開催の発表資料です。
mitti1210
April 23, 2022
More Decks by mitti1210
See All by mitti1210
前処理勉強会_発表資料_MITTI_20210724.pdf
mitti1210
3
1.4k
Rによるオープンデータ 前処理勉強会(医療データ) _オープニング
mitti1210
3
2.1k
前処理をRでしたい! ~DPCデータに挑戦!~
mitti1210
2
260
Fukuoka.R #15 順序尺度の時系列変化を 折れ線グラフとヒートマップで 可視化してみた
mitti1210
1
13k
20190605_プログラム未経験者がMOOCでRを独学してみたら・・・
mitti1210
1
13k
Other Decks in Programming
See All in Programming
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
250
JIS keyboard support in Omarchy
lef237
0
180
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
680
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
200
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
320
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
120
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.6k
Spec-Driven Development - Why Vaadin Is the Perfect Fit
simas
PRO
0
210
AI時代のシニアエンジニアとは
yosuke_furukawa
PRO
14
11k
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
690
そのデザイントークン、Flutterでも同じ見た目になりますか?
nakamizu
0
270
Getting Started with Vibe Coding
miccheng
0
170
Featured
See All Featured
Design in an AI World
tapps
1
380
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
820
How Software Deployment tools have changed in the past 20 years
geshan
2
35k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
440
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
Site-Speed That Sticks
csswizardry
13
1.6k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
600
Speed Design
sergeychernyshev
33
2.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
300
Transcript
tryCatch @MITTI12101 2 # R (2022/04/23)
MITTI Edx Professional Certificate (Data Sciense) GCI GCI2019 Winter
病棟の機器を一日どのくらい使用しているか集計したい Excelのデータはあります いいですよ!
ここの平均が欲しい 数十ヶ月ある
この行だけ読み込めばOK? readxl::read_excel(range=”B25:AF25”) でも機器の数って変わってそう・・・
【作戦】 1, 1行目以外を読み込む 2, 計の行のみにする 3, A列を消して数字だけにする 4, 平均を計算する 完成予想
library(readxl) library(tidyverse) file <- "test.xlsx sheets <- excel_sheets(file) temp <-
read_excel(file, sheet = 1, skip = 1) temp %>% filter(...1 == " ") %>% select(-1) %>% rowMeans(na.rm = TRUE) [1] 8.677419 1 ReadSheet <- function(file, sheet){ temp <- read_excel(file, sheet = sheet, skip = 1) mean <- temp %>% filter(...1 == " ") %>% select(-1) %>% rowMeans(na.rm = TRUE) year <- str_extract(sheet, "^20[0-9][0-9]") month <- str_extract(sheet,"[0-9]*$") result <- tibble( year = as.integer(year), momth = as.integer(month), value = mean ) return(result) } ReadSheet(file, sheets[1]) [1] 8.677419
map_dfr(sheets,~ReadSheet(file, .x)) 1 1 map
for (sheet in sheets) { tryCatch( { ReadSheet(file, sheet) #
}, error = function(e){ print(paste0(sheet, )) # } ) } tryCatch
character
ReadSheet <- function(file, sheet){ temp <- read_excel(file, sheet = sheet,
skip = 1) mean <- temp %>% filter(...1 == " ") %>% select(-1) %>% mutate(across(everything(), as.numeric)) %>% # 1 rowMeans(na.rm = TRUE) year <- stringr::str_extract(sheet, "^20[0-9][0-9]") month <- stringr::str_extract(sheet,"[0-9]*$") result <- tibble( year = as.integer(year), momth = as.integer(month), value = mean ) return(result) } ReadSheet(file, sheets[7])
map_dfr(sheets,~ReadSheet(file, .x)) map
csv map tryCatch
ENJOY!!