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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:45:28+00:00 2026-06-12T18:45:28+00:00

My original data frame is this: x Team Date variable value A 2012-07-01 Score

  • 0

My original data frame is this:
x

Team  Date   variable  value
A 2012-07-01 Score      13
A 2012-07-02 Score      12
A 2012-07-03 Score      2097
A 2012-07-04 Score      45
A 2012-07-05 Score      41
A 2012-07-06 Score      763

need to to be like this

z
    Team 2012-07-01 2012-07-02 2012-07-03 2012-07-04 2012-07-05 2012-07-06 
    A     13         12          2097      45        41         763

library(reshape)
z<-cast(x, Team + variable ~ Date)

I get a warning message stating this:

Aggregation requires fun.aggregate: length used as default

  • 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-12T18:45:29+00:00Added an answer on June 12, 2026 at 6:45 pm

    Use dcast from reshape2 package and it’ll work!

    x <- read.table(text='Team  Date   variable  value
    A 2012-07-01 Score      13
    A 2012-07-02 Score      12
    A 2012-07-03 Score      2097
    A 2012-07-04 Score      45
    A 2012-07-05 Score      41
    A 2012-07-06 Score      763', header=T)
    
    library(reshape2)
    dcast(x, Team + variable ~ Date)
     Team variable 2012-07-01 2012-07-02 2012-07-03 2012-07-04 2012-07-05 2012-07-06
    1    A    Score         13         12       2097         45         41        763
    

    Edit:

    You can use reshape function from stats. No additional package is required as above.

    Y <- reshape(x, v.names='value', idvar='Team', timevar='Date',direction='wide')
    names(Y) <- sub('value.', '', names(Y))
    Y
      Team variable 2012-07-01 2012-07-02 2012-07-03 2012-07-04 2012-07-05 2012-07-06
    1    A    Score         13         12       2097         45         41        763
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame that looks like this > head(df) Memory Memory Memory Memory
I am using something like this to filter my data frame: d1 = data.frame(data[data$ColA
This code works: library(plyr) x <- data.frame(V= c(X, Y, X, Y, Z ), Z
Let's say you have a data frame generated by the following commands: date <-
In the R data frame coded for below, I would like to replace all
I have the following data frame, subsetted from my original data frame, with columns
Does the original data type of the username string in a call to FormsAuthentication.SetAuthCookie(...)
Would be possibile to get the original data type after applying the ArrayToStringTransformer to
original column is like: 0.45::rafas::4.0::0.0::0.9 0.35::rasaf::4.0::110.0::1.0 and i would like to break the string
[Original] I have a ListBox which has its ItemsSource (this is done in the

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.