Skip to Content
R Cookbook
book

R Cookbook

by JD Long, Paul Titer, Jee -Won Lee
May 2022
Beginner to intermediate
667 pages
16h 17m
Korean
Insight
Content preview from R Cookbook
R
208
6장 데이터 변형
6.1
󺹻󻝳󼞇󻰧󽴔󺃐󽴔󻮟󻙛󻪟󽴔󼨷󻛧󽴔󻳐󻭸󼨧󺋿
󻀇󻳫
리스트가 있고, 리스트의 각 원소에 함수를 적용하고 싶다.
󼩃󺅿󼄔
리스트의 각 원소에 함수를 적용하기 위해
map
을 사용한다.
library(tidyverse)
lst %>%
map(fun)
󺙋󻰧
리스트의 각 원소별로, 모든 숫자의 평균을 구하는 예시를 살펴보자.
library(tidyverse)
lst <- list(
a = c(1,2,3),
b = c(4,5,6)
)
lst %>%
map(mean)
#> $a
#> [1] 2
#>
#> $b
#> [1] 5
map
함수는 리스트의 원소마다 여러분의 함수를 호출하게 된다. 여러분의 함수는 하
나의 인자를 받아야 하는데, 바로 리스트의 원소 한 개가 되겠다. 그러면
map
함수는
반환된 값들을 모아서 리스트로 반환해 준다.
purrr
패키지는 리스트나 벡터를 받아 입력과 동일한 수의 원소로 이루어진 객체
를 반환하는
map
함수 계열 전체를 포함하고 있다. 반환되는 객체의 종류는 어떤
map
함수를 사용하느냐에 따라 달라진다. 관련 함수들의 목록은
map
함수의 도움말 파일
을 참고하면 되며, 그중 자주 사용하는 것을 몇 가지 소개하면 다음과 같다.
R Cookbook 2판_최종.indd 208 21. 4. 27. 오전 11:07
Cookbook
209
6.1 리스트의 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

R Cookbook

R Cookbook

Paul Teetor
R Graphics Cookbook

R Graphics Cookbook

Winston Chang
R Cookbook, 2nd Edition

R Cookbook, 2nd Edition

JD Long, Paul Teetor

Publisher Resources

ISBN: 9788966262984