tibble Questions
4
Solved
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(...
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...
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...
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...
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...
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...
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
...
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...
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...
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...
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...
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...
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...
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...
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 ...
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> <...
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...
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...
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...
1
Solved
Is it possible to name a column of a tibble using a variable containing a character vector (string)?
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.
...
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()...
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...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.