All Questions
Tagged with tidyverse data.table
292
questions
1
vote
2
answers
23
views
How to select specific columns across multiple dataframes in R and then bind them into one data.frame?
I am trying to select or subset multiple data frames with different number of columns. They all contain the same columns of interest, so I am trying to make them all contain the same columns so I can ...
1
vote
2
answers
42
views
Recode relationship matrices based on new subgrouping
Problem:
I have a survey dataset which includes intra-household relationships. I had to subdivide household into tax-unit, which means I need to redefine the relationship matrices based on the new tax-...
1
vote
3
answers
177
views
Classification of rows/individuals based on their column output in an incidence matrix
I wrote an R function to classify rows (individuals) based on the columns output in an incidence matrix M5 for the following requirements:
M5 <- structure(c(1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1,...
3
votes
3
answers
151
views
How to re-group rows based on correlation values
I have one dataframe called snps of genetic variants:
ID Group
1: 1:12345:A:G 1
2: 1:12346:T:C 1
3: 1:23457:A:G 1
4: 3:1234:A:G 2
5: 3:12345:A:G 2
6: 1:99991:A:...
0
votes
1
answer
65
views
Calculating running amounts using data.table does not count days with no values?
I have two dataframes with values for two different years, categorized by group, and I'd like to combine them together to calculate running amounts per group while filling in missing dates. Here are ...
3
votes
1
answer
62
views
Reducing repetition of column and object names in data.table syntax
Using data.table, I want to modify the columns x1, x2, and x3 of data table object dt. Each version of the code achieves the modifications, but repeat the object and column names in several places.
...
1
vote
2
answers
138
views
How to calculate the number of children for each female in a dataset in R?
I'm working with a dataset in R and I'm trying to calculate the number of children for each female individual based on their relationship to the household head. The dataset includes variables such as ...
1
vote
3
answers
75
views
How can I smooth or ignore small changes in a variable in R?
I have a variable for which I'd like to ignore small changes, up to a threshold of 5, since I interpret them as measurement error or noise.
My minimal data is:
mydf = data.frame(time = 1:14,
...
0
votes
0
answers
65
views
Why does unique(x, by = a) work on data.tables but ignore the by = a on tibbles?
When using unique() on a tibble it silently drops the by argument. (I assume.) I do not understand why this is the case and why there is no error message. This is my example:
library(data.table)
...
0
votes
1
answer
162
views
Export percent missing, empty, zero, DK/RF in dataset to excel file
I am an extensive Stata user but would like to use R to achieve a similar goal. My desired objective is to have a data frame (that I can export to excel) with summary stats (actually percentage) of ...
2
votes
2
answers
79
views
How to get rid of duplicate rows preserving information into another column in R?
I am trying to get rid of duplicates from a dataset and I just found out that the rows are not exactly the same. Thus, I am trying to preserve the information and generate another column. For example, ...
1
vote
1
answer
35
views
Reshape with dplyr and stubs [duplicate]
DATA=data.frame( STUDENT =c(1, 2, 3),
GRADE1 =c(7, 3, NA),
GRADE2 =c(6, 5, 9),
GRADE3 =c(4, NA, 2),
GYM1 =c(2, 0, ...
1
vote
1
answer
51
views
Conditionally adding a variable based on strings in a file being loaded
I'm working on some workflow to join .csv files in a directory based on conditions met within the character strings of the files themselves.
For example, lets say I have the following files:
/path/...
0
votes
1
answer
78
views
How to split elements separated by underscore in columns names and create
I have the following dataset. As you could see, the columns names are composed by three elements. I would like to separate each of the element separated by an underscore:
structure(list(...
0
votes
5
answers
198
views
Assign a letter to each name in R to deidentify a dataset
I have seen many posts regarding using the letters function in R to assign a letter ID to a row number, however my question is a bit different from that- I am looking to deidentify a dataset and would ...