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
Cookbook
177
5.16 행렬의 행과 열에 설명이 담긴 이름 붙이기
󺙋󻰧
A
*
B
가 원소 수준의 곱셈이고,
A%
*
%B
가 행렬 곱셈이었던 것을 기억해 내자(레시피
2
.
11
참고).
앞서 말한 모든 함수는 행렬을 반환한다. 앞 함수의 인자들은 행렬이나 데이터 프
레임이다. 데이터 프레임인 경우,
R
은 이것들을 먼저 행렬로 변환한다(데이터 프레
임이 수치형 값만 갖고 있을 경우에나 유용한 기능이기는 하다).
5.16
󼩘󺳻󻰧󽴔󼩘󺇋󽴔󻫃󻪟󽴔󻗳󺽔󻱃󽴔󺟃󺌃󽴔󻱃󺹓󽴔󻉨󻱃󺋿
󻀇󻳫
행렬의 행과 열에 설명이 담긴 이름을 부여하고 싶다.
󼩃󺅿󼄔
모든 행렬에는
rownames
속성과
colnames
속성이 있다. 해당 속성에 문자열로 된 벡
터를 대입하자.
rownames(mat) <- c("
󼩘󻱃󺹓
1", "
󼩘󻱃󺹓
2", ..., "
󼩘󻱃󺹓
N")
colnames(mat) <- c("
󻫃󻱃󺹓
1", "
󻫃󻱃󺹓
2", ..., "
󻫃󻱃󺹓
N")
󺙋󻰧
R
에서는 행렬을 출력할 때 보기 좋도록 행렬의 행과 열에 이름을 부여할 수 있다.
R
은 이름이 정의되어 있는 경우 이름을 출력해 주기 때문에 출력물의 가독성이 높다.
다음 행렬을
IBM
, 마이크로소프트, 구글 주가 사이의 상관관계를 나타내는 행렬이
라고 가정하자.
print(corr
_
mat)
#> [,1] [,2] [,3]
#> [1,] 1.000 0.556 0.390
#> [2,] ...
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