Skip to main content

All Questions

Tagged with
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 ...
Victor Shin's user avatar
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-...
ravinglooper's user avatar
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,...
MYaseen208's user avatar
  • 23.6k
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:...
DN1's user avatar
  • 218
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 ...
user23687835's user avatar
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. ...
myusername's user avatar
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 ...
X.Jun's user avatar
  • 390
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, ...
Marco's user avatar
  • 2,727
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) ...
CZ_8eer's user avatar
  • 45
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 ...
Stephen Okiya's user avatar
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, ...
Victor Shin's user avatar
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, ...
bvowe's user avatar
  • 3,344
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/...
TDeramus's user avatar
  • 160
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(...
12666727b9's user avatar
  • 1,097
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 ...
EtoiledeMoyenOrient's user avatar

15 30 50 per page
1
2 3 4 5
20