tibble Questions

4

Solved

If I add a new row to the iris dataset with: iris <- as_tibble(iris) > iris %>% add_row(.before=0) # A tibble: 151 × 5 Sepal.Length Sepal.Width Petal.Length Petal.Width Species <d...
Imco asked 13/4, 2017 at 23:41

7

Solved

This code makes a sentence from two different columns in a data frame library(dplyr); library(tibble); library(magrittr) mtcars %>% rownames_to_column(var = "car") %>% sample_n(...
Ovalle asked 17/4, 2024 at 12:0

2

Solved

I am working with data that has significant digits (i.e. digits after the "."). These digits appear when viewing my data both as a variable in base R, and also when the data is stored in a datafram...
Cohligan asked 31/7, 2018 at 20:24

4

I have a tibble named X of multiple columns (over 500) which are named in format of "X"+integer. The tibble looks like this. # A tibble: 7,352 x 561 X1 X2 X3 X4 X5 X6 <dbl> <dbl> &l...
Gca asked 12/2, 2020 at 8:44

2

Solved

I have a data.frame with several columns: set.seed(1) df <- data.frame(cluster=LETTERS[1:4],group=c(rep("m",2),rep("f",2)),point=rnorm(4),err=runif(4,0.1,0.3)) and I'd add another columns whi...
Thomasthomasa asked 2/7, 2018 at 16:46

1

Solved

Given a dataframe: df <- data.frame(Col1 = LETTERS[1:4], Col2 = LETTERS[23:26], Col3 = c(1:4), col4 = c(100:103)) I want to combine column with their column names. I know I can use unite from t...
Campfire asked 22/6, 2023 at 3:52

3

Solved

When editing quarto/rmarkdown documents, I would like RStudio to display inline tibbles the same way as it does in the console, instead of the paginated default printing. Instead of this: I would ...
Washroom asked 20/12, 2022 at 9:34

2

Solved

In R, some functions only work on a data.frame and others only on a tibble or a matrix. Converting my data using as.data.frame or as.matrix often solves this, but I am wondering how the three are d...
Legislate asked 16/11, 2020 at 10:36

3

Solved

Often Stack Overflow R questions can share sample data that is just data.frame output as such, instead of dput: id cate result 1 1 yes 1 2 1 yes NA 3 1 no NA 4 2 no NA 5 2 yes 1 6 2 yes NA ...
Aargau asked 29/7, 2022 at 16:11

5

Solved

I would like to create an empty data frame where the column names are coming from a character vector. for example, if this was my vector: vec <- letters[1:3] I would like create an empty d...
Brail asked 17/10, 2019 at 11:40

6

Solved

I have a vector of column names called tbl_colnames. I would like to create a tibble with 0 rows and length(tbl_colnames) columns. The best way I've found of doing this is... tbl <- as_tibble...
Sabec asked 16/2, 2018 at 19:44

2

I have a csv file weight.csv with the following contents. weight,weight_selfreport 81.5,81.66969147005445 72.6,72.59528130671505 92.9,93.01270417422867 79.4,79.4010889292196 94.6,96.64246823956442...
Synecious asked 6/3, 2019 at 8:8

1

Solved

I'm trying to use pivot_longer to enlongate my dataframe, but I don't need it to be fully long, and would like to output multiple "values" columns. Example: df <- tibble( ids = c(&quo...
Czarra asked 18/3, 2022 at 17:24

3

Solved

In order to prepare the data for plotting I need to add a new row to the data: I have this dataframe: df <- data.frame( test_id = c(1, 1, 1, 1), test_nr = c(1, 1, 1, 1), region = c("A&qu...
Thomasenathomasin asked 12/2, 2022 at 20:43

3

Solved

This is a follow-up question of this How to add a row to a dataframe modifying only some columns. After solving this question I wanted to apply the solution provided by stefan to a larger dataframe...
Geophagy asked 12/2, 2022 at 22:38

3

Solved

I have this tibble: tibble(Cor = c("Linear", "Rank"), `a,b` = c("x1","x2"), `b,c` = c("x3","x4") ) I want to transpose it into this ti...
Buckinghamshire asked 6/2, 2022 at 17:29

2

Solved

I want to enumerate each record of a dataframe/tibble resulted from a grouping. The index is according a defined order. If I use row_number() it does enumerate but within group. But I want that it ...
Rimple asked 11/10, 2018 at 14:13

4

Solved

I have this tibble: library(tibble) library(dplyr) df <- tibble(id = c("one", "two", "three"), A = c(1,2,3), B = c(4,5,6)) id A B <chr> <dbl> &lt...
Contravention asked 2/1, 2022 at 21:26

4

Solved

I have a tibble called df: > class(df) [1] "tbl_df" "tbl" "data.frame" Now I run: > sen <- df[df$my_dummy==0, "col_name"] This returns another tib...
Upanddown asked 7/9, 2021 at 8:25

3

Solved

How does one add metadata to a tibble? I would like a sentence describing each of my variable names such that I could print out the tibble with the associated metadata and if I handed it to someon...
Ballocks asked 8/1, 2018 at 19:55

4

Solved

As of tibble package version 2.0.1 what is the best way to convert an xts object into a tibble? Consider the following example: library(tibble) library(xts) myxts <- xts(matrix(1:4, 2, 2), or...
Erma asked 26/2, 2019 at 15:22

1

Solved

Is there a way to name the column of a tibble using a variable? I want to name the first column below Clade for example. I tried paste() and assign(), but neither function seems to do what I want. ...
Zipangu asked 28/6, 2021 at 21:46

2

Solved

Although basic, I can't find an answer anywhere: how can I disable scientific notation in tibbles, and have the tibble display decimals instead? My data I have a simple tibble, resulted from lm()...
Nullifidian asked 31/1, 2020 at 13:3

2

Solved

I have this df: df <- structure(list(a = 1:5, b = 6:10, c = 11:15, d = c("a", "b", "c", "d", "e"), e = 1:5), row.names = c(NA, -5L), class = c(...
Sexless asked 1/5, 2021 at 14:3

3

Solved

I want to identify which row matches the information in a vector. As an example, I'll use the iris dataset (in tibble format to better approximate my situation): iris %>% as_tibble(). Then I hav...
Decorous asked 2/4, 2021 at 16:54

© 2022 - 2025 — McMap. All rights reserved.