Skip to main content

All Questions

Tagged with
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
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
0 answers
79 views

In R, when transpose data from row to column, why spread() code doesn't work?

I have a data below dataA= data.frame( Location = rep(c("East", "West", "North"), each = 12 * 2), Season = rep(rep(c(2021, 2022), each = 6), 3), Genotype = rep(rep(...
Jin.w.Kim's user avatar
  • 884
1 vote
0 answers
109 views

Error "geom_line(): Each group consists of only one observation. ℹ Do you need to adjust the group aesthetic?" (line graph - repeated measures design)

I am trying to plot a line graph for two independent variables. Here are where I downloaded the data and how I converted them to a long format: textMessages <- read.delim("http://www....
OzkanGelincik's user avatar
1 vote
2 answers
34 views

Reshape strings within a dataframe in R

I have a dataframe that looks like this data.frame(service=c("1,2,3,4","2,4,5","1,3,4"), score=c("1,2,1,3","1,1,3","1,1,1&...
David Granada Donato's user avatar
4 votes
1 answer
65 views

transform data frame from wide to long (several variables) using separator [duplicate]

I have a df like this one: FID <- c(1,2,3,4) d <- c(1,1,2,2) IID_1 <- c("1A","2A","NA","4A") IID_2 <- c("1B","2B","3B",...
JuanJMV's user avatar
  • 145
2 votes
2 answers
70 views

New column for next occurrence of a variable in R

Note: Please note that I have tried the following to solve my problem before posting: Transpose / reshape dataframe without "timevar" from long to wide format How to Reshape Long to Wide ...
NM_'s user avatar
  • 1,993
0 votes
0 answers
29 views

reshape2 melt a list of pixel image objects like in reshape

I have a list of pixel image objects from spatstat.geom (see example data below) and want to melt them into one data.frame. I do it with reshape::melt and it works fine. Now, I wanted to do it with ...
Saskia Schirmer's user avatar
1 vote
2 answers
48 views

How do I reshape an R dataframe from long to wide without using the long variable values as the new variable names?

I have a long dataframe that lists the top 3 employers of each occupation code (3 rows per occupation code). It looks like this. occcode employer 1 top employer for occcode1 1 2nd employer for ...
C.K.'s user avatar
  • 85
1 vote
1 answer
32 views

Reshape dataframe in R

I have monthly data. df = structure(list(year = c(2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2000, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, 2001, ...
Haribo's user avatar
  • 2,142
1 vote
1 answer
190 views

How to draw barplot on either side of the y-axis using ggplot2?

I am trying to draw a barplot on either side of the y-axis (atleast present in "YES" or "NO") instead of stacking both "YES" and "NO" together. Firstly I ...
MOHAMMED TOUFIQ's user avatar
3 votes
6 answers
2k views

Arrange columns by prefix in column names

I've got a dataframe with hundreds of columns, here's a simplified sample: I need to arrange the order of specific columns so they are "kept together" based on the prefix in their column ...
Madamadam's user avatar
  • 918
1 vote
3 answers
741 views

Comparing values of pairs of columns whose names are suffixed by numbers (R / tidyverse)

I would like to compare the values of pairs of columns whose names start with certain characters but have same suffix in their column name. In the example below, I want to compare q_1 with v_1 and q_2 ...
Madamadam's user avatar
  • 918
1 vote
2 answers
478 views

Duplicating columns whose names are suffixed with numbers and adding an offset to the new column name suffixes

I would like to duplicate a certain subset of columns whose names are suffixed by numbers. To the numerical suffixes of new columns should be added a certain offset (in the following example it's 12). ...
Madamadam's user avatar
  • 918
1 vote
2 answers
97 views

Adding a new column next to each existing column that matches a certain column name pattern in R / tidyverse

In a dataframe I want to add a new column next each column whose name matches a certain pattern, for example whose name starts with "ip_" and is followed by a number. The name of the new ...
Madamadam's user avatar
  • 918

15 30 50 per page
1
2 3 4 5