Search code examples
rreshape2

Reshaping large data set


I am trying to reformat my data set. Currently, this is what it looks like:

SeqId PlateId Target TargetFullName
1 11 111 111
2 22. 222. 2222.

However, I'd like it to look like this:

----- SeqId PlateId TargetFullName
Target - - -
111 1 11 111
222 2 22 222

This is what I have for reshaping:

library(reshape2)
longnewData <- melt(newData)
(differentSeqs <- getSequencesWithLargestBetweenGroupVariation(
  longnewData, n=10))[,.(SeqId, Target)]

Any help would be greatly appreciated -- thanks!


Solution

  • This seems to achieve what you want:

    Data:
    df <- data.frame(SeqId = 1:2, 
                     PlateId = c(11,22), 
                     Target = c(111,222), 
                     TargetFullName = c(111, 2222))
    
    Turning column into row:
    row.names(df) <- df$Target; df$Target <- NULL
    
    Checking outcome:
    df
        SeqId PlateId TargetFullName
    111     1      11            111
    222     2      22           2222