skabir
skabir

Reputation: 5

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!

Upvotes: 0

Views: 65

Answers (2)

Anoushiravan R
Anoushiravan R

Reputation: 21938

We could also use this:

library(tibble)

df %>% column_to_rownames("Target")

    SeqId PlateId TargetFullName
111     1      11            111
222     2      22           2222

Upvotes: 1

coffeinjunky
coffeinjunky

Reputation: 11514

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

Upvotes: 1

Related Questions