dplyr Questions
4
I'm looking to count how many values in a row are identical. The idea is to be able to filter out respondents that have straightlined (ie answered all questions the same), for instance by filtering...
Baucom asked 31/10 at 1:42
4
Let's consider markers with their coefficient of variation (cv) and three reference cv (rcv):
Initial data:
marker cv rcv1 rcv2 rcv3
<chr> <dbl> <dbl> <dbl> <dbl>
1 ...
2
Junior R developer here. I'm not really completely clear on the meaning of the LinkingTo field in an R package's dependencies.
What I would like to do is remove the package BH after the installat...
Nipha asked 23/1, 2019 at 20:43
5
Solved
I have this data:
simulated_states = c("A", "E", "B", "B", "A", "C", "D", "A", "B", "D", "A&...
Nedry asked 19/9 at 2:8
3
Solved
I am trying to write a code that will allow me to automate the calculation of a population estimate on summarized capture data based on two-pass depletion methods used in fisheries.
The equation to...
2
Solved
I'd like to sample rows from a data frame by group. But here's the catch, I'd like to sample a different number of records based on data from another table. Here is my reproducible data:
df <- ...
3
Solved
Okay, so I know I could do something like this,
mtcars %>%
group_by(cyl) %>%
sample_n(2)
which will give me,
Source: local data frame [6 x 11]
Groups: cyl [3]
mpg cyl disp hp drat w...
3
Solved
I had to write a function today like this
data1 %>%
summarise(
ab1 = fn(a1, b1),
ab2 = fn(a2, b2),
ab3 = fn(a3, b3)
)
# imagine if there are 100 of them
If fn was a single argument funct...
3
I'm trying to create dynamic SQL pulls in R. I'm using dplyr to create the pulls. However, I haven't found a way to properly convert a string to expression with dplyr.
For example, the following co...
Firstly asked 29/8 at 17:20
5
Solved
I have this dataset
library(dplyr)
# creating a dataframe
data_frame <- data.frame(id = c(1,1,2,2,3,3),
col2 = c("start", "finish", "start", "finish",&q...
3
Solved
My filter_list has a large number of elements. The filtering below works but how would one make the dplyr::filter more concise?
I couldn't make all_of work.
filter_list <- list(
hair_color = c(...
2
Solved
Let's say I have this data.frame (with 3 variables)
ID Period Score
123 2013 146
123 2014 133
23 2013 150
456 2013 205
456 2014 219
456 2015 140
78 2012 192
78 2013 199
78 2014 133
78 2015 170
U...
5
Solved
How can I interleave rows from 2 data frames together like a perfect riffle shuffle?
Example data:
df1 <- data.frame(df = 1, id = 1:5, chr = 'puppies')
df2 <- data.frame(df = 2, id = 1:5, c...
Proudfoot asked 14/6, 2016 at 16:17
5
Solved
Assume I have a tibble (in my example here only with four columns). In real I have two hourly time series therefore 2 times 24 columns:
s1.x,...,s24.x, s1.y,...,s24.y
Now I want to sum up column s1...
2
Solved
I find myself writing this bit of code all the time to produce standard errors for group means ( to then use for plotting confidence intervals).
It would be nice to write my own function to do this...
4
Solved
4
Solved
I create a dataframe df.
df <- data.frame (id = 1:10,
var1 = 10:19,
var2 = sample(c(1:2,NA), 10, replace=T),
var3 = sample(c(3:5, NA), 10, replace=T))
What I need is a new column var4, w...
3
Solved
Is there a way to get the equivalent of a _merge indicator variable after a merge in dplyr?
Something similar to Pandas' indicator = True option that essentially tells you how the merge went (how...
4
Solved
Suppose I have 2 dataframes structured as such:
GROUPS:
P1 P2 P3 P4
123 213 312 231
345 123 213 567
INDIVIDUAL_RESULTS:
ID SCORE
123 23
213 12
312 11
213 19
345 10
567 22
I want to add a col...
2
Solved
I found two threads on this topic for calculating deciles in R. However, both the methods i.e. dplyr::ntile and quantile() yield different output. In fact, dplyr::ntile() fails to output proper dec...
5
Solved
I have a data frame which I am dcasting using the reshape2 package, and I would like to remove the first column and have it become the row names of the data frame instead.
Original dataframe, befo...
3
Solved
i have a rather specific question: how can I make a string into a factor and set its contrasts within a pipe ?
Let's say that I have a tibble like the following
tib <- data_frame (a = rep(c("...
2
I need to write a dplyr function that creates a customised area plot. So here's my attempt.
area_plot <- function(data, what, by){
by <- ensym(by)
what <- ensym(what)
data %>%
f...
Surreptitious asked 16/10, 2018 at 12:34
4
Is it possible to filter in dplyr by the position of a column?
I know how to do it without dplyr
iris[iris[,1]>6,]
But how can I do it in dplyr?
Thanks!
4
I'd like to merge two data frames where df2 overwrites any values that are NA or present in df1. Merge data frames and overwrite values provides a data.table option, but I'd like to know if there i...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.