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
0
votes
1 answer

Create column of a tibble (or data frame) that contains a list from a long-format tibble

I have objects that have varying numbers of events at varying times. This is currently stored in a long format (using tibbles from library(tidyverse)) : timing_tbl <- tibble(ID = c(101,101,101,102,102,103,103,103,103), …
kazap
  • 3
  • 3
0
votes
3 answers

Convert multiple characters vectors to factors on a tibble

I used read_csv() to import a file into R. Now I wish to convert various character vectors to factors. I used this code and it worked fine. library(readr) library(tibble) activos_dic_2017$DESCRI_RIESGO <-…
Dennis Aguilar
  • 113
  • 1
  • 7
0
votes
1 answer

Turn list of different length vectors into a `tibble`

I currently have a list of character vectors that are different lengths. Like this: list( c('this','is','first'), c('this','is','second','it','longer'), c('this is a list','that is length 2') ) I'd like to combine all the elements of each…
elliot
  • 1,844
  • 16
  • 45
0
votes
1 answer

cut() and label eveything in tibble by the same breaks and labels

I got a tibble that is 8984 times 155 where I need to cut() and label all all columns in the same way, i.e. using the same cut and the same labels to create a new labeled tibble. How do I do this in a simple way? Here a 3 times 3 tibble to simulate…
Eric Fail
  • 8,191
  • 8
  • 72
  • 128
0
votes
1 answer

R - Creating DFs (tibbles) in a loop. How to rename them and columns inside, to include date? (I do it with eval(..), but is there a better solution?)

I have a loop, that creates a tibble at the end of each iteration, tbl. Loop uses different date each time, date. Assume: tbl <- tibble(colA=1:5,colB=5:10) date <- as.Date("2017-02-28") > tbl # A tibble: 5 x 2 colA colB 1 …
phemark
  • 3
  • 1
  • 5
0
votes
1 answer

Left join a list of irregular lists to a dataframe based on list names

Let's say I have a data.frame called countDF: > countDF date count complete 1 20180124 16 FALSE 2 20180123 24 TRUE 3 20180122 24 TRUE 4 20180121 24 TRUE 5 20180120 23 FALSE 6 20180119 23 FALSE 7 20180118 …
d8aninja
  • 3,233
  • 4
  • 36
  • 60
0
votes
1 answer

Do you need to cast to data.frame in order to convert rownames before casting to tibble

I use a gene expression package that outputs a named matrix. In order to get this into a tibble, I always have to first cast it to a data.frame so that I can then convert the rownames. Is there a shorter way of doing this?…
kmace
  • 1,994
  • 3
  • 23
  • 39
0
votes
3 answers

Merging Tibbles, but overriding missing values

I'm joining the following two tibbles using full_join: library(dplyr) library(tibble) tibble(id=c(1:2, NA), b = c("mouse", "cat", "fish"), c = 6:8) %>% full_join(tibble(id=1:3, b = c("mouse", "", "fish"), c = 6:8)) This will give me: A tibble:…
Nina
  • 91
  • 7
0
votes
2 answers

Creating tibble or data frame of tibbles or data frames and other class

Is it possible to create a tibble or data.frame, which has columns that are integers and other columns that are tibbles or data.frames? E.g.: library(tibble) set.seed(1) df.1 <- tibble(name=sample(LETTERS,20,replace =…
dan
  • 6,048
  • 10
  • 57
  • 125
0
votes
2 answers

Categorical Variables Table with Percentages in R

I have a series of categorical variables that have the response options (Favorable, Unfavorable, Neutral). I want to create a table in R that will give the list of all 10 variables in rows (one variable per row) - with the percentage response…
Steve
  • 13
  • 1
  • 3
0
votes
1 answer

Join dataframe (tibble) with different column names

I'm looking for a dplyr solution to merge two df (or tibble) in dplyr, when they have the same langth, but different column names. The solutions I found so far relate to a common column name, joined through the by = "" field. The structure: df1 A…
Christopher
  • 2,120
  • 7
  • 31
  • 58
0
votes
0 answers

Remove rowid (not rowname) from tibble

How can I remove the rowid from a tibble? Example: require(tibble) tibble(x = letters[1:3], y = letters[4:6]) # A tibble: 3 x 2 x y 1 a d 2 b e 3 c f I want to remove 1,2,3. Note I: the rowid…
Manuel R
  • 3,976
  • 4
  • 28
  • 41
0
votes
0 answers

How to add lists to a tibble

I am defining two functions as follows: load <- function(rate, servicetime){ # Calculates Offered Load in Erlang # rate: Rate of arrivals # servicetime: Mean time for service a = rate * servicetime return(list(load = a, rate =…
fr3d-5
  • 792
  • 1
  • 6
  • 27
0
votes
0 answers

R: Adding a title to a ggplot stored in a column of a tibble, based on another column

I have a nested tibble that stores data, a grouping variable and a plot illustrating the data. Consider the following example: library(dplyr) library(tibble) library(ggplot2) test <- tibble(x=c(1,2), p=list(qplot(1), qplot(2))) Column p are the…
Vertho
  • 200
  • 1
  • 7
0
votes
1 answer

Matching data with duplicates for self-update with different sources in R

I have a set of data with duplicates: x <- tibble(num=c(1,2,3,2,5,5,8), alph=NA) And separate sources giving their corresponding values. y <- tibble(num=1:4, alph=LETTERS[1:4]) z <- tibble(num=5:10, alph=LETTERS[5:10]) Normally, one would use…
Sati
  • 716
  • 6
  • 27