Skip to main content

All Questions

Tagged with
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
0 votes
2 answers
44 views

pivot longer by looping over certain columns

I have the following data which belongs to my darts league in wide format structure(list(home_team = c("Art of Dart", "Art of Dart", "Art of Dart", "Art of Dart&...
Emre Toros's user avatar
0 votes
1 answer
128 views

How to convert from wide to long format in longitudinal data?

My dataset looks something like this: Id smoke_2m Smoke_3m smoke_4m alcohol_3m age sex 1 2 3 5 7 30 M 2 3 3 5 6 26 ...
Komal Mehta's user avatar
2 votes
1 answer
53 views

I want to pivot wider and spread at the same time but having issues

this is an example table that I want to consolidate the data so that each patient is on one row with a different column for each test date/test result. Each patient has a different number of tests/...
mtejan's user avatar
  • 21
0 votes
0 answers
37 views

Can't reshape from wide to long for multiple variables

I have been trying to use panelr and then other packages to reshape from wide to long. Here are my variables: I tried using panelr's long_panel ('merg_Liz_OSARI_MCST' is the name of the dataframe I ...
Belinda Davey's user avatar
1 vote
3 answers
49 views

Reshape table from wide to long - nested keys

The goal is to convert this dataframe from wide to long format. The thing that I cannot figure out is how to handle this nested structure. My dataframe looks like this: df <- data.frame(dwelling=c('...
TvCasteren's user avatar
0 votes
2 answers
52 views

long to wide table on multiple columns in r [duplicate]

I'm having trouble in transform my table from long to wide. Table like : Con Bro Gr N Freq Jp CF ii 578 54.3 Jp CF ir 423 45.7 Jp CY im 1835 69.4 Jp CY nm ...
Ollie's user avatar
  • 147
1 vote
1 answer
50 views

convert wide to long dataset in R

set.seed(123) dataset <- data.frame(ID = 1:10, height_1 = rnorm(10,0,1), height_2 = rnorm(10,0,1), common_fam = rnorm(10,0,1), ...
Tube's user avatar
  • 191
1 vote
2 answers
54 views

Reshaping long with pivot_longer() with multiple values_to

I am trying to reshape long the following dataset: country Data Type Product 2007 [...] 2021 Austria Retail Volume id1 125 140 Austria Retail Value id1 ...
Matteo Bulgarelli's user avatar
0 votes
2 answers
45 views

Reshaping df from wide to long creating a new column with event names

I've got a data frame with data of different time points in which various event started and ended. The data frame looks something like this: Date Event 1 start Event 1 end Event 2 start Event 2 ...
RGR_288's user avatar
  • 93
1 vote
2 answers
70 views

how to use pivot wider if dataframe have any NA value

i have a dataframe like this df = data.frame(day = c("1", NA, NA, NA, NA, "2", NA, NA, NA), Unit = c("unit1", NA, NA, NA, "unit2", "unit1&...
Fadhil Dzikri's user avatar
0 votes
1 answer
56 views

How can I reshape from long to wide a dataset imported from Eurostat package?

I have the following dataset, from the Eurostat package: IPI <- get_eurostat("sts_inpr_m") %>% select("geo", "time", "values") %>% mutate(time=...
Maria's user avatar
  • 309
0 votes
2 answers
102 views

Reshaping a dataframe with multiple variables from wide to long

apologies if the same question has been posted elsewhere, but I can't seem to find a solution to my problem. I have a dataset from WDI that looks approximately like this: country iso3 ...
mgdang's user avatar
  • 11
0 votes
2 answers
115 views

Mutate() error is caused when trying to subtract values from 2 different columns

I have the code below in which I basically subtract the values on column qty based on if they have the same value in column activity and with the logic in-out from the in_out column. The result will ...
firmo23's user avatar
  • 8,306

15 30 50 per page
1
2 3 4 5
16