Skip to main content

All Questions

Tagged with
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
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
0 votes
1 answer
93 views

reshape dataframe based on event occurance and clearing

i want to see if there is an efficient way to reshape dataframe that is read from a tab separated csv file. the data consist of event codes and messages that are stacked up vertically with their ...
Hannibal's user avatar
  • 105
0 votes
0 answers
24 views

how dcast melted data winto a table with header and sub-header?

I have Input data like the one below and I want to know if there is any way to reshape it into an Excel format with a header and sub-header. Input: Cons rep name value 10 N=1 A 12 ...
star's user avatar
  • 765
3 votes
3 answers
96 views

Is it possible to reorder a table in R?

I have a table as belowe: dput(df) structure(list(Samples = c("Cont-4", "Cont-4", "Cont-4", "Cont-4", "Cont-4", "Cont-4", "Cont-4"...
A.Mokhtari's user avatar
4 votes
2 answers
116 views

How to reference the last column in pivot_longer() without naming it or providing the index number?

I'm writing a function to pivot a data table to long format. For the cols = argument, the name of the first column will always be the same, but the final column (and number of columns) will change. ...
ksinva's user avatar
  • 361
1 vote
1 answer
121 views

Convert data from wide to long format by checking the values of a row

I have the data below data<-structure(list(id = c("R_88j7lG37gLfxk22", "R_6DK8lERVf8lSQf4" ), t1_choice = c("2", "3"), t2_choice = c("1", "3&...
firmo23's user avatar
  • 8,306
0 votes
0 answers
15 views

Is there any xarray code for selecting data in the shape of a parallelogram?

I have a temperature data with dimensions YC and XC. I'm interested in selecting data within the red parallelogram shape depicted in the figure. xarray.DataArray'YC: 720 XC: 560. However, when using ...
Pragnya Makar's user avatar
3 votes
2 answers
93 views

Reshaping a data frame with example

I am trying to reshape my data frame. I have my data in long columns, and I need to spread that data out into the same row but new columns, as you can see above. One of the main problems I am running ...
Jack Sutkaytis's user avatar
1 vote
3 answers
143 views

Reshape a stacked style data file into a dataframe using pandas

I have a csv input file with the below format and i'm looking for a fairly easy way to convert to normal shape dataframe in pandas. the csv data file has all data stacked up into two columns with each ...
Hannibal's user avatar
  • 105
0 votes
1 answer
60 views

Reshaping dataframe by ID

I have a dataframe with one ID column and 24 value columns. For one ID, there is 49 rows of data. I would like to reshape this 49x24 into 7x168 shape for each ID, retaining the order so, that every ...
Hupatin's user avatar
  • 41
1 vote
1 answer
22 views

How to evaluate the fate (dropped, added or persisted) of species in consecutive years in R

Blockquote I have several time-series of varying length in a data frame that looks like this: I want to see if a species dropped or added or persisted from one year to the other year. The output can ...
Gull's user avatar
  • 117
1 vote
1 answer
47 views

function for reshaping data efficiently

I need to reshape a dataframe that looks like: holdc country_n popClass_n org P50M P50L P50U P95M P95L P95U P99M P99L P99U P99_9M P99_9L P99_9U 1 Austria Adults ADG 0.0445 ...
efz's user avatar
  • 435
0 votes
2 answers
62 views

R function to combine rows based on duplicates in specific columns and add value to a new column based on

I have a very large data frame ('df') that has many duplicated rows that need consolidation. These duplicated rows represent different categories, and the values that correspond to these categories ...
Willd's user avatar
  • 11
2 votes
1 answer
26 views

Reshape/convert study-level meta-analysis to individual patients data meta-analysis

I have study-level meta-analysis data that I want to reshape/convert it to patients level data Here is a sample of my data data2<-read.table(text="STUDY TOTAL POAF Age_POAF CRESWELL, ...
Mohamed Rahouma's user avatar

15 30 50 per page
1
2 3 4 5
49