"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #3
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #2
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #1
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #4
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #2
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #1
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
"R을 이용한 데이터 처리 & 분석 실무 - 서민구 지음" 정리 자료 #4
- https://thebook.io/006723/
- 첫번째 : goo.gl/FJjOlq
- 두번째 : goo.gl/Wdb90g
- 세번째 : goo.gl/80VGcn
- 네번째 : goo.gl/lblUsR
2D 컴퓨터비젼에 대한 설명. 영상으로부터 정보를 추출해내는 공학/과학 분과인 컴퓨터비젼의 기술에 대한 쉬운 설명. 파이썬(Python)의 컴퓨터비젼/영상처리 라이브러리인 scikit-image를 주로 활용하였으며 코드를 함께 담음.
R컨퍼런스 발표본 (2014.5.30) 임.
20130222 Data structures and manipulation in RKazuki Yoshida
1) Objects in R can take various classes like numeric, factor, and logical and know their class through a class attribute.
2) Common data objects in R include vectors (containing a single data type), lists (containing multiple data types), matrices (2D arrays), and data frames (lists of equal-length vectors displayed as a table).
3) The class of an object determines how it can be manipulated and analyzed in R; for example, summarizing numerical versus categorical data requires different functions.
2D 컴퓨터비젼에 대한 설명. 영상으로부터 정보를 추출해내는 공학/과학 분과인 컴퓨터비젼의 기술에 대한 쉬운 설명. 파이썬(Python)의 컴퓨터비젼/영상처리 라이브러리인 scikit-image를 주로 활용하였으며 코드를 함께 담음.
R컨퍼런스 발표본 (2014.5.30) 임.
20130222 Data structures and manipulation in RKazuki Yoshida
1) Objects in R can take various classes like numeric, factor, and logical and know their class through a class attribute.
2) Common data objects in R include vectors (containing a single data type), lists (containing multiple data types), matrices (2D arrays), and data frames (lists of equal-length vectors displayed as a table).
3) The class of an object determines how it can be manipulated and analyzed in R; for example, summarizing numerical versus categorical data requires different functions.
이 책은 본격적인 알고리즘 공부보다는 알고리즘을 소재로 풀어가는 재미난 이야기를 담았다. 새로운 알고리즘 이론을 소개하는 것도, 독자에게 알고리즘을 ‘강의’하는 것도 아니다. 오히려 알고리즘은 맛있는 읽을거리의 ‘재료’로 쓰였을 뿐이다. 현실 세계와 유사한 재미있는 퀴즈로 독자의 흥미를 유도하기도 하고 때로는 딱딱한 수학 문제로 긴장감을 고조시킨다. 어떤 곳에서는 지저분한 펄 코드가 등장하기도 하며 깔끔하고 읽기 쉬운 C 코드 또한 자주 등장한다. 정렬이나 탐색 리스트 등의 정통 알고리즘도 책의 곳곳에 녹아 있다. 익살스럽고 특이한 그림을 보는 재미 또한 쏠쏠하다는 점도 이 책의 부수적인 장점이다.
“소프트웨어를 개발하는 사람에게 알고리즘은 취업이나 승진을 위해서 억지로 공부하는 대상이 아니라 퍼즐이나 수수께끼처럼 자체로 재미있고 신나는 놀이가 되어야 한다. 내 책 중에서 이 책이 가장 많은 사랑을 받은 배경에는 알고리즘을 딱딱한 공부가 아니라 말랑말랑한 놀이로 다루었다는 측면이 놓여 있을 것이다. 그런 의미에서 나는 이 책이 이미 개발자인 사람은 물론이고, 이제 막 소프트웨어 개발과 코딩을 배우려는 사람들에게 많이 읽히기를 희망한다.”
-- 지은이의 말 중에서
★ 대상 독자
- 휴식과 상식 쌓기와 공부를 동시에 원하는 바쁜 직장인
- 학문으로서가 아닌, 개발자의 삶에 녹아든 알고리즘 이야기가 궁금한 개발자
- 알고리즘이 재미있는 개발자
This document discusses sub-space system identification. It begins with an introduction to state space representation and the difference between deterministic and stochastic systems. It then outlines the procedure for sub-space identification, which involves generating block Hankel matrices and extracting system parameters. As a case study, it examines using sub-space identification to calibrate a finite element model of a 17th century bridge by determining its natural frequencies and mode shapes from ambient vibration data. This led to an updated model with better accuracy in predicting the bridge's earthquake response.
This document discusses sparse linear models and Bayesian variable selection. It introduces the spike and slab model for Bayesian variable selection, which uses a binary vector γ to indicate whether features are relevant or not. Computing the posterior p(γ|D) involves calculating the marginal likelihood p(D|γ). Greedy search and stochastic search methods are discussed to approximate the posterior over models. L1 regularization, also known as lasso, is introduced as an optimization technique since computing the posterior for discrete γ is difficult. Lasso replaces the discrete priors with continuous priors to encourage sparsity. Coordinate descent is discussed as an algorithm to optimize the lasso objective function.
사이토 고키 지음 | 개앞맵시(이복연) 옮김 | 24,000원 | 한빛미디어 | 2017.01.03
"직접 구현하고 움직여보며 익히는 가장 쉬운 딥러닝 입문서 "
이 책은 라이브러리나 프레임워크에 의존하지 않고, 딥러닝의 핵심을 ‘밑바닥부터’ 직접 만들어보며 즐겁게 배울 수 있는 본격 딥러닝 입문서입니다. 술술 읽힐 만큼 쉽게 설명하였고, 역전파처럼 어려운 내용은 ‘계산 그래프’ 기법으로 시각적으로 풀이했습니다. 무엇보다 작동하는 코드가 있어 직접 돌려보고 요리조리 수정해보면 어려운 이론도 명확하게 이해할 수 있습니다. 딥러닝에 새롭게 입문하려는 분과 기초를 다시금 정리하고 싶은 현업 연구자와 개발자에게 최고의 책이 될 것입니다.
Torque is defined as the vector product of position and force. It is commonly measured using strain gauges attached to a measuring body that experiences elastic strain when torque is applied. Strain gauges work by changing electrical resistance proportionally to strain. They are connected in a Wheatstone bridge configuration to detect small resistance changes. Precise summaries require careful application and wiring of strain gauges in a clean room to minimize errors from temperature changes or impurities. Compensation elements are added to account for temperature effects and the sensor's zero point.
PyCon 2014 발표 http://pycon.kr/2014/program/8 자료 입니다. 파이썬을 기반으로 금융데이터(주식시장 데이터)에 대한 이해와 수집/분석을 위한 구체적인 방법들 소개합니다.
- 마켓 데이터 수집과 저장
- 거래소 상장 종목 분석
- 금융 데이터의 측정과 분포
- 야후 파이낸스 활용
- 이동평균, 기술적 분석, 상관분석
- 데이터 시각화
This document discusses the impacts of climate change on various ecosystems. Wetlands will dry out and plants will die from less water. Coastal marshes will lose habitat for migratory birds. Forest ranges will shift and tropical forests will dry out and change plant life. Boreal forests will see more insect infestations and fires. The Arctic habitat will shrink in size. Low-lying islands will lose land area and human populations. Deserts will expand and dry further. Coral reefs will be impacted by rising water levels and dropping temperatures.
1. The document summarizes a presentation about information literacy and resources available from the library for first-year seminar courses.
2. It encourages scheduling a library instruction session and follow-up sessions to help students build research skills and awareness of resources.
3. It discusses new models of information literacy being adopted, including "digital and media literacy", and how the library can help with evaluative and critical thinking skills.
4. An overview is given of new library resources like a new search tool and an online history video collection.
Многоязычная база архивных терминов Международного Совета Архивов: История пр...Natasha Khramtsovsky
Доклад Натальи Храмцовской о том, как создавалась многоязычная база архивных терминов Международного Совета Архивов, сделанный на заседании Гильдии Управляющих Документацией 16 октября 2012
Dr Natasha Khramtsovsky's presentation “Development of ICA Multilingual Archival Terminology Database" at the meeting of the Russian Records Managers' Guild, Moscow, 16 October 2012.
Let's make APM by instrumenting Nodejs through the knowledge gained through tracing. Creating clues that facilitate tracking becomes a milestone for latecomers, like a snow-footprint.
[함수형 사고] 책을 읽고 진행한 PT
Java 8, Scala, Clojure, Groovy 등의 함수형 프로그래밍 언어에서 사용하고 있는 패러다임을 익힐 수 있습니다.
책을 요약하고 PT를 진행하려고 하니 미숙한 부분이 많으니, 자세한 부분은 책을 참고 부탁드립니다.
책에서는 주로 Groovy에 대한 코드가 많았는데, Scala에 조금 더 익숙하기 때문에 Scala로 작성한 코드가 많습니다.
3. 01. 데이터 처리 및 가공 패키지
Data를 다루는 능력의 중요성
• ML/DM 프로젝트에서 모델을 만드는 데 소요되는 시간은 전체 프로젝트의 14%
• 데이터 수집, 전처리 및 후처리에 더 많은 시간 소비
• 데이터를 원하는 형태로 바꾸거나 조작하는 능력은 절대적으로 중요
R 주요 Packages
Package 용도
sqldf SQL을 사용한 데이터 처리
plyr 데이터를 분할(split), 분할된 결과에 함수 적용(apply), 그 결과를 재조합(combine)
reshape2 데이터의 모양을 바꾸거나 요약
data.table R의 데이터 프레임을 대신할 수 있는 더 빠르고 편리한 데이터 타입
foreach apply 계열 함수들과 for문을 대신할 수 있는 반복문 구조
doParallel 멀티코어를 사용한 프로그램의 병렬적 사용 가능
testthat R코드의 기능 테스트를 위한 유닛 테스팅 프레임워크
4. 02. SQL을 사용한 데이터 처리
함수 대신 SQL 문을 사용하여 데이터 처리
SQL문이 주어지면 자동으로 스키마 생성하고 데이터를 테이블로
로드
> sqldf("select distinct Species from iris")
> sqldf('select avg("Sepal.Length") from iris where Species="setosa"')
avg("Sepal.Length")
1 5.004
> mean(subset(iris, Species == "setosa")$Sepal.Length)
[1] 5.004
> sqldf('select species, avg("sepal.length") from iris group by species')
Species avg("sepal.length")
1 setosa 5.004
2 versicolor 5.936
3 virginica 6.588
> sapply(split(iris$Sepal.Length, iris$Species), mean)
setosa versicolor virginica
5.004 5.936 6.588
5. 03. 분할, 적용, 재조합을 통한 데이터 분석
plyr 패키지 –데이터를 분할split하고, 함수를 적용apply후, 결과를
재조합combine하는 함수들을 제공
함수 naming 규칙 – a(rray), d(ata frame), l(ist), _(nothing)
{adl} {adl_} ply
입력 데이터 타입 입력 데이터 타입
split apply
combine
mean
mean
mean
array data frame list nothing
array aaply adply alply a_ply
data frame daply ddply dlply d_ply
list laply ldply llply l_ply
n
replicates
raply rdply rlply r_ply
function
arguments
maply mdply mlply m_ply
vector, matrix도 가능
6. 03. 분할, 적용, 재조합을 통한 데이터 분석
adply(.data, .margins, .fun=NULL)
• .data - 주어진 입력을 숫자 색인으로 읽을 수 있는 데이터 타입
• .margins – 함수를 적용할 방향 (그림참고)
• .fun – margin 방향으로 잘려진 데이터에 적용할 함수
2D 3D
8. 03. 분할, 적용, 재조합을 통한 데이터 분석
ddply(.data, .variables, .fun=NULL)
• 데이터 프레임을 분할하고 함수를 적용한 뒤 결과를 데이터 프레임으로 반환
• adply()는 행 또는 열 단위로 함수를 적용하는 반면 ddply()는 .variables에
나열한 컬럼에 따라 데이터를 나눈 뒤 함수를 적용
• .variables – data를 group지을 변수명, .()안에 기록
> ddply(iris, .(Species, Sepal.Length > 5.0),
function(sub) {
data.frame(sepal.width.mean=mean(sub$Sepal.Width))
})
Species Sepal.Length > 5 sepal.width.mean
1 setosa FALSE 3.213793
2 setosa TRUE 3.723810
3 versicolor FALSE 2.233333
4 versicolor TRUE 2.804255
5 virginica FALSE 2.500000
6 virginica TRUE 2.983673
9. > head(subset(baseball, id=="ansonca01"))
id year stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf gidp
4 ansonca01 1871 1 RC1 25 120 29 39 11 3 0 16 6 2 2 1 NA NA NA NA NA
121 ansonca01 1872 1 PH1 46 217 60 90 10 7 0 50 6 6 16 3 NA NA NA NA NA
276 ansonca01 1873 1 PH1 52 254 53 101 9 2 0 36 0 2 5 1 NA NA NA NA NA
398 ansonca01 1874 1 PH1 55 259 51 87 8 3 0 37 6 0 4 1 NA NA NA NA NA
525 ansonca01 1875 1 PH1 69 326 84 106 15 3 0 58 11 6 4 2 NA NA NA NA NA
741 ansonca01 1876 1 CHN NL 66 309 63 110 9 7 2 59 NA NA 12 8 NA NA NA NA NA
> ddply(baseball, .(id), function(sub) { mean(sub$g) })
id V1
1 aaronha01 143.39130
2 abernte02 40.05882
3 adairje01 77.66667
4 adamsba01 25.36842
5 adamsbo03 85.40000
6 adcocjo01 115.23529
...
03. 분할, 적용, 재조합을 통한 데이터 분석
선수의 년도별 출장게임수
각 선수별 년도별 평균
출장게임 수
10. 03. 분할, 적용, 재조합을 통한 데이터 분석
그룹마다 연산을 쉽게 수행하기
• base::transform(_data, …) ▶ _data의 … 연산 결과를 새로운 컬럼으로
추가한 데이터 프레임 반환
• plyr::mutate(_data, …) ▶ 여러 컬럼을 데이터 프레임에 추가할 때 직전에
추가한 컬럼을 뒤에 추가하는 컬럼에서 참조가 가능
• plyr::summarise(_data, …) ▶ …에 지정된 그룹마다 요약을 수행한 뒤 그
결과만을 담은 새로운 데이터 프레임 반환
• base::subset(x, subset) ▶ 그룹별로 조건을 만족하는 행만 추출
11. > head(ddply(baseball, .(id), transform, cyear = year - min(year) + 1))
id year stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf gidp cyear
1 aaronha01 1954 1 ML1 NL 122 468 58 131 27 6 13 69 2 2 28 39 NA 3 6 4 13 1
2 aaronha01 1955 1 ML1 NL 153 602 105 189 37 9 27 106 3 1 49 61 5 3 7 4 20 2
> head(ddply(baseball, .(id), mutate, cyear = year - min(year) + 1, log_cyear=log(cyear)))
id year stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf gidp cyear log_cyear
1 aaronha01 1954 1 ML1 NL 122 468 58 131 27 6 13 69 2 2 28 39 NA 3 6 4 13 1 0.0000000
2 aaronha01 1955 1 ML1 NL 153 602 105 189 37 9 27 106 3 1 49 61 5 3 7 4 20 2 0.6931472
3 aaronha01 1956 1 ML1 NL 153 609 106 200 34 14 26 92 2 4 37 54 6 2 5 7 21 3 1.0986123
> head(ddply(baseball, .(id), summarise, minyear=min(year), maxyear=max(year)))
id minyear maxyear
1 aaronha01 1954 1976
2 abernte02 1955 1972
3 adairje01 1958 1970
> head(ddply(baseball, .(id), subset, g == max(g)))
id year stint team lg g ab r h X2b X3b hr rbi sb cs bb so ibb hbp sh sf gidp
1 aaronha01 1963 1 ML1 NL 161 631 121 201 29 4 44 130 31 5 78 94 18 0 0 5 11
2 abernte02 1965 1 CHN NL 84 18 1 3 0 0 0 2 0 0 0 7 0 1 3 0 0
3 adairje01 1965 1 BAL AL 157 582 51 151 26 3 7 66 6 4 35 65 7 2 4 2 26
03. 분할, 적용, 재조합을 통한 데이터 분석
컬럼추가
직전 컬럼 참조
12. 03. 분할, 적용, 재조합을 통한 데이터 분석
mdply()
• m{adl_}ply() 함수는 데이터 프레임 또는 배열을 인자로 받아 각 컬럼을
주어진 함수에 적용하고 그 실행 결과들을 조합
> (x <- data.frame(mean=1:5, sd=1:5))
mean sd
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
> mdply(x, rnorm, n=2)
mean sd V1 V2
1 1 1 0.1255683 0.8584299
2 2 2 4.0005895 0.7128111
3 3 3 4.1732252 1.5489749
4 4 4 7.5287423 1.4327492
5 5 5 5.3530204 6.2291398
>
13. 04. 데이터의 구조의 변형과 요약
Reshape2 패키지는 데이터의 모양을 바꾸거나 그룹별 요약 값을
계산하는 함수들을 담고 있는 패키지
변환된 데이터는 측정치를 variable과 value라는 두 컬럼으로 표현
함수 의미
melt() 여러 컬럼으로 구성된 데이터를 데이터 식별자(id), 측정 변수(variable), 측정
값(value)이라는 3개 컬럼으로 변환. 각 variable마다 value의 통계값을 계산
하는 것이 편리
cast() melt()된 데이터를 다시 여러 컬럼으로 변환한다. 데이터에 여러 측정 변수와 측
정값이 존재한다면 이들은 모두 새로운 컬럼으로 변환된다.
또 다른 유용한 기능으로 데이터의 요약 값을 제공하는 기능을 제공
14. 04. 데이터의 구조의 변형과 요약
> head(m <- melt(french_fries, id.vars=1:4))
time treatment subject rep variable value
1 1 1 3 1 potato 2.9
2 1 1 3 2 potato 14.0
...
> ddply(m, .(variable), summarise, mean=mean(value, na.rm=TRUE))
variable mean
1 potato 6.9525180
2 buttery 1.8236994
...
> french_fries[!complete.cases(french_fries),]
time treatment subject rep potato buttery grassy rancid painty
315 5 3 15 1 NA NA NA NA NA
455 7 2 79 1 7.3 NA 0.0 0.7 0
...
> head(m <- melt(id=1:4, french_fries, na.rm=TRUE))
time treatment subject rep variable value
1 1 1 3 1 potato 2.9
2 1 1 3 2 potato 14.0
...
15. 04. 데이터의 구조의 변형과 요약
> # melt()후에 dcast()를 사용해 원 데이터로 변환하는 예제
> m <- melt(french_fries, id.vars=1:4)
> r <- dcast(m, time + treatment + subject + rep ~ ...)
> rownames(r) <- NULL
> rownames(french_fries) <- NULL
> identical(r, french_fries)
> m <- melt(french_fries, id.vars=1:4)
> dcast(m, time ~ variable)
[1] TRUE
Aggregation function missing: defaulting to length
time potato buttery grassy rancid painty
1 1 72 72 72 72 72
2 2 72 72 72 72 72
…
> dcast(m, time ~ variable, mean, na.rm=TRUE)
time potato buttery grassy rancid painty
1 1 8.562500 2.236111 0.9416667 2.358333 1.645833
2 2 8.059722 2.722222 1.1819444 2.845833 1.444444
…
> dcast(m, time ~ treatment + variable, mean, na.rm=TRUE)
time 1_potato 1_buttery 1_grassy 1_rancid 1_painty 2_potato 2_buttery 2_grassy 2_rancid 2_painty 3_po
1 1 7.925000 1.7958333 0.9041667 2.758333 2.1500000 8.775000 2.491667 0.9958333 1.716667 0.8083333 8.98
2 2 7.591667 2.5250000 1.0041667 3.900000 1.9750000 8.537500 3.125000 0.9500000 2.141667 0.6625000 8.05
17. 05. 데이터 테이블: 더 빠르고 편리한 데이터 프레임
데이터 프레임을 대신 ▶ 속도 개선
• 색인 사용
• 참조를 통한 데이터 갱신 : 데이터 복사에 따른 비용 감소
18. 06. 더 나은 반복문 - foreach
apply 계열 함수, for() 문을 대체할 수 있는 루프문을 위한 함수
반환 값이 있고, {}가 아닌 %do% 문을 사용해 블록 지정
foreach(i=1:5) %do% {
return(i)
}
foreach(i=1:5, .combine=c) %do% {
return(i)
}
foreach(i=1:5, .combine=c) %do% {
return(i)
}
foreach(i=1:5, .combine=rbind) %do% {
return(data.frame(val=i))
}
19. 07. 병렬처리
멀티코어를 활용하여 프로그램을 병렬적으로 수행
Steve Weston이 개발한 doMC와 doParallel 패키지가 대표적
• doMC – multicore, foreach 패키지를 조합, fork사용으로 인한 OS 의존성
• doParallel – multicore, foreach, snow 패키지 조합, snow는 다수의
머신에 클러스터를 구현하는 기능 제공
Process의 수 결정
• CPU intensive vs. I/O(network, file) intensive
적절한 I/O가 있는 경우는 core x 2, CPU intensive한 작업들이 대부분일 경우는 core
개수와 동일하거나 default 값인 core개수의 절반 추천
• Ex. doParallel::registerDoParallel(cores=4)
20. plyr의 병렬화
• {adl}{adl_}ply 함수는 .parallel 옵션을 TRUE 로 설정
foreach의 병렬화
• %do% 대신 %dopar% 를 지정
가용 메모리 확인을 통해 스래싱thrashing 현상 여부 파악
• 시스템의 가용 메모리가 바닥
• 스와핑으로 인한 디스크 I/O가 지속적으로 발생
• R 프로세스의 CPU 사용량이 낮다.
21. 08. 유닛테스팅과 디버깅
Unit Testing은 단위코드가 의도대로 동작하는지 코드를 통해
검증하는 방법
일반적 사용 상황 및 특이 사용 상황(Corner Case) 테스트
테스트 코드를 통해 코드의 사용 방법을 설명하는 Documentation의
역할을 담당
함수의 사용자가 함수로부터 어떤 것을 기대할지를 미리 생각하게
하는 TDD(Test Driven Development)가 가능
UnitTesting Packages in R
• RUnit, testthat
22. 08. 유닛테스팅과 디버깅
testthat::expect 함수들
• 기대값(expected value)값이 실제 반환값과(return value) 동일한지 확인
Package 용도
expect_true(x) x가 참인가?
expect_false(x) x가 거짓인가?
expect_equal(object, expected) Object가 기대값 expected와 동일한가? 값의 비교에는
all.equal() 사용하며 두 객체가 거의 같은지를 비교. 부동소수의
경우 epsilon(매우 작은 값) 이하로 차이는 동일한 것으로 취급
expect_equivalent(x, y) x가 y와 동등한가? expect_equal()과 달리 속성
(ex. rownames)을 제외한 값만 비교
23. 08. 유닛테스팅과 디버깅
> a <- 1:3
> b <- 1:3
> expect_equal(a, b)
> expect_equivalent(a, b)
> names(a) <- c('a', 'b', 'c')
> expect_equal(a, b)
Error: a not equal to b
names for current but not for target
> expect_equivalent(a, b)
>
24. Debugging
• print(), sprintf(), cat()을 사용하여 메시지나 객체의 내용을 출력
• browser()를 사용한 코드 디버깅
메시지 출력을 통한 디버깅
• print(x) – 값을 출력
• sprintf() – C언어 스타일로 문자열 포맷팅
• cat() – 값들을 붙여서 출력
• browser() – 코드의 실행을 중지하고 현재 환경(environmen)을 조사
26. 09. 코드 수행 시간 측정
수행 시간 측정 및 프로파일링 수행을 통해 병목 구간 파악
명령문 수행 시간 측정
• system.time(expr)
• user time, system time, elapsed time
Elasped Time은 User mode와 Kernel mode에서 수행한 시간으로 구성
코드 프로파일링
• 프로그램의 동적인 성능, 즉 메모리나 CPU 사용량을 평가하는 작업을 의미
• Rprof()
특정 시간 간격마다 수행 중인 함수를 샘플링하여 분석에 사용