search for: reshape

Displaying 20 results from an estimated 1254 matches for "reshape".

2009 Dec 13
2
Reshape a data set
I am trying to reshape a data set. Could someone please help me with the reshape, cast, and melt functions? I am new to R and I have tried reading up on how to use the reshape package, but I am very confused. Here is an example of what I am trying to do: subject coder score time [1,] 1 1 20 5 [2,]...
2004 Feb 19
1
reshape direction=wide
Hello I am reshaping a data.frame bids --> reshaped as shown below. I thought this should be possible with a single invocation of reshape, but the only way I came up with is reshaping subsets for each keyword and then joining them together. Does anyone have an idea how to solve this in a more elegant way? Efficiency is a concern as the datasets ar...
2009 Jul 10
2
ReShape/cast question - sum of value in table
...it gets through but if it doesn't I'll post the actual text which is only 26 lines. Put it somewhere sensible and change the first line in the code to point at it. The R code I'm having trouble with is this: Y = read.table("C:\\test.txt") names(Y)[7] = "value" Y ReShape.Y = reshape(Y, varying=list(names(Y)[7]), direction='long') ReShape.Y cast(ReShape.Y, EnTime ~ ExTime) When run the last two steps output the following: > ReShape.Y Trade PosType EnDate EnTime ExDate ExTime time value id 1 1 -1 1080103 800 1080103 1310 1 52...
2010 Mar 29
2
Reshaping a data frame with a series of factors and 23 repeated measures
I have a data frame that I created using read.table on a csv spreadsheet. The data look like the following: Steer.ID stocker.trt Finish.trt Date Days Wt ...... Steer.Id, stocker.trt, Finish.trt are factors------ Date, Days, Wt are data that are repeated 23 times (wide format). I want to reshape the data such that I have the correct Steer.ID, stocker.trt, Finish.trt identifying all of the repeated measures data in a long format. I am a newbie at R and need to develop the skill in reshaping data, so that I can handle routine problems like described above. Thanks so much in advance for he...
2012 Dec 13
2
More efficient use of reshape?
Hi all, I have played a bit with the "reshape" package and function along with "melt" and "cast", but I feel I still don't have a good handle on how to use them efficiently. Below I have included a application of "reshape" that is rather clunky and I'm hoping someone can offer advice on how to use res...
2010 Jul 21
2
Issues reshaping data
Hello All, I'm having some trouble reshaping my data from wide to long format. I have tried using both the reshape function and package. Although I haven't worked much with the reshape function, I have found the reshape package useful and intuitive for reshaping data from long to wide format. However, going the other way has me stumped with this type of data. My data is set up, roughly, as follows: SUBJECT...
2008 Dec 29
1
Trouble installing plyr
I want to learn how to use the reshape package. The reshape package is not included in the Ubuntu repositories, so I attempted to install reshape with: install.packages("reshape") This is what I got for output: Warning in install.packages("reshape") : argument 'lib' is missing: using...
2009 May 13
5
Help with reshape/reShape and indexing
Dear R Helpers, I have trouble applying reShape and reshape although I read the documentation and several posts, so I would very much appreciate your help on the two points below. I have a dataframe df = data.frame(Name=c("a", "a", "a", "b", "b", "c"), X1=c("12", "13&qu...
2008 Feb 08
1
reshape question
I know there are a lot of reshape questions on the mailing list, but I haven't been able to find an answer to this particular issue. I am trying to get a datafame structured like this: > sub <- rep(1:5) > ta1 <- rep(1,5) > ta2 <- rep(2,5) > tb1<- rep(3,5) > tb2 <- rep(4,5) > DF <- d...
2012 Oct 17
1
Comparing dcast and reshape
I'm in the middle of my own little intellectual exercise comparing dcast() and reshape() and have successfully stumped myself. I want to melt() a data frame, then dcast() it into a new form. After doing so, I want to duplicate the process using reshape(). So far, I can do the melt and cast require(reshape2) Raw <- data.frame(site = c(1, 1, 1, 1, 2, 2, 2, 2),...
2008 Feb 20
3
reshaping data frame
Dear all, I'm having a few problems trying to reshape a data frame. I tried with reshape{stats} and melt{reshape} but I was missing something. Any help is very welcome. Please find details below: ################################# # data in its original shape: indiv <- rep(c("A","B"),c(10,10)) level.1 <- rpois(20, lambda=3)...
2008 May 19
1
reshape a wide data frame from wide to a long format with metadata columns
Hello R users and developers, I have a general question about reshaping a wide data frame using the "reshape" command. I have a data frame consisting of 108 columns that I would like to convert to a long table and remove the metadata (embedded in the column names of the wide table) to new metadata columns in the long format. #example data frame. NOTE column names contain metadata:: mediacont.21.MC1A...
2009 Mar 31
2
'sep' argument in reshape()
I wonder if the 'sep' argument in reshape() is being ignored unintentionally: ## From example(reshape) df <- data.frame(id=rep(1:4,rep(2,4)), visit=I(rep(c("Before","After"),4)), x=rnorm(4), y=runif(4)) reshape(df, timevar="visit", idvar="id", direction=&quot...
2007 Nov 24
2
unexpected result from reshape
Hi all. I have unexpected reshape results on datasets with certain variable names. Here a reproducible example: d <- matrix(seq_len(7*7), 1, 7*7) vnames <- c('acc','ppeGross','CF','ROA','DeltaSales','invTA','DeltaRevDeltaRec') varying <- unlist(lapply(vnames, paste,...
2009 Jan 14
1
reshape, direction=long: "multiple row names not allowed"
Hi all, for some reason I always get stuck spending hours when trying to use reshape or the Reshape package. Heaven knows why. My latest frustration (in 2.7.1, so ignore if this has been fixed): test<-data.frame(matrix(rnorm(42*4),ncol=4),rep(1:21,2),rep(c("a","b"),each=21)) reshape(test,varying=list(colnames(test)[1:4]),direction="long") test<...
2009 Dec 04
0
simple reshape of a large data frame (reshape() runs out of memory)
Hello everyone, I'm having a problem performing reshape() on a large data frame. The operation is fairly trivial but it makes R run out of memory. The data frame has the following structure: ID DATE1 DATE2 VALTYPE VALUE 'abcd1233' 2009-11-12 2009-12-23 'TYPE1' 123.45 ... V...
2006 Feb 22
1
unused factor levels in reshape
.../FALSE needed For example, > df <- data.frame(i = factor(rep(1:5, each = 2)), t = factor(rep(1:2, 5)), x = rep(rbinom(5, 1, 0.5), each = 2), y = rpois(10, 10)) > subdf <- subset(df, i %in% 1:3) defines a dataframe, and a subframe with some unused factor levels (i = 4, 5). Then > reshape(df, v.names = "y", timevar = "t", idvar = "i", direction = "wide") i x y.1 y.2 1 1 0 13 6 3 2 0 12 5 5 3 0 10 9 7 4 1 9 11 9 5 1 12 8 works fine but > reshape(subdf, v.names = "y", timevar = "t", idvar = "i"...
2009 Sep 14
2
problems with reshape
Hello * I would like to reshape wide the following dataset: > rl <- read.dta("intermedi/rapporti_lavoro.dta") [c("id_rl","prog","sil_pi","sil_cf","sil_dat_avv")] > dim(rl) [1] 12964 5 > object.size(rl) 1194728 bytes > head(rl) id_rl prog sil_...
2008 Sep 27
2
reshape "Error in data[, timevar] : incorrect number of dimensions"
I have two waves of a survey given to students at various middle schools and high schools, with student id numbers for each student. I am having difficulty reshaping the file from long to wide. My code is below: library(foreign) svy <- read.spss("studsur4.SAV") svy.wide <- reshape(svy, timevar="WAVE", idvar="id", direction="wide") "id" is the student identification number, and "WAVE" takes values 1 and 2. I get the following error: Error in data[, timevar] : incorrect number of dimensions I would provide reproducible co...
2004 Aug 06
1
reshape (was: Comparing rows in a dataframe)
Hi all: I solved the previous stated problem in something of a brute force way (but it works). I seem to now be running into one little hiccup using reshape. Here is a quick snip of the data in long format: grade stability year schid 6 Grade 4 3 2001 100005 7 Grade 4 3 2002 100005 8 Grade 4 2 2003 100005 10 Grade 5 2 2001 100005 11 Grade 5 2 2002 100005 12 Grade 5 1 2003 100005 18 Grade...