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 6697843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:30:29+00:00 2026-05-26T06:30:29+00:00

I have huge dataframe like this: SN = c(1:100, 1:100, 1:100, 1:100) class =

  • 0

I have huge dataframe like this:

SN = c(1:100, 1:100, 1:100, 1:100)  
class = c(rep("A1", 100), rep("B2", 100), rep("C3", 100), rep("D4", 100)) # total 6000 levels 
myvar = rnorm(400)
mydf = data.frame(SN, class, myvar) 

I want to “unmelt” to a table with each level as single column and myvar in filled:

SN          A1            B2          C3         D4       .............and so on for all 6000 

How can I achieve this, I know it is simple question, but I could not figure out.

  • 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-05-26T06:30:30+00:00Added an answer on May 26, 2026 at 6:30 am
    > dcast(mydf, SN ~ class)
    
      SN         A1         B2          C3          D4
    1  1  0.1461258  0.8325014  0.33562088 -0.07294576
    2  2  0.5964182  0.4593710 -0.23652803 -1.52539568
    3  3  2.0247742 -1.1235963  1.79875447 -1.87462227
    4  4  0.8184004  1.3486721  0.76076486 -1.18311991
    5  5 -0.6577212  0.3666741 -0.06057506  1.38825487
    6  6  0.1590443  0.2043661  0.08161778  0.10421797
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge database with 100's of tables and stored procedures. Using SQL
I have a huge database with some 100 tables and some 250 stored procedures.
I have a huge dictionary of blank values in a variable called current like
I have this huge data frame that has servernames, Date, CPU, memory as the
I don't know whether this question makes sense or not. I have huge amount
I have a huge ASPX web form which has around 100 fields which need
I have huge query on my SQL 2005 Server. This have to be run
Good day... I have huge trouble with this and it drives me insane. My
I have huge table with 1 million records, i would like to modify some
I have huge class that I need to build stub for. To give you

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.