Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
110 views

I am new to R and trying to create two new variables from my dataset. My data frame is called netflix and it contains these relevant columns: date_added and duration Example values: date_added: "...
user31963479's user avatar
-3 votes
0 answers
46 views

Suppose I have df <- data.frame(name=c("Hello", "Hi", "GoodMorning")) I would like to convert "GoodMorning" into "GoodEvening" (of course this is ...
robertspierre's user avatar
0 votes
2 answers
120 views

I have the following dataframe: df <- tribble( ~nuts_code, ~value, "AT", 1, "AT1", NA, "AT2", NA, "BG", NA, "BG1", 10, "BG2"...
robertspierre's user avatar
1 vote
4 answers
193 views

I have the following tibble: eu_df <- structure( list( nuts_code = c( "PT17", "PT17", "PT17", "PT17", "PT17", "PT17", "PT17", &...
robertspierre's user avatar
3 votes
5 answers
180 views

I have two data frames in R that share SOME columns and SOME rows in an arbitrary order. I now want to create a third data frame that has the columns and rows of data frame 1 merged with the ...
deschen's user avatar
  • 11.6k
3 votes
7 answers
332 views

Suppose I have a list of dataframes l. All dataframes are guaranteed to have the same shape and contain the same columns. I would like to combine the columns of those dataframes with a column-specific ...
robertspierre's user avatar
3 votes
1 answer
110 views

I'm working with dbplyr and DuckDB to process very large Parquet files using limited system resources. To make my workflow more efficient, I want to create a custom function that can be seamlessly ...
A.N. O'Nyme's user avatar
4 votes
4 answers
296 views

When printing a tibble, how do I print the cells with nested data types (in list columns)? Let's have a look at two examples: 1. call data type b <- tibble(a = 1, prior = list(call("rnorm"...
Tomas's user avatar
  • 60.2k
3 votes
4 answers
179 views

Say I have data.frame h like this: component hyperpar x 1 i sigma2 1.0 2 envN sigma2 1.0 3 envN sigma2_int 0.1 4 envN sigma2_int ...
Tomas's user avatar
  • 60.2k
2 votes
2 answers
118 views

I am trying to deduct values across a data frame of elements. structure(list(Date = structure(c(20095, 20095, 20095, 20095, 20123, 20123, 20123, 20123), class = "Date"), Type = c("Drip&...
B.Shermeister's user avatar
3 votes
3 answers
214 views

Currently I have a dataframe of bear detections that I want to convert into a binary detection history (14 columns of day1, day2, day3, etc. where: actual_date_out = the date the camera was deployed, ...
Jessie Elliott's user avatar
0 votes
1 answer
116 views

In dplyr filter, how to parse conditions which are stored in string?When there's only one condition, below code can work library(dplyr) conditions_string_1 <- "Species=='versicolor'" iris ...
anderwyang's user avatar
  • 2,547
2 votes
3 answers
164 views

I have some date/time data that has overlapping minutes/hours and I want to calculate how much there is. I'm a little stumped on how to do this. I prefer a tidyverse solution because I'm more familiar ...
Indescribled's user avatar
0 votes
2 answers
84 views

Sometimes, in case report forms the almost-same entries are inserted on a certain day and for some patient. I want to find similar, possibly misspelled comment, per patient and date. Finding the ...
Dieter Menne's user avatar
  • 10.3k
0 votes
1 answer
140 views

I want to extract information from a large df of multiple .docx files. Using the officer package I have so far read all .docx from a folder into 1 df. However I need a way to extract specific sections ...
AudileF's user avatar
  • 462
9 votes
6 answers
360 views

For fun, I would like to track the time when a baby is sleeping or feeding over the course of 24 hours and then visualize this as a pi chart or polar chart so that it resembles a 24-hour clock. Every ...
user3710004's user avatar
1 vote
0 answers
81 views

I am currently learning how to conduct a meta-analysis using this guide: https://bookdown.org/MathiasHarrer/Doing_Meta_Analysis_in_R/ However, I have encountered an issue in Chapter 5 when using ...
MingChe's user avatar
  • 51
3 votes
4 answers
178 views

I have a data frame of names, and each name has a count of individuals, e.g. df = read.table(header=TRUE, text= 'name count a 10 b 1 c 7 d 3') > df name count 1 a 10 2 b ...
user72959's user avatar
  • 119
4 votes
2 answers
175 views

I have a messy data set, which generally resembles the output of the following schools_messy <- tibble::tribble( ~data, "state:maryland", "location:bowie||name:bowie state ...
David Robie's user avatar
0 votes
1 answer
101 views

I have a recurring problem which I have been addressing using a messy approach of multiple passes of pivot_wider and rbinding the results together. This seems inelegant, does anyone have a single ...
Peter's user avatar
  • 152
0 votes
1 answer
137 views

I am trying to get a large dataset prepped to create an ECharts4R sunburst visualization, which requires a hierarchical data structure. What is an efficient way to group by, summarize, and nest data ...
Gingie's user avatar
  • 350
2 votes
3 answers
118 views

I started with a simple example which works, but I don't know how to use within dplyr mutate This works, I get "bcd-234": library(tidyverse) list = c("abc-123", 'bcd-234', 'cde-345'...
Shreko's user avatar
  • 363
-1 votes
3 answers
186 views

It looks like tidyr's drop_na will drop rows if any of the specified columns contain missing values. Example: > library(tidyverse) > df <- data.frame(a=c(1,NA,2,NA), b=c(3,4,NA,NA)) > df ...
robertspierre's user avatar
1 vote
2 answers
135 views

After reading in my data using read_csv() from readr, the command spec() returns "full column specification" for the resulting tibble: > spec(steps) cols( duration = col_double(), ...
Ben's user avatar
  • 821
2 votes
3 answers
138 views

Take the following MWE: df <- data.frame(a=c(TRUE, TRUE, FALSE), b=c(FALSE, TRUE, FALSE)) myvars <- c("a","b") The aim is to build a column c which is row-wise TRUE if one ...
robertspierre's user avatar
3 votes
2 answers
143 views

I am trying to write a function that, using tidyverse tools, will load two CSVs, join them on some key column, and write the joined result to a CSV. I am passing in the names of the key columns as ...
Lee Hachadoorian's user avatar
10 votes
8 answers
752 views

Is there a way to calculate the sum (or mean, etc.) for a range of values that are defined for that row in another column? Here's some sample data: structure(list(start = c("cmi_apr", "...
frandude's user avatar
  • 312
1 vote
2 answers
108 views

I have two data.frames, nests, and nest_days, which contains more days for one nest. I want to do a join, and group by nests (i.e. group by the rows of the first data.frame). I want to keep all ...
Tomas's user avatar
  • 60.2k
0 votes
1 answer
69 views

I would like to know how to add a column of row names in combination with the reframe() function in dplyr. Here's toy data: a grouped dataset with three groups crossed with three conditions and a ...
llewmills's user avatar
  • 3,414
8 votes
4 answers
717 views

I have two data frames I am working with. The first contains information on a cohort of kids. These same kids have been measured multiple times on different days (uniqueID AD_1 indicates child AD ...
Taylor Harman's user avatar
0 votes
2 answers
83 views

I tried to use 'map' to filter a list of dataset. how can I extract the name of dataframe, which is 'YYY' in my code. library(dplyr) library(purrr) df1 <- data.frame(var1=seq(1:10), var2=seq(1:10),...
Stataq's user avatar
  • 2,451
1 vote
1 answer
40 views

I want to visualize the distribution of a variable ('F3A7_1') by plotting a histogram, and right underneath it a boxplot (below the y-axis of the histogram or something). I also want to create this ...
kornpat's user avatar
  • 37
2 votes
1 answer
139 views

In vignette("programming", package = "dplyr") there is the following example code my_summarise2 <- function(data, expr) { data %>% summarise( mean = mean({{ expr }}), ...
moreQthanA's user avatar
2 votes
3 answers
88 views

Unexpected output of set_names() I'm trying to name a list of tibbles using set_names. I expect the names to be "tbl_df, tbl, data.frame" However, the result is "character". Any ...
Rasmus Larsen's user avatar
0 votes
1 answer
69 views

I have a spatial vector (Spatvector) with points arranged in groups. I want to calculate the distance of each point to the first point in the group. Trans2024_df Name Distance_to_first 1 ...
mace's user avatar
  • 508
2 votes
1 answer
73 views

I have this dataframe: mydf <- structure(list(Time = c("T0", "T3", "T3", "T0", "T3", "T3"), Organism = c("BB", "BB&...
aminards's user avatar
  • 459
2 votes
2 answers
350 views

The following code runs fine, but it fails a lintr check and raises a note from devtools::check(), which is preventing me from submitting my package to CRAN. # MINIMAL REPRODUCIBLE EXAMPLE OF ...
Christopher Carroll Smith's user avatar
1 vote
2 answers
59 views

I am trying to do a bar plot, however, is printing multiple lines on each bar. I understand that I might have to aggregate but if I do I need to retain the original columns because I need to fill by ...
Salvador's user avatar
  • 1,973
0 votes
1 answer
55 views

I have a data frame that looks like this: ID Email Name Company TripIdentifier Date1 Campsite1 NumberOfAnimals1 Date2 Campsite2 NumberOfAnimals2 1 1 [email protected] ...
R Beginner's user avatar
2 votes
2 answers
293 views

I'm working with 50 Parquet files (each file is of ~800MB with ~380000 rows and ~8 columns). I need to perform a grouped summarisation in R. Something like: group_by(sample_id, gene1, gene2) %>% ...
Arindam Ghosh's user avatar
1 vote
2 answers
94 views

I'm trying to group data into a grouping variable based on whether or not there is data in specific columns. In other words, if there is data in the same row for V1 & V2 below, then I want to put ...
HelplessStatistician's user avatar
1 vote
3 answers
86 views

I am using survey data and would like to create multiple cross tables with row percentages at once. Below is some dummy data and the way I would create those tables individually. Where I get confused ...
C More's user avatar
  • 31
0 votes
0 answers
31 views

I have the following list of words/phrases: vec <- c("Apple (Red)", "Ginger [Indian]", "Avocado", "Cherry: Spring time") I want to ...
JontroPothon's user avatar
4 votes
5 answers
164 views

I'm relatively new to R. I have a table of data consisting of an id, plus 3 values. library(dplyr) df <- tibble(id=c(1, 2, 3),val_a = c(13,25,42), val_b = c(25,30,0), val_c = c(7,27,21)) df # A ...
Buckaroo Banzai's user avatar
3 votes
5 answers
190 views

Consider the following code: > df <- tibble(gender=c(1,1,0)) > df$male Warning: Unknown or uninitialised column: `male`. NULL How can I convert this specific warning type into an error? I ...
robertspierre's user avatar
2 votes
1 answer
126 views

With {gt}, you can conditionally style cells based on the values in another column in your dataframe. Is there a way to conditionally overwrite the cell display values based on a different column? In ...
Mark Rieke's user avatar
6 votes
6 answers
150 views

I have a data.table object which contains 3 columns (spec_fun, param_1, param_2). I wanted to use mutate to create a new column based on the result of the 3 mentioned columns but I got the error: ...
GSandro_Strongs's user avatar
2 votes
2 answers
101 views

I am using mark-recapture data, with each individual having a PIT tag (Tag) and a genetic sample ID given at the first observation (ID), which is typically used as the ID for the individual (Unified....
ghaines's user avatar
  • 93
5 votes
0 answers
91 views

I have created a sub-class of a tbl and I want to provide a custom print method which adds some more arguments to further tweak the output. I have read vignette("extending", package = "...
thothal's user avatar
  • 20.7k
1 vote
1 answer
50 views

I'd like to know if there is a way to parse a dynamic case_when expression. Let's take as an example a vector of of 3 thresholds : thresholds = c(0.4, 0.6, 0.8) Based on that, I would like to assign ...
Rgrvkfer's user avatar
  • 417

1
2 3 4 5
206