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

Vector from tibble has length 0

I have a tibble ('df') with > dim(df) [1] 55 144 of which I extract a vector test <- c(df[,39]). I would expect the following result: > length(test) [1] 55 as I basically took column 39 from my tibble. Instead, I get > length(test) [1] 1 Now,…
Lukas
  • 424
  • 3
  • 6
  • 17
0
votes
1 answer

Reorder all strings in a Column of a Dataframe R

I'm trying to reorder a string in a dataframe for all of the values in a column. I have values such as: F123/1K F234/2Q F678/8W and I want it to look like: K1231 Q2342 W6788 Is there a way to change all the strings at once rather than the crude…
MaskedMonkey
  • 107
  • 1
  • 6
0
votes
2 answers

R Tibble/Dataframe to JSON where the key is the first column?

I have a tibble/dataframe that look like this: aspect Col1 Col2 Col3 Col4 ac1 0 2.874891e-05 0.0089479233 -0.0603030498 ac2 0 1.666263e-06 0.0057062434 0 ac3 0 -1.146331e-06 0.0171818879 0 ac4…
SteveS
  • 3,789
  • 5
  • 30
  • 64
0
votes
2 answers

convert lists of vectors in just one tibble data frame

I have two lists. Each of them with many vectors (around 500) of different lengths and I would like to get a tibble data frame with three columns. My reproducible example is the following: > a [[1]] [1] 1 3 6 [[2]] [1] 5 4 > b [[1]] [1] 3…
Citizen
  • 121
  • 15
0
votes
1 answer

How to keep all variables using sapply?

I have a tbl (EU_28), the head of which looks like this: # A tibble: 5 x 22 `Member State` `1997` `1998` `1999` `2000` `2001` `2002` `2003` `2004` `2005` `2006` `2007`
geoffest
  • 39
  • 6
0
votes
1 answer

Tibble/Data_frame is not rounding using mutate_if()

I've got a tibble with similar characteristics to this: set.seed(123) df <- tibble( x = sample(LETTERS[1:3],10,T), y = rdunif(10,7.5), z = rdunif(10,7.5) ) Which yields: # A tibble: 10 x 3 x y z 1 A …
elliot
  • 1,844
  • 16
  • 45
0
votes
1 answer

View in RStudio a table with crossed data of two labelled of a tibble

If I have a data frame (or a tibble) df as the following: x <- c(2,2,2,1,1,2,3) y <- c(5,5,4,5,4,4,5) df <- data.frame(x,y) Then, if I cross data with the instruction table(df$x,df$y) I get a matrix form: 4 5 1 1 1 2 2 2 3 0 …
iago
  • 2,990
  • 4
  • 21
  • 27
0
votes
1 answer

Unnesting lists of different depth in a tibble

I've got a tibble that has nested lists of different depths in different columns. Each list has only one value in it or is NULL. How do I extract these into a normal tibble/dataframe with row and column single values. I can't get purrr:map_* to…
Scott Bell
  • 161
  • 2
  • 11
0
votes
1 answer

Efficient method to add a column to a listcolumn in r

How can I create a new column within a listcolumn? I can only do it by mutating into a new listcolumn. Moreover, I find that the double mutation below is quite slow compared to the other methods. Does mutate add a lot of…
Misha
  • 3,114
  • 8
  • 39
  • 60
0
votes
1 answer

Read a set of files into a matrix in R

I am trying to read a set of tab separated files into a matrix or data.frame. For each file I need to extract one column and then concatenate all the columns into a single matrix keeping both column and row names. I am using tidyverse (and I am…
ftabaro
  • 136
  • 11
0
votes
1 answer

Set an option in the R tibble package

The tibble package at version 1.4.2 has options which are listed in the documentation under tibble-options. For example, one such option is tibble.max_extra_cols which defaults to 100. How does one access and set these options?
peter2108
  • 5,580
  • 6
  • 24
  • 18
0
votes
1 answer

R: Which is the tidy way to apply a function over various columns of each row of a data frame?

I would like to apply a function to all rows of a data frame where each application the columns as distinct inputs (not like mean, rather as parameters). I wonder what the tidy way is to do the following: # Data successes <-…
Richi W
  • 3,534
  • 4
  • 20
  • 39
0
votes
1 answer

how can I ignore a character variable in a comparison operator on a tibble?

I have a tibble (dataframe) and I would like to select numeric elements greater than some number (e.g., 20) and update them to a new value (e.g., 0) like this: mtcars_tbl <- as_tibble(rownames_to_column(mtcars)) mtcars_tbl[mtcars_tbl > 20] <-…
sometimes_sci
  • 183
  • 1
  • 10
0
votes
1 answer

R tibble error when training

I'm training a model with Caret package. The training table if fine and I don't do any changes to it. Why then am I getting the Setting row names on a tibble is deprecated. error?
mRiddle
  • 214
  • 1
  • 7
  • 22
0
votes
2 answers

R - Appending column to data frame. Match by year.

New to R. Brain size of pea. Suppose I have two separate data frames. df1 = tibble( date = as.Date(c("1990-10-01", "1991-11-01", "1992-11-01")), wage = c(4, 5, 6) ) df2 = tibble( date = as.Date(c("1990-01-01", "1991-01-01", "1992-01-01")), …
ixodid
  • 2,180
  • 1
  • 19
  • 46