名前:niszet*
Rおじさん歴:2年目
趣味:R、楽器(お休み中)、ラズパイなど
普段は回路設計などしています
iris
とか。コンソール上に全部表示されてしまう…summary()
, fivenum()
, IRQ()
, skimr::skim()
, …plot()
, hist()
, ggplot2
, plotly
, …str()
, View()
, class()
, attributes()
, typeof()
, ……など。今回はlistに注目。
str()
でデータの構造を確認するstr()
の出力はコンソールに直接表示。
head()
も出来ない。## List of 4
## $ a: int [1:10] 1 2 3 4 5 6 7 8 9 10
## $ b: num 2
## $ c: chr "b"
## $ d: cplx 1+3i
## NULL
str()
では見きれない## List of 6
## $ :List of 30
## ..$ login : chr "gaborcsardi"
## ..$ id : int 660288
## ..$ avatar_url : chr "https://avatars.githubusercontent.com/u/660288?v=3"
## ..$ gravatar_id : chr ""
## ..$ url : chr "https://api.github.com/users/gaborcsardi"
## ..$ html_url : chr "https://github.com/gaborcsardi"
## ..$ followers_url : chr "https://api.github.com/users/gaborcsardi/followers"
## ..$ following_url : chr "https://api.github.com/users/gaborcsardi/following{/other_user}"
## ..$ gists_url : chr "https://api.github.com/users/gaborcsardi/gists{/gist_id}"
## ..$ starred_url : chr "https://api.github.com/users/gaborcsardi/starred{/owner}{/repo}"
## ..$ subscriptions_url : chr "https://api.github.com/users/gaborcsardi/subscriptions"
## ..$ organizations_url : chr "https://api.github.com/users/gaborcsardi/orgs"
## ..$ repos_url : chr "https://api.github.com/users/gaborcsardi/repos"
## ..$ events_url : chr "https://api.github.com/users/gaborcsardi/events{/privacy}"
## ..$ received_events_url: chr "https://api.github.com/users/gaborcsardi/received_events"
## ..$ type : chr "User"
## ..$ site_admin : logi FALSE
## ..$ name : chr "Gabor Csardi"
## ..$ company : chr "Mango Solutions, @MangoTheCat "
## ..$ blog : chr "http://gaborcsardi.org"
## ..$ location : chr "Chippenham, UK"
## ..$ email : chr "csardi.gabor@gmail.com"
## ..$ hireable : NULL
## ..$ bio : NULL
## ..$ public_repos : int 52
## ..$ public_gists : int 6
## ..$ followers : int 303
## ..$ following : int 22
## ..$ created_at : chr "2011-03-09T17:29:25Z"
## ..$ updated_at : chr "2016-10-11T11:05:06Z"
## $ :List of 30
## ..$ login : chr "jennybc"
## ..$ id : int 599454
## ..$ avatar_url : chr "https://avatars.githubusercontent.com/u/599454?v=3"
## ..$ gravatar_id : chr ""
## ..$ url : chr "https://api.github.com/users/jennybc"
## ..$ html_url : chr "https://github.com/jennybc"
## ..$ followers_url : chr "https://api.github.com/users/jennybc/followers"
## ..$ following_url : chr "https://api.github.com/users/jennybc/following{/other_user}"
## ..$ gists_url : chr "https://api.github.com/users/jennybc/gists{/gist_id}"
## ..$ starred_url : chr "https://api.github.com/users/jennybc/starred{/owner}{/repo}"
## ..$ subscriptions_url : chr "https://api.github.com/users/jennybc/subscriptions"
## ..$ organizations_url : chr "https://api.github.com/users/jennybc/orgs"
## ..$ repos_url : chr "https://api.github.com/users/jennybc/repos"
## ..$ events_url : chr "https://api.github.com/users/jennybc/events{/privacy}"
## ..$ received_events_url: chr "https://api.github.com/users/jennybc/received_events"
## ..$ type : chr "User"
## ..$ site_admin : logi FALSE
## ..$ name : chr "Jennifer (Jenny) Bryan"
## ..$ company : chr "University of British Columbia"
## ..$ blog : chr "https://twitter.com/JennyBryan"
## ..$ location : chr "Vancouver, BC, Canada"
## ..$ email : NULL
## ..$ hireable : NULL
## ..$ bio : chr "prof at UBC, humane #rstats, statistics, teach @STAT545-UBC, leadership of @rOpenSci, @rsheets, academic director @ubc-mds"
## ..$ public_repos : int 168
## ..$ public_gists : int 54
## ..$ followers : int 780
## ..$ following : int 34
## ..$ created_at : chr "2011-02-03T22:37:41Z"
## ..$ updated_at : chr "2016-10-24T07:20:26Z"
## $ :List of 30
## ..$ login : chr "jtleek"
## ..$ id : int 1571674
## ..$ avatar_url : chr "https://avatars.githubusercontent.com/u/1571674?v=3"
## ..$ gravatar_id : chr ""
## ..$ url : chr "https://api.github.com/users/jtleek"
## ..$ html_url : chr "https://github.com/jtleek"
## ..$ followers_url : chr "https://api.github.com/users/jtleek/followers"
## ..$ following_url : chr "https://api.github.com/users/jtleek/following{/other_user}"
## ..$ gists_url : chr "https://api.github.com/users/jtleek/gists{/gist_id}"
## ..$ starred_url : chr "https://api.github.com/users/jtleek/starred{/owner}{/repo}"
## ..$ subscriptions_url : chr "https://api.github.com/users/jtleek/subscriptions"
## ..$ organizations_url : chr "https://api.github.com/users/jtleek/orgs"
## ..$ repos_url : chr "https://api.github.com/users/jtleek/repos"
## ..$ events_url : chr "https://api.github.com/users/jtleek/events{/privacy}"
## ..$ received_events_url: chr "https://api.github.com/users/jtleek/received_events"
## ..$ type : chr "User"
## ..$ site_admin : logi FALSE
## ..$ name : chr "Jeff L."
## ..$ company : NULL
## ..$ blog : chr "http://biostat.jhsph.edu/~jleek/"
## ..$ location : chr "Baltimore,MD"
## ..$ email : NULL
## ..$ hireable : NULL
## ..$ bio : NULL
## ..$ public_repos : int 67
## ..$ public_gists : int 12
## ..$ followers : int 3958
## ..$ following : int 6
## ..$ created_at : chr "2012-03-24T18:16:43Z"
## ..$ updated_at : chr "2016-10-05T13:03:04Z"
## $ :List of 30
## ..$ login : chr "juliasilge"
## ..$ id : int 12505835
## ..$ avatar_url : chr "https://avatars.githubusercontent.com/u/12505835?v=3"
## ..$ gravatar_id : chr ""
## ..$ url : chr "https://api.github.com/users/juliasilge"
## ..$ html_url : chr "https://github.com/juliasilge"
## ..$ followers_url : chr "https://api.github.com/users/juliasilge/followers"
## ..$ following_url : chr "https://api.github.com/users/juliasilge/following{/other_user}"
## ..$ gists_url : chr "https://api.github.com/users/juliasilge/gists{/gist_id}"
## ..$ starred_url : chr "https://api.github.com/users/juliasilge/starred{/owner}{/repo}"
## ..$ subscriptions_url : chr "https://api.github.com/users/juliasilge/subscriptions"
## ..$ organizations_url : chr "https://api.github.com/users/juliasilge/orgs"
## ..$ repos_url : chr "https://api.github.com/users/juliasilge/repos"
## ..$ events_url : chr "https://api.github.com/users/juliasilge/events{/privacy}"
## ..$ received_events_url: chr "https://api.github.com/users/juliasilge/received_events"
## ..$ type : chr "User"
## ..$ site_admin : logi FALSE
## ..$ name : chr "Julia Silge"
## ..$ company : NULL
## ..$ blog : chr "juliasilge.com"
## ..$ location : chr "Salt Lake City, UT"
## ..$ email : NULL
## ..$ hireable : NULL
## ..$ bio : chr "Data science and visualization, #rstats, parenthood, reading, food/wine/coffee, #NASADatanauts."
## ..$ public_repos : int 26
## ..$ public_gists : int 4
## ..$ followers : int 115
## ..$ following : int 10
## ..$ created_at : chr "2015-05-19T02:51:23Z"
## ..$ updated_at : chr "2016-10-20T10:41:43Z"
## $ :List of 30
## ..$ login : chr "leeper"
## ..$ id : int 3505428
## ..$ avatar_url : chr "https://avatars.githubusercontent.com/u/3505428?v=3"
## ..$ gravatar_id : chr ""
## ..$ url : chr "https://api.github.com/users/leeper"
## ..$ html_url : chr "https://github.com/leeper"
## ..$ followers_url : chr "https://api.github.com/users/leeper/followers"
## ..$ following_url : chr "https://api.github.com/users/leeper/following{/other_user}"
## ..$ gists_url : chr "https://api.github.com/users/leeper/gists{/gist_id}"
## ..$ starred_url : chr "https://api.github.com/users/leeper/starred{/owner}{/repo}"
## ..$ subscriptions_url : chr "https://api.github.com/users/leeper/subscriptions"
## ..$ organizations_url : chr "https://api.github.com/users/leeper/orgs"
## ..$ repos_url : chr "https://api.github.com/users/leeper/repos"
## ..$ events_url : chr "https://api.github.com/users/leeper/events{/privacy}"
## ..$ received_events_url: chr "https://api.github.com/users/leeper/received_events"
## ..$ type : chr "User"
## ..$ site_admin : logi FALSE
## ..$ name : chr "Thomas J. Leeper"
## ..$ company : chr "London School of Economics"
## ..$ blog : chr "http://www.thomasleeper.com"
## ..$ location : chr "London, United Kingdom"
## ..$ email : NULL
## ..$ hireable : logi TRUE
## ..$ bio : chr "Political scientist and R hacker. Interested in open science, public opinion research, surveys, experiments, cr"| __truncated__
## ..$ public_repos : int 99
## ..$ public_gists : int 46
## ..$ followers : int 213
## ..$ following : int 230
## ..$ created_at : chr "2013-02-07T21:07:00Z"
## ..$ updated_at : chr "2016-10-20T10:36:25Z"
## $ :List of 30
## ..$ login : chr "masalmon"
## ..$ id : int 8360597
## ..$ avatar_url : chr "https://avatars.githubusercontent.com/u/8360597?v=3"
## ..$ gravatar_id : chr ""
## ..$ url : chr "https://api.github.com/users/masalmon"
## ..$ html_url : chr "https://github.com/masalmon"
## ..$ followers_url : chr "https://api.github.com/users/masalmon/followers"
## ..$ following_url : chr "https://api.github.com/users/masalmon/following{/other_user}"
## ..$ gists_url : chr "https://api.github.com/users/masalmon/gists{/gist_id}"
## ..$ starred_url : chr "https://api.github.com/users/masalmon/starred{/owner}{/repo}"
## ..$ subscriptions_url : chr "https://api.github.com/users/masalmon/subscriptions"
## ..$ organizations_url : chr "https://api.github.com/users/masalmon/orgs"
## ..$ repos_url : chr "https://api.github.com/users/masalmon/repos"
## ..$ events_url : chr "https://api.github.com/users/masalmon/events{/privacy}"
## ..$ received_events_url: chr "https://api.github.com/users/masalmon/received_events"
## ..$ type : chr "User"
## ..$ site_admin : logi FALSE
## ..$ name : chr "Maelle Salmon"
## ..$ company : chr "ISGlobal"
## ..$ blog : chr "https://masalmon.github.io/"
## ..$ location : chr "Barcelona, Spain"
## ..$ email : NULL
## ..$ hireable : NULL
## ..$ bio : chr "I use R for getting, preparing, visualizing and analyzing data mostly about air quality & public health."
## ..$ public_repos : int 31
## ..$ public_gists : int 0
## ..$ followers : int 34
## ..$ following : int 38
## ..$ created_at : chr "2014-08-05T08:10:04Z"
## ..$ updated_at : chr "2016-10-24T09:54:57Z"
str()
と同じ表示が得られる
View()
を使ってデータの階層構造を見るhttps://kevinushey-2018-rstudio-conf.netlify.com/slides.html
View(repurrrsive::gh_users)
kazutanさんの資料をView()
を使い手を動かしながら
視ていくとさらにわかりやすい…!
https://kazutan.github.io/HijiyamaR6/intro_ggplot2.html
ggplot()
にdataを指定した場合とりあえずいい感じにプロットしてみる
g_def_gpoint_null <- ggplot(data = iris, mapping =
aes(x = Sepal.Length, y = Sepal.Width)) + geom_point()
g_def_gpoint_null
View(g_def_gpoint_null)
data
に iris
のデータが入っていることがわかる。
geom_point()
に引数を与えていないので、layers
のdata
は空geom_point()
にdataを指定した場合g_gpoint_iris <- ggplot() + geom_point(data = iris,
mapping = aes(x = Sepal.Length, y = Sepal.Width))
g_gpoint_iris
View(g_gpoint_iris)
geom_point()
に引数を指定したので、top階層のdataは空
View(iris, "hoge")
だとhoge
という変数から値を取ろうとしてしまうためView()
で表示させたタブの表示が更新されない。
View()
で表示するときは先にタブを閉じておくことas.list()
などで変換してからView()
で表示すれば今回の方法が使えるutils::View()
のヘルプを見てもわからないので注意。str()
View()
zeallot
でデータを抜き出す際の確認などに。