All Questions
6 questions
1
vote
2
answers
89
views
Iterate along the two vectors of different length using map()
I have two vectors of unequal length. One vector is a list of dataframes and the other vector is made up of unique values. How can I use map() to iterate the vectors over a custom function? Dummy data ...
0
votes
0
answers
176
views
purrr::Compose or any alternative to reduce the run time for a long nested function in R?
Problem: I have several (10+) custom functions, each defining a step in the workflow. I want to run a nested function of these steps over a large data frame for n (50+) periods iteratively. My ...
1
vote
3
answers
175
views
Return vector of names where NA is greater than a set value
I want to create a vector of column names for columns that have fewer than 3 NAs. Here is my data and what I have tried so far:
df <- data.frame("A" = c(1,3,4,6,NA,3,NA),
&...
0
votes
5
answers
73
views
Is there a way to apply a function with multiple arguments over two data frames in R?
I want to write a function to replace values of "+" in the "values" data.frame with the corresponding value in the "others" data.frame.
values <- data.frame(A = c(&...
1
vote
1
answer
291
views
purrr over multiple groups of variables in R
I have a dataframe with many scales, and I want to calculate each participant's mean and sum as well as the grand mean and grand sum for each scale. I've can't figure out how to us pmap_dbl to get me ...
3
votes
3
answers
286
views
In R, how do I wrap text around all words in a string, but a specific one(going from left to right)? Iteration and string manipulation
I know my question is a little vague, so I have an example of what I'm trying to do.
input <- c('I go to school')
#Output
'"I " * phantom("go to school")'
'phantom("I ") * "go" * phantom("to ...