Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A modern re-imagining of the data frame

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

tidyverse/tibble

R-CMD-checkCodecov test coverageCRAN_Status_BadgeLife cycle

Overview

Atibble, ortbl_df, is a modern reimagining of the data.frame,keeping what time has proven to be effective, and throwing out what isnot. Tibbles are data.frames that are lazy and surly: they do less(i.e. they don’t change variable names or types, and don’t do partialmatching) and complain more (e.g. when a variable does not exist). Thisforces you to confront problems earlier, typically leading to cleaner,more expressive code. Tibbles also have an enhancedprint() methodwhich makes them easier to use with large datasets containing complexobjects.

If you are new to tibbles, the best place to start is thetibbleschapter inR for data science.

Installation

# The easiest way to get tibble is to install the whole tidyverse:install.packages("tidyverse")# Alternatively, install just tibble:install.packages("tibble")# Or the the development version from GitHub:# install.packages("pak")pak::pak("tidyverse/tibble")

Usage

library(tibble)

Create a tibble from an existing object withas_tibble():

data<-data.frame(a=1:3,b=letters[1:3],c= Sys.Date()-1:3)data#>   a b          c#> 1 1 a 2025-06-18#> 2 2 b 2025-06-17#> 3 3 c 2025-06-16as_tibble(data)#> # A tibble: 3 × 3#>       a b     c#>   <int> <chr> <date>#> 1     1 a     2025-06-18#> 2     2 b     2025-06-17#> 3     3 c     2025-06-16

This will work for reasonable inputs that are already data.frames,lists, matrices, or tables.

You can also create a new tibble from column vectors withtibble():

tibble(x=1:5,y=1,z=x^2+y)#> # A tibble: 5 × 3#>       x     y     z#>   <int> <dbl> <dbl>#> 1     1     1     2#> 2     2     1     5#> 3     3     1    10#> 4     4     1    17#> 5     5     1    26

tibble() does much less thandata.frame(): it never changes the typeof the inputs (e.g. it keeps list columns as is), it never changes thenames of variables, it only recycles inputs of length 1, and it nevercreatesrow.names(). You can read more about these features invignette("tibble").

You can define a tibble row-by-row withtribble():

tribble(~x,~y,~z,"a",2,3.6,"b",1,8.5)#> # A tibble: 2 × 3#>   x         y     z#>   <chr> <dbl> <dbl>#> 1 a         2   3.6#> 2 b         1   8.5

Related work

The tibble print method draws inspiration fromdata.table, andframe. Likedata.table::data.table(),tibble() doesn’t change column names anddoesn’t use rownames.


Code of Conduct

Please note that the tibble project is released with aContributor Codeof Conduct. Bycontributing to this project, you agree to abide by its terms.

About

A modern re-imagining of the data frame

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors70

Languages


[8]ページ先頭

©2009-2025 Movatter.jp