Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7982971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:49:33+00:00 2026-06-04T10:49:33+00:00

I need to transform some data like this: df<-data.frame(Plate=c(4660, 4660, 4660, 4660, 4660, 4660,

  • 0

I need to transform some data like this:

df<-data.frame(Plate=c("4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660", "4660"), Well=c("A1", "A2", "A3", "A4", "B1", "B2", "B3", "C1", "C2", "C3", "C4"), Result=c(1, 10, 100, 1000, 1, 10, 100, 1, 10, 100, 1000), Compound=c("C1", "C1", "C1", "C1", "C2", "C2", "C2", "C3", "C3", "C3", "C3"))
cmpds <- ddply(df, .(Compound), .fun = "t")

What I want to end up with is this:

   1     2     3     4
A  1     10    100   1000
B  1     10    100   NA
C  1     10    100   1000

Is there a way to fill the missing B4 row with NA or just ignore it? The t function or ddply seem to be choking on the fact that B is a different length than the others.

Thanks,
J–

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:49:35+00:00Added an answer on June 4, 2026 at 10:49 am

    Like @Justin, I am assuming your column names are coming from the numeric part of the well specification. If so, here is a slightly more general solution (will work for non-single digit numbers and non-single letter, um, letters.

    library("gsubfn")
    library("reshape2")
    
    wells <- strapply(as.character(df$Well), ".*([A-Z]+)([0-9]+)", c, simplify=rbind)
    colnames(wells) <- c("well.letter", "well.number")
    df <- cbind(df, wells)
    

    Then use dcast:

    > dcast(df, Compound~well.number, value.var="Result")
      Compound 1  2   3    4
    1       C1 1 10 100 1000
    2       C2 1 10 100   NA
    3       C3 1 10 100 1000
    

    If the horizontal labels are meaningless and you just want to fill in how many ever values you have, you can do this with plyr:

    ddply(df, .(Compound), function(DF) {
      as.data.frame(t(DF$Result))
    })
    

    which gives

      Compound V1 V2  V3   V4
    1       C1  1 10 100 1000
    2       C2  1 10 100   NA
    3       C3  1 10 100 1000
    

    What you want is not really clear since the rows in your example are labeled with the well letters, while the code implies splitting by compound name. Not sure which you really want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to transform some paginated data from Linq to Entity Framework. The data
I get some data from a WebService, which looks like this Building Address ->
I am having some problems with an XML transform and need some help. The
I need to transform my nested sets structure (mysql) into json for this spacetree
I would like to store some Application-Related Metadata for Files, and NTFS Alternate Data
I have a table schema which has some meta field data which I need
I need to transform a valid XML document to the OFX v1.0.2 format .
I need to transform a list into dictionary as follows. The odd elements has
I am developing an application were I need to transform XML documents that look
I need a way to transform numeric HTML entities into their plain-text character equivalent.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.