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
250
Fukuoka.R #15 順序尺度の時系列変化を 折れ線グラフとヒートマップで 可視化してみた
mitti1210
1
13k
20190605_プログラム未経験者がMOOCでRを独学してみたら・・・
mitti1210
1
13k
Other Decks in Programming
See All in Programming
Event is what happens
moro
2
1k
Seven New Principles of Software Engineering
yegor256
0
120
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
0
550
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
1.7k
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
2
1.1k
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
330
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
3
550
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
Featured
See All Featured
Technical Leadership for Architectural Decision Making
baasie
3
600
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
730
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Abbi's Birthday
coloredviolet
4
10k
Ruling the World: When Life Gets Gamed
codingconduct
0
410
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
530
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
68
59k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
890
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
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!!