Questions tagged [tibble]

tibble could refer to an R class (tbl_df class), which is an improved data frame with stricter checking and better formatting. tibble could also refer to an R package providing functions to create and manipulate a tibble.

1309 questions
6
votes
1 answer

Sequential evaluation of named arguments in R

I am trying to understand how to succinctly implement something like the argument capture/parsing/evaluation mechanism that enables the following behavior with dplyr::tibble() (FKA dplyr::data_frame()): # `b` finds `a` in previous…
lefft
  • 2,065
  • 13
  • 20
5
votes
3 answers

Read whitespace-delimited Stack Overflow data with row numbers directly into R

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…
dcsuka
  • 2,922
  • 3
  • 6
  • 27
5
votes
3 answers

Transpose a tibble

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 tibble: tibble(Cor = c("a,b","b,c"), Linear = c("x1","x3"), Rank = c("x2","x4") ) Is…
GiulioGCantone
  • 195
  • 1
  • 10
5
votes
4 answers

How to add a row to each group and assign values

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 1 one 1 4 2 two 2 5 3 three 3 …
TarJae
  • 72,363
  • 6
  • 19
  • 66
5
votes
3 answers

How to identify row that matches vector

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 have a tibble with a single row, which came directly from…
Érico Patto
  • 1,015
  • 4
  • 18
5
votes
4 answers

Convert list of lists into single nested row of a data.frame or tibble (R)

I have a nested list of lists: data = list(a = list(1, 2, 3), b = list("foo"), c = list("toast", "onions")) How can I convert this into a single row of a data.frame or tibble? I would like the lists with more than one element (a and c here) to be…
D Greenwood
  • 415
  • 2
  • 11
5
votes
1 answer

What is the error `vec_assign()`: `value` should have been recycled to fit `x`. trying to tell me

I have a function that does some basic web harvesting. This function is called after a successful login. (website has been masked xxxxxx) Search Function: search <-function(HorseList){ url <- "http://tnetwork.xxxxxx.com/tnet/HorseSearch.aspx" s…
Mutuelinvestor
  • 3,384
  • 10
  • 44
  • 75
5
votes
2 answers

Applying simple function via across within nested data on each group

Background Given nested data, I would like to apply a simple function using across on an arbitrary selection of columns. Using across I want to iterate over the selection of columns passed to one argument of the function and keep the second argument…
Konrad
  • 17,740
  • 16
  • 106
  • 167
5
votes
4 answers

Embedding a script within a for-loop in R

I have a dataframe in R that looks something like this: library(tibble) sample <- tribble(~subj, ~session, "A", 1, "A", 2, "A", 3, "B", 1, "B", 2, "C", 1, "C",…
Catherine Laing
  • 475
  • 6
  • 18
5
votes
2 answers

How to remove the temporal component in an aggregation of a tsibble object?

I have been working with the tsibble package and I can't get how is the proper way to remove the time component from the aggregation result. So in the following dataset, I want to have the mean trips by Region and State. Is the proper way to convert…
User2321
  • 2,952
  • 23
  • 46
5
votes
2 answers

How to convert scientific notation to decimal in tibbles?

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() %>% broom::tidy(). library(tidyverse) ## I used…
Emman
  • 3,695
  • 2
  • 20
  • 44
5
votes
4 answers

What is the best way to transform an xts into a tibble

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), order.by = seq.Date(from = as.Date("2019-02-26"), …
Cettt
  • 11,460
  • 7
  • 35
  • 58
5
votes
1 answer

'as.tibble' causes error in tibble 2.0.1 but not 1.4.2

I have written a function part of which converts a matrix to a tibble. This works without issues in tibble 1.4.2 but causes an error in 2.0.1. The code that causes the error is as follows library(tibble) library(magrittr) testmerge <- matrix( data =…
Jonno Bourne
  • 1,931
  • 1
  • 22
  • 45
5
votes
2 answers

dplyr unquoting does not work with filter function

maybe I am missing something, but I can't seem to make dplyr's unquoting operator to work with the filter function. It does with with select, but not with filter... Example set.seed(1234) A = matrix(rnorm(100),nrow = 10, ncol = 10) colnames(A)…
Jean_N
  • 489
  • 1
  • 4
  • 19
5
votes
2 answers

Problem using dplyr on tibbles with vector elements [list columns]

I am running into some problems doing text processing using dplyr and stringr functions (specifically str_split()). I think I am misunderstanding something very fundamental about how to use dplyr correctly when dealing with elements that are…
Angelo
  • 2,936
  • 5
  • 29
  • 44