본문 바로가기

R

(4)
tidyr:: (3) iris data에 적용해보자 (+pivot_longer) 여담 line -------------------------------------------------------------- 원래 굳이 응용까지 할 생각은 없었는데 내 데이터에 tidyr의 spread 함수가 안굴러가더라... 왜 안되나 구글링해보다가 iris data 분석한 걸 찾았다. 한번 따라해보다가 기록해둬야될 것 같아 글로 적는다. 각설하고 시작하자 --------------------------------------------------------------------------- 참고 페이지: https://stackoverflow.com/questions/60083062/tidyrspread-error-each-row-of-output-must-be-identified-by-a-uniqu..
tidyr:: (2) Split or combine: separate, separate_rows, unite [참고 페이지] https://m.blog.naver.com/bosongmoon/221587219214 https://gomguard.tistory.com/22 (추가 argument 설명 有) 지금 설명할 것은, 'Use these functions to split or combine cells into individual, isolated values'에 관련된 두 함수다. Spilt or combine Cells (1) separate(data, col, into, sep, remove = T, convert = F, extra = "warn", fill = "warn", ...) table3 %>% separate(rate, into= c("'cases', 'pop')) 또는, separate(t..
tidyr:: (1) reshape function: gather, spread [참고 페이지] https://m.blog.naver.com/bosongmoon/221587219214 https://gomguard.tistory.com/22 지금 설명할 것은, 'Reshape data: change the layout of values in a table'에 관련된 두 함수다. Reshape Data 1. gather(data, key, value, ..., na.rm = F, convert = F, factor_key = F) table4a %>% gather('1999', '2000', key='year', value='cases') 또는, gather(table4a, '1999', '2000', key='year', value='cases') = columns: 1999, 20..
'tidyverse' package 여담: 아주 오랜만에 티스토리글을 쓴다... 완전 잊었음... 그치만 예상했다 작심삼일 - 사라 = 0 이니깐 아무튼 각설하고 tidy 패키지를 정리해야할 것 같아 들고왔다 내가 정말 필요로 했던 기능도 발견했기 때문! (이건 tidyr로 ㄱㄱ) 0. Tidy data란? Hadley Wickham(2016)에 따르면 tidy data는 아래 세 가지 규칙을 갖는다고 합니다. 하나의 변수는 하나의 세로줄을 형성한다. (Each variable forms a column: Variables in columns) 하나의 관측치는 하나의 가로줄을 형성한다. (Each observation forms a row: observations in rows) 하나의 변수의 종류별로 하나의 표를 형성한다. (Each t..