reshape

  1. D

    I need to merge columns by date into one column

    Hi all, I need to change a dataframe that is has a variable arranged by date like this: ID Var_Day1 Var_Day2 Var_Day3 1 2 66 222 2 5 55 333 3 6 44 555 4 3 33 444 5 4 22 333 into a new dataframe with one column for the variable for all days. Something like this: ID Day Var 1 1 2 2 1...
  2. gianmarco

    reshaping dataframe to matrix

    Hello, I am admittedly very dumb when it comes at reshaping data in R. So, I would appreciate to have some suggestion on what follows. I got the appended dataset with three columns: the first 2 contains codes for sites, the last column is the distance (in meters) between each pairs of sites...
  3. rogojel

    Elegant way to do the inverse of aggregation

    hi, I have a data frame with several factor variables and one numeric variable that gives the number of times a row with the given combination of factor values was obseved. I would like to disaggregate (if there is a such a word) the data frame to get one where a factor combination is...
  4. M

    Create a variable based on a hierarchy

    Hello friends, I have a dataset where each services offer by providers is in one row. However my goal is that each provider represents one row. I would like to create a variable that represents the LEAD grantee of my provider. Note that providers can have more than one grantee. For...
  5. M

    Reshape, collapse, restructure

    Hello guys, These are my variables: GranteeID Funding= Funding type there are 4 funding types (a,b,c,d) ProviderID=provider of the services Services= type of services (there can be 5 different type of services). In this dataset the services is the unit of analysis. Basically, I want...
  6. G

    how to reshape the data.frame from a square matrix to three column

    I have a data.frame like this: row.name a b c 1 1 4 7 2 2 5 8 3 3 6 9 and I want to reshape it like this rownamesnames1 names2 weight 1 a a 1 2 b a 2 3...
  7. L

    create a time period

    Hello everybody! I have values for prices for each year (price_1998, price_1999 etc), the avarage prices(aprice_1998, aprice_1999..), the marginal prices(mprice_1998, mprice_1999..). I have to build a graph, on the y axis i need the prices and on the x axis i should have the years(1998, 1999...
  8. M

    Complex reshape

    Hello guys, I really need help with this on. I have a dataset of healthcare organization with the following variables: ContactID : organization ID Quarter : data reporting period - first or second quarter Services : services provide Clients : how many...
  9. L

    Reshaping data

    Hi, I have a data frame which looks like : Jan_V Jan_S Feb_V Feb_S 1 100 90 120 110 2 123 88 112 120 3 121 89 134 130 There are around 200 rows. The data frame can have additional month columns i.e. Mar_V...
  10. P

    Reshape to long: how to prepare data?

    Hi, I really need your help. I'm new to Stata so it might be easy to answer for you guys... I have an excel sheet that lists stock prices for specific firms (about 800) on each trading day for 10 years. Firms (coded by their German stock exchange code) are arranged in ROW and dates in COLUMN...
  11. M

    Reshaping/collpasing institution level data

    I have data for lets say 10 health centers. There are a series of variables that ask for number of clients serve by age group. For example. var1= provide emergency contraception to 12-14 years old. var2 = provide emergency contraception to 15-17 years old. var3= provide emergency...
  12. M

    I reshaped long and now there are more categories in my encoded variables!

    Hi :) I reshaped my dataset and now my encoded variables have more categories than they had. What may be the cause? (PERS_ID is the identifier for the person while STU_ID identifies the identification number and then change if the student switches between majors in the university system of my...
  13. R

    More observations than individuals - convert rows to variables - reshape????

    Dear everyone, I have a HH dataset consiting of about 50 or so subsets which I am trying to merge together. The following problem occures. In some of these datasets there are more observations then individuals in the survey because data on jobs has been coded as job1, job2, job3 etc... each...
  14. M

    how to reshape the matrix with or without do loop?

    Dear All, I need to reshape below matrix with or without do loop: Below is my question: fd=read.table(header=TRUE, text=" X1 X2 X3 X4 X5 X6 18.25766 123.9019 151.4487 34.1252 196.6713 231.2289 16.89285 121.7344 146.5685 60.4828 299.1966 346.6185...