setnames() in a list object in R

I have a list object below and I need to assign each list object with a specific name such as if the object is in the 1st place in my.list, DF.1, if it is in the 10th place, DF.10. Many thanks in advance. df1 <- data_frame(ID = paste0(LETTERS[1],1:4), valueA = seq(0.1,0.4,0.1), Category= "Apples", valueDEF =… Read More setnames() in a list object in R

combining common columns in a list in R

I have an list object like below. df1 <- data_frame(ID = paste0(LETTERS[1],1:4), valueA = seq(0.1,0.4,0.1), Category= "Apples", valueDEF = seq(0.1,0.4,0.1), valueDEF2 = seq(0.1,0.4,0.1) ) df2 <- data_frame(ID = paste0(LETTERS[1],5:8), valueB = seq(0.1,0.4,0.1), Category= "Apples2") df3 <- data_frame(ID = paste0(LETTERS[1],9:12), valueC = seq(0.1,0.4,0.1), Category= "Apples3") list1 <- list(df1, df2, df3);list1 [[1]] # A tibble: 4 ×… Read More combining common columns in a list in R

Pivot_wider: Combine Duplicate Observations AND Create New Variable Columns for Those Values

I’m new to R and have scoured the site to find a solution – I’ve found lots of similar, but slightly different questions. I’m stumped. I have a dataset in this structure: SURVEY_ID CHILD_NAME CHILD_AGE Survey1 Billy 4 Survey2 Claude 12 Survey2 Maude 6 Survey2 Constance 3 Survey3 George 22 Survey4 Marjoram 14 Survey4 LeBron… Read More Pivot_wider: Combine Duplicate Observations AND Create New Variable Columns for Those Values

C++ higher order functions: different results when declaring multiple functions

I was plying with higher order functions, and I started getting different results when I created two instances and assigning them to variables. I reduced the issue to the following example: #include <iostream> using ColorGetter = int(*)(void); auto paint(const ColorGetter &f) { return [&]() { return f(); }; } int colorA() { return 10; }… Read More C++ higher order functions: different results when declaring multiple functions

Join columns, duplicating existing row for each variable in new column

Ok so say we have two different columns of data. One is just a running date column: day 2017-11-08 2017-11-09 2017-11-10 2017-11-13 2017-11-14 2017-11-15 The other is just an ID column ID asdflauih3298b43f9n akjwn3ibfun9834n93n nv43879n4vliuhs87ba I would like to join these columns in a way so that each ID occurs for every day. Like this:… Read More Join columns, duplicating existing row for each variable in new column