Skip to main content

All Questions

Tagged with
0 votes
2 answers
33 views

merge multiple DFs based on column names and row names in R [duplicate]

I have 3 Dfs I need to split it based on columns and row names like shown below I tried merge_recurse option from reshape, looks like it merges row by row. Please help me to get the columns added side ...
Shyamili's user avatar
1 vote
1 answer
29 views

R issue with reshape, reshape is not ordering columns correctly

I am trying to use reshape function in R to arrange my data timepoints in a table. The variable that I am using to split it is numerical, but when reshape arranges the table it incorrectly puts 2,0.5,...
Gabriela Toomer's user avatar
2 votes
1 answer
24 views

How to subset a melt object

My issue I have melt object from reshape2 library. I would like to subset variables with value==1. However, when I select value from subset melt object, I get the id instead of variable. How to get a ...
Yacine Hajji's user avatar
  • 1,307
2 votes
3 answers
74 views

Converting dataframe from "wide" to "long" format with pairs of ID variables

Here's an example of what I am trying to do. I am starting with a dataframe in "wide" format, like below. #sample dataframe id_1 <- c(260, 500, 640, 720) id_2 <- c(261, 501, 641, 721) ...
wooden05's user avatar
  • 195
3 votes
3 answers
84 views

Convert vector to matrix by blocks -reshape

just a quick question I am struggling in R to convert a list of numbers to a matrix that has a fixed number of rows and the numbers are placed in triplets (blocks of 3 rows) at a time The elements are ...
chriliv's user avatar
  • 33
0 votes
2 answers
40 views

pivot_longer with multiple columns with different column name patterns and count column [duplicate]

I have looked at multiple posts but have not seen this exact situation addressed. The linked examples have more consistent variable names (not single/multiple underscores) and do not add the count ...
Agnes Flack's user avatar
0 votes
1 answer
60 views

Keep all matched rows when reshaping from long to wide

I am trying to reshape my data from long to wide format. I would like to keep all rows that match for sn3=1 and sn3=2 instead of taking only the first value. How can I achieve this? Desired output: ...
Victoria's user avatar
0 votes
0 answers
20 views

wide data with part of column name as value [duplicate]

I have the following data structure in R DE_GDP DE_INFL US_GDP US_INFL 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 ...
Rkid's user avatar
  • 33
0 votes
3 answers
47 views

calculate annual cases after reshaping dataframe in R

I am working in R and I want to calculate the last column Annual_Cases based on the available years for each surgeon. The variable Years was reported per each 3-year time interval. Some surgeons were ...
Mohamed Rahouma's user avatar
0 votes
3 answers
72 views

How to append value of every two columns in R?

go from m <- matrix(1:16, nrow = 4) [,1] [,2] [,3] [,4] [1,] 1 5 9 13 [2,] 2 6 10 14 [3,] 3 7 11 15 [4,] 4 8 12 16 to 1x16 matrix 1 5 2 6 3 7 4 8 9 ...
dunbesscolder's user avatar
4 votes
3 answers
107 views

Sum up replicate columns in dataframe, keep rows unique

I thought this would be a relatively easy task to do but I couldn't find examples here that weren't focused on summing up rows based on column conditions. What I'm trying to achieve is to sum up ...
Katherine Chau's user avatar
1 vote
2 answers
72 views

R - Reshape list with matrices

I am working with a list of matrices that was created from the output of combn: lapply(2:length(c("A","B","C","D","E")), function(n) combn(c("A&...
thiagoveloso's user avatar
  • 2,671
2 votes
1 answer
49 views

Pivoting dataset to long format for all variable pairs following specific name pattern

I've got data from an experiment with 2 conditions where each participant got tested in both conditions for various properties. The dataset is in wide format, the variable name pattern is like this: ...
Madamadam's user avatar
  • 918
1 vote
2 answers
35 views

R : Reshape Long => wide with different value length

I want to reshape from long to wide the following data base df_long <- data.frame( indiv_id = c(rep(1,2), rep(2,6), rep(3,4)), value = c(sample(x = 2), sample(x = 6), sample(x = 4)), field_id ...
Jamman's user avatar
  • 11
0 votes
0 answers
35 views

Rowwise comparison in R for several fields [duplicate]

Suppose you have a dataframe df_matches with transaction data structured in the following way: | REPORT_ID| VALUE | SIDE | COUNTRY | CP1 | CP2 |... | -------- | -------- | -------- | ...
Marius's user avatar
  • 3

15 30 50 per page
1
2 3 4 5
152