Linked Questions
18 questions linked to/from Transpose a data frame
3 votes
1 answer
3k views
transpose data frame [duplicate]
I am using R to transpose a data frame from an excel file (mydata.xls). The original data frame looks like this: ID AB_1 AB_2 AB_3 AB_4 AB_5 Variable1 1 2 3 4 5 Variable2 ...
-2 votes
1 answer
313 views
R: reshape data from column to row and add additional data based on name [duplicate]
I am looking for a way to reshape the following sample data data <- structure(list(id = c(2L, 5L, 7L), name = structure(1:3, .Label = c("Test1","Test10", "Test8"), class = "factor"), source = ...
-3 votes
1 answer
305 views
Transposing data frame [duplicate]
This dataframe code : f <- function (l) { l } data.frame(lapply(letters[1:2] , f)) which renders : I'm attempting to transpose the rows to cols so a,b appear as : X.a. a X.b. b I tried : f &...
0 votes
1 answer
319 views
Replicate each cell from multiple columns 3 times and append them one below the other [duplicate]
I have an excel with multiple columns (20 in total) with each column containing multiple rows (5000 each). I want to replicate each cell from one row and all the columns 3 times and add them one below ...
0 votes
4 answers
67 views
I'm not writing my pivot_wider function correctly [duplicate]
I am trying to run pivot_wider so that the output switches the rows and column fields. This does not accomplish that - what am I missing here? Current: model jan feb mar a 1 2 3 b 2 ...
0 votes
0 answers
41 views
Trying to remove first column of generic variable names created after transposing in R [duplicate]
I did not see anything that completely matches my issue, so I will address it here. In my dataset (lets call it microbes) I am simply trying to switch the rows (BacteriaType) and the columns (SD1-SD4) ...
0 votes
1 answer
49 views
reshape untidy data frame, spreading rows to columns names [duplicate]
Have searched the threads but can't understand a solution that will solve the problem with the data frame that I have. My current data frame (df): # A tibble: 8 x 29 `Athlete` Monday...2 ...
42 votes
5 answers
74k views
Transpose a dataframe maintaining the first column as heading
I have a big dataframe, but small example would be like this: mydf <- data.frame(A = c(letters[1:10]), M1 = c(11:20), M2 = c(31:40), M3 = c(41:50)) # A M1 M2 M3 # 1 a 11 31 41 # 2 b 12 32 42 #...
23 votes
7 answers
67k views
What is the best way to transpose a data.frame in R and to set one of the columns to be the header for the new transposed table?
What is the best way to transpose a data.frame in R and to set one of the columns to be the header for the new transposed table? I have coded up a way to do this below. As I am still new to R. I would ...
6 votes
2 answers
32k views
Transposing a data frame
I am trying to transpose a data frame in R, but having very little luck. The data frame contains an epigenetic data set, with 300,000+ CpG sites in the first column. The 74 additional columns are ...
0 votes
4 answers
495 views
Pivot a dataframe in r and add a column with custom value
I want to pivot a data frame My input data is as 1st Input MSFT AAPL GOOG 10 20 40 1st output Id Symbol Value T1 MSFT 10 T1 AAPL 20 T1 GOOG 40 -------------------------...
2 votes
2 answers
5k views
Format Numbers in FlexTable
I am using ReporteRs to generate a flexTable using the following piece of code: library( ReporteRs ) baseCellProp <- cellProperties( padding = 2 ) baseParProp <- parProperties(text.align = "...
1 vote
2 answers
2k views
How to transpose certain set of columns
I have a data set with over 300 columns and rows that looks like this: old= data.frame( id=1:3, DATE=c('20/12/1965','11/101970','03/12/1985'), TRT=c(1,2,1), AT1=c(40,89,50), AT2=c(...
-1 votes
2 answers
179 views
How to create a new data frame with each data point as a new column?
I am trying to scrape tables from a web page. The web page contains links to data in tables. Basically, I am writing a for loop to get the table from each link and concatenating with the other table. ...
3 votes
1 answer
172 views
How to extract unique and double records by row while keeping original row order using R?
Original (see Update below) I'm a newbie to R and currently working with collaboration data in the form of an edge list with 32 columns and around 200.000 rows in the following representation: 1 A ...