Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Jim Lemon
Hi Allaisone, If you want a data frame as the output you will have to put up with a few NA values unless each Customer has the same number of diet types: a1df<-read.table(text="CustomerIDDietType 1 a 1c 1b 2

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread peter dalgaard
It depends quite strongly on what you want to do with the result, but I wonder if what is really needed might be a list of diettypes per person, i.e. continuing from Eric's code > On 25 Feb 2018, at 18:56 , Eric Berger wrote: > > Hi Allaisone, > I took a slightly

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Eric Berger
Hi Allaisone, I took a slightly different approach but you might find this either as or more useful than your approach, or at least a start on the path to a solution you need. df1 <- data.frame(CustId=c(1,1,1,2,3,3,4,4,4),DietType=c("a","c","b","f","a","j","c","c","f"),

Re: [R] reshaping column items into rows per unique ID

2018-02-25 Thread Bert Gunter
I believe you need to spend time with an R tutorial or two: a data frame (presumably the "table" data structure you describe) can *not* contain "blanks" -- all columns must be the same length, which means NA's are filled in as needed. Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not

Re: [R] reshaping the data

2017-07-03 Thread Bogdan Tanasa
f Bogdan > > Tanasa > > Sent: Monday, July 3, 2017 9:22 AM > > To: r-help <r-help@r-project.org> > > Subject: [R] reshaping the data > > > > Dear all, > > > > I would appreciate please a piece of help regarding the use of > acast/dcas

Re: [R] reshaping the data

2017-07-03 Thread PIKAL Petr
r-help-boun...@r-project.org] On Behalf Of Bogdan > Tanasa > Sent: Monday, July 3, 2017 9:22 AM > To: r-help <r-help@r-project.org> > Subject: [R] reshaping the data > > Dear all, > > I would appreciate please a piece of help regarding the use of acast/dcast > fun

Re: [R] reshaping the data

2017-07-03 Thread Jim Lemon
Hi Bogdan, If you want something like this: 22M 17M 11M AEBP1 SNV SNV NA ATR INDEL NA NA ATR SNV NANA BTKNA NA SNV BTK NA NA INDEL You're in trouble with repeated row names. Same with column names

[R] reshaping the data

2017-07-03 Thread Bogdan Tanasa
Dear all, I would appreciate please a piece of help regarding the use of acast/dcast functions in reshape2 package. Specifically, I'm working with a data frame, that has information about SAMPLE, GENE, and TYPE of MUTATION (as shown below): SampleGene Type 22M AEBP1 SNV 17M

Re: [R] Reshaping from long to wide with duplicate idvar and timevar

2017-03-14 Thread PIKAL Petr
3:45 AM > To: r-help@r-project.org > Subject: [R] Reshaping from long to wide with duplicate idvar and timevar > > Hi, > > I would like to reshape a data.frame from long to wide format. However, the > reshape function does not seem to accept data containing rows with > dup

[R] Reshaping from long to wide with duplicate idvar and timevar

2017-03-13 Thread Sebastien Bihorel
Hi, I would like to reshape a data.frame from long to wide format. However, the reshape function does not seem to accept data containing rows with duplicate idvar and timevar. Building upon the ?reshape example: summary(Indometh) wide <- reshape(Indometh, v.names = "conc", idvar = "Subject",

Re: [R] reshaping a large dataframe in R

2016-11-29 Thread PIKAL Petr
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David L > Carlson > Sent: Monday, November 28, 2016 8:27 PM > To: jean-philippe <jeanphilippe.fonta...@gssi.infn.it>; r-help@r-project.org > Subject: Re: [R] reshaping a large dataframe in R > > There may be a simpl

Re: [R] reshaping a large dataframe in R

2016-11-28 Thread Daniel Nordlund
On 11/28/2016 1:06 AM, jean-philippe wrote: dear all, I have a dataframe of 500 rows and 4004 columns that I would like to reshape to a dataframe of 500500 rows and 4 columns. That is from this dataframe: V1 V2 V3 V4 ... V4001 V4002 V4003 V4004 1 2 3 4 ... 4001 4002 4003 4004 1 2 3 4 ...

Re: [R] reshaping a large dataframe in R

2016-11-28 Thread David L Carlson
David L Carlson Department of Anthropology Texas A University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of jean-philippe Sent: Monday, November 28, 2016 3:07 AM To: r-help@r-project.org Subject: [R] reshaping a

[R] reshaping a large dataframe in R

2016-11-28 Thread jean-philippe
dear all, I have a dataframe of 500 rows and 4004 columns that I would like to reshape to a dataframe of 500500 rows and 4 columns. That is from this dataframe: V1 V2 V3 V4 ... V4001 V4002 V4003 V4004 1 2 3 4 ... 4001 4002 4003 4004 1 2 3 4 ... 4001 4002 4003 4004 1 2 3 4 ... 4001 4002

Re: [R] Reshaping geographic data

2016-10-17 Thread MacQueen, Don
I suggest you simplify your computing task by making this into three distinct tasks: 1. get copies of the shapefiles on your computer. Do this outside of R. Since this has two parts, i.e., downloading and unzipping, it will be easier at first to do it outside of r. Then later you can figure out

[R] Reshaping geographic data

2016-10-17 Thread G . Maubach
Hi All, I need to reshape an ESRI shape file: http://arnulf.us/PLZ and resp http://www.metaspatial.net/download/plz.tar.gz I found an instruction for T-SQL Server: https://blog.oraylis.de/2010/05/german-map-spatial-data-for-plz-postal-code-regions/ How can I do this using R? Kind regards

Re: [R] Reshaping an array - how does it work in R

2016-03-23 Thread Martin Maechler
> Dénes Tóth > on Tue, 22 Mar 2016 10:55:58 +0100 writes: > Hi Martin, > On 03/22/2016 10:20 AM, Martin Maechler wrote: >>> >Dénes Tóth >>> > on Fri, 18 Mar 2016 22:56:23 +0100 writes: >> > Hi

Re: [R] Reshaping an array - how does it work in R

2016-03-22 Thread Roy Mendelssohn - NOAA Federal
Thanks all. This is interesting, and for what I am doing worthwhile and helpful. I have to be careful in each operation whether a copy is made or not, and knowing this allows me to test on small examples what any command will do before I use, Thanks again, I appreciate all the help. I will

Re: [R] Reshaping an array - how does it work in R

2016-03-22 Thread Dénes Tóth
Hi Martin, On 03/22/2016 10:20 AM, Martin Maechler wrote: >Dénes Tóth > on Fri, 18 Mar 2016 22:56:23 +0100 writes: > Hi Roy, > R (usually) makes a copy if the dimensionality of an array is modified, > even if you use this syntax: > x <-

Re: [R] Reshaping an array - how does it work in R

2016-03-22 Thread Martin Maechler
> Dénes Tóth > on Fri, 18 Mar 2016 22:56:23 +0100 writes: > Hi Roy, > R (usually) makes a copy if the dimensionality of an array is modified, > even if you use this syntax: > x <- array(1:24, c(2, 3, 4)) > dim(x) <- c(6, 4) > See also

Re: [R] Reshaping an array - how does it work in R

2016-03-21 Thread Roy Mendelssohn - NOAA Federal
Thanks for the info, but I will stay with regular R. Work -arounds for what I want to do just took some thought and programming, I just didn’t know if R copied the array or just manipulated indices, and given the size of the array I am memory limited. This gets into the old thing of

[R] Reshaping an array - how does it work in R

2016-03-21 Thread Rodrigo Botafogo
Roy, I have implemented a Ruby Gem (SciCom) with exactly your use case in mind. SciCom is based on Renjin, an R interpreter for the JVM. So, this reply is about R, but not about GnuR. If this is not proper behavior, please let me know. I´ve looked at the posting guidelines and it seems to be

Re: [R] Reshaping an array - how does it work in R

2016-03-19 Thread Dénes Tóth
Hi Roy, R (usually) makes a copy if the dimensionality of an array is modified, even if you use this syntax: x <- array(1:24, c(2, 3, 4)) dim(x) <- c(6, 4) See also ?tracemem, ?data.table::address, ?pryr::address and other tools to trace if an internal copy is done. Workaround: use

Re: [R] Reshaping an array - how does it work in R

2016-03-19 Thread Roy Mendelssohn - NOAA Federal
> On Mar 19, 2016, at 8:18 AM, Henrik Bengtsson > wrote: > > On Fri, Mar 18, 2016 at 8:28 PM, Roy Mendelssohn - NOAA Federal > wrote: >> Hi Henrik: >> >> I want to do want in oceanography is called an EOF, which is just a PCA >>

Re: [R] Reshaping an array - how does it work in R

2016-03-19 Thread Henrik Bengtsson
On Fri, Mar 18, 2016 at 8:28 PM, Roy Mendelssohn - NOAA Federal wrote: > Hi Henrik: > > I want to do want in oceanography is called an EOF, which is just a PCA > analysis. Unless I am missing something, in R I need to flatten my 3-D matrix > into a 2-D data matrix. I

[R] Reshaping an array - how does it work in R

2016-03-19 Thread Roy Mendelssohn - NOAA Federal
Hi All: I am working with a very large array. if noLat is the number of latitudes, noLon the number of longitudes and noTime the number of time periods, the array is of the form: myData[noLat, no Lon, noTime]. It is read in this way because that is how it is stored in a (series) of netcdf

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Bert Gunter
arrays are vectors stored in column major order. So the answer is: reindexing. Does this make it clear: > v <- array(1:24,dim=2:4) > as.vector(v) [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 > v , , 1 [,1] [,2] [,3] [1,]135 [2,]246

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Roy Mendelssohn - NOAA Federal
Hi Henrik: I want to do want in oceanography is called an EOF, which is just a PCA analysis. Unless I am missing something, in R I need to flatten my 3-D matrix into a 2-D data matrix. I can fit the entire 30GB matrix into memory, and I believe I have enough memory to do the PCA by

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Roy Mendelssohn - NOAA Federal
> On Mar 18, 2016, at 2:56 PM, Bert Gunter wrote: > > However copying may occur anyway as part of R's semantics. Others will > have to help you on that, as the details here are beyond me. > > Cheers, > Bert Hi Bert: Thanks for your response. The only part I was

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Roy Mendelssohn - NOAA Federal
Thanks. That is what I needed to know. I don’t want to play around with some of the other suggestions, as I don’t totally understand what they do, and don’t want to risk messing up something and not be aware of it. There is a way to read in the data chunks at a time and reshape it and put, it

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Henrik Bengtsson
On Fri, Mar 18, 2016 at 3:15 PM, Roy Mendelssohn - NOAA Federal wrote: > Thanks. That is what I needed to know. I don’t want to play around with > some of the other suggestions, as I don’t totally understand what they do, > and don’t want to risk messing up something

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Jeff Newmiller
R always makes a copy for this kind of operation. There are some operations that don't make copies, but I don't think this one qualifies. -- Sent from my phone. Please excuse my brevity. On March 18, 2016 2:28:35 PM PDT, Roy Mendelssohn - NOAA Federal wrote: >Hi

Re: [R] Reshaping Data in R - Transforming Two Columns Into One

2014-03-19 Thread PIKAL Petr
Hi Isn't melt just what you want? melt(mydt) Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Abraham Mathew Sent: Tuesday, March 18, 2014 1:59 AM To: r-help@r-project.org (r-help@r-project.org) Subject: [R] Reshaping

[R] Reshaping Data in R - Transforming Two Columns Into One

2014-03-17 Thread Abraham Mathew
I have the following data frame. Using the stringr package, I've attempted to map the url's to some specific elements that are in each url. I then used the reshape package to join two different data frames. The next step is to transform the two columns in the mydt data frame (forester and

[R] reshaping a data frame

2013-06-10 Thread Abhishek Pratap
Hi Guys I am trying to cast a data frame but not aggregate the rows for the same variable. here is a contrived example. **input** temp_df - data.frame(names=c('foo','foo','foo'),variable=c('w','w','w'),value=c(34,65,12)) temp_df names variable value 1 foow34 2 foow

Re: [R] reshaping a data frame

2013-06-10 Thread Adams, Jean
Abhi, In the example you give, you don't really need to reshape the data ... just rename the column value to w. Here's a different example with more than one category ... tempdf - expand.grid(names=c(foo, bar), variable=letters[1:3]) tempdf$value - rnorm(dim(tempdf)[1]) tempdf library(reshape)

Re: [R] reshaping a data frame

2013-06-10 Thread John Kane
, 9 Jun 2013 23:15:48 -0700 To: r-help@r-project.org Subject: [R] reshaping a data frame Hi Guys I am trying to cast a data frame but not aggregate the rows for the same variable. here is a contrived example. **input** temp_df - data.frame(names=c('foo','foo','foo'),variable=c('w','w

Re: [R] reshaping a data frame

2013-06-10 Thread arun
: Monday, June 10, 2013 2:15 AM Subject: [R] reshaping a data frame Hi Guys I am trying to cast a data frame but not aggregate the rows for the same variable. here is a contrived example. **input** temp_df  - data.frame(names=c('foo','foo','foo'),variable=c('w','w','w'),value=c(34,65,12)) temp_df

Re: [R] reshaping a data frame

2013-06-10 Thread Abhishek Pratap
@gmail.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Monday, June 10, 2013 2:15 AM Subject: [R] reshaping a data frame Hi Guys I am trying to cast a data frame but not aggregate the rows for the same variable. here is a contrived example. **input** temp_df - data.frame(names=c

Re: [R] Reshaping Data for bi-partite Network Analysis [SOLVED]

2013-04-14 Thread arun
5   #Mary  4    0 0 0 A.K. From: sylvain willart sylvain.will...@gmail.com To: arun smartpink...@yahoo.com Cc: R help r-help@r-project.org Sent: Saturday, April 13, 2013 5:41 PM Subject: Re: [R] Reshaping Data for bi-partite Network Analysis [SOLVED

[R] Reshaping Data for bi-partite Network Analysis

2013-04-13 Thread sylvain willart
Hello I have a dataset of people spending time in places. But most people don't hang out in all the places. it looks like: Input-data.frame(people=c(Marc,Marc,Joe,Joe,Joe,Mary), + place=c(school,home,home,sport,beach,school), + time=c(2,4,3,1,5,4)) Input people

Re: [R] Reshaping Data for bi-partite Network Analysis

2013-04-13 Thread arun
, 2013 5:03 PM Subject: [R] Reshaping Data for bi-partite Network Analysis Hello I have a dataset of people spending time in places. But most people don't hang out in all the places. it looks like: Input-data.frame(people=c(Marc,Marc,Joe,Joe,Joe,Mary), +              place=c(school,home,home

Re: [R] Reshaping Data for bi-partite Network Analysis

2013-04-13 Thread Rui Barradas
Hello, With the following the order of both rows and columns will be different than the order of your example output, but the table is basically the same. xtabs(time ~ people + place, data = Input) Hope this helps, Rui Barradas Em 13-04-2013 22:03, sylvain willart escreveu: Hello I have

Re: [R] Reshaping Data for bi-partite Network Analysis [SOLVED]

2013-04-13 Thread sylvain willart
sylvain.will...@gmail.com To: r-help r-help@r-project.org; sylvain willart sylvain.will...@gmail.com Sent: Saturday, April 13, 2013 5:03 PM Subject: [R] Reshaping Data for bi-partite Network Analysis Hello I have a dataset of people spending time in places. But most people don't hang out

Re: [R] Reshaping a table

2013-04-11 Thread S Ellison
-Original Message- Here's the relevant portion of the as.table Help file: But ... is an argument to table(), not to as.table; this part of the help file is not referring to as.table. The first argument to as.table is x, which is an 'arbitrary R object'. as.table is a generic; it

Re: [R] Reshaping a table - PS

2013-04-11 Thread S Ellison
as.table(dat1) #Error in as.table.default(dat1) : cannot coerce to a table You _can_ coerce to a matrix first: as.table( as.matrix(dat1) ) S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}}

Re: [R] Reshaping a table

2013-04-11 Thread Bert Gunter
Yes. My error was previously pointed out to me and there was further offlist discussion. Maybe I should have kept it onlist, but I was reticent about displaying my stupidity. :( Mea Culpa. Cheers, Bert On Thu, Apr 11, 2013 at 9:11 AM, S Ellison s.elli...@lgcgroup.com wrote: -Original

[R] Reshaping a table

2013-04-08 Thread IOANNA
Hello all, I have data in the form of a table: X Y1Y2 0.1 3 2 0.2 2 1 And I would like to transform in the form: X Y 0.1 Y1 0.1 Y1 0.1 Y1 0.1 Y2 0.1 Y2 0.2 Y1 0.2 Y1 0.2 Y2 Any ideas how? Thanks in advance, IOanna

Re: [R] Reshaping a table

2013-04-08 Thread arun
(res)  res #    X  Y #1 0.1 Y1 #2 0.1 Y1 #3 0.1 Y1 #4 0.1 Y2 #5 0.1 Y2 #6 0.2 Y1 #7 0.2 Y1 #8 0.2 Y2 A.K. - Original Message - From: IOANNA ii54...@msn.com To: 'r-help-r-project.org' r-help@r-project.org Cc: Sent: Monday, April 8, 2013 8:09 AM Subject: [R] Reshaping a table Hello all

Re: [R] Reshaping a table

2013-04-08 Thread David L Carlson
To: IOANNA Cc: R help Subject: Re: [R] Reshaping a table Hi, Try this: dat1-read.table(text= X  Y1    Y2 0.1  3  2 0.2  2  1 ,sep=,header=TRUE)  res-do.call(rbind,lapply(split(dat1,seq_len(nrow(dat1))),function(x) {Y=rep(colnames(x)[-1],x[-1]); X=rep(x[,1],length(Y

Re: [R] Reshaping a table

2013-04-08 Thread arun
about the problem. A.K. - Original Message - From: Bert Gunter gunter.ber...@gene.com To: arun smartpink...@yahoo.com Cc: dcarl...@tamu.edu dcarl...@tamu.edu Sent: Monday, April 8, 2013 1:33 PM Subject: Re: [R] Reshaping a table Thanks. Here's the relevant portion of the as.table Help

[R] Reshaping a dataframe

2012-11-17 Thread eric
Seems like this should be easy but I'm struggling a bit. How do I rearrange a data frame to go from the first one to the second shown below ? State Datelbs TX 200701 400 TX 200702 650 TX 200703 950 TX 200704 1000 FL 200701 200 FL

Re: [R] Reshaping a dataframe

2012-11-17 Thread eric
What am I doing wrong ? Using the method you proposed on SLIGHTLY different data. head(x) Region YearMon kg AP 200701 290,311 AP 200702 322,671 AP 200703 216,600 AP 200704 450,711 AP 200705 245,215 AP 200706 212,492 j

Re: [R] Reshaping a dataframe

2012-11-17 Thread eric
Didn't try the other two methods as I spent a bit of time trying to learn about reshape2. I was also able to melt the data and that went fine (although based on your post, melting is not needed). Any ideas on why reshape2 dcast is giving fits ? -- View this message in context:

Re: [R] Reshaping a dataframe

2012-11-17 Thread eric
Could it be that my data is showing up as factors ? class(x) 1] data.frame str(x) data.frame':284 obs. of 3 variables: $ Region : Factor w/ 4 levels AP,EU,LA,..: 1 1 1 1 1 1 1 1 1 1 ... $ YearMon: int 200701 200702 200703 200704 200705 200706 200707 200708 200709 200710 ... $ kg :

Re: [R] Reshaping dataframes

2012-08-23 Thread Ingmar Schuster
Thanks Rui! Anybody with ideas regarding filling _while_ binding data frames instead of afterwards? Ingmar 2012/8/22 Rui Barradas ruipbarra...@sapo.pt Hello, Your function doesn't seem to be very difficult to generalize. d - read.table(text= trg_type child_type_1 1 Scientists NA 2

Re: [R] Reshaping dataframes

2012-08-23 Thread David Winsemius
On Aug 23, 2012, at 2:02 AM, Ingmar Schuster wrote: Thanks Rui! Anybody with ideas regarding filling _while_ binding data frames instead of afterwards? Not sure what you mean by _while_ binding dataframes but the original question seems answered by this sentence from the help file

[R] Reshaping dataframes

2012-08-22 Thread Ingmar Schuster
Hi, I have a data set with variables that are _not_ missing at random. Now I use a package for learning a Bayesian Network which won't accept NA as a value. From a database I query data.frames with k,k+n,k+2n, ... variables (there are always at least k variables as leftmost columns). Using

Re: [R] Reshaping dataframes

2012-08-22 Thread Rui Barradas
Hello, Your function doesn't seem to be very difficult to generalize. d - read.table(text= trg_type child_type_1 1 Scientists NA 2of used , header=TRUE) str(d) subs_na - function(tok, na_factor_level = NOT_REALIZED, na_num = 9) { ifac - which(sapply(tok, is.factor))

Re: [R] reshaping data

2012-07-25 Thread AC Del Re
Wonderful! thanks, Rui! AC On Tue, Jul 24, 2012 at 10:01 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Try the following. # We are going to use this twice sl - split(long, long$id) # Remove groups with only one row l2 - lapply(sl, function(x) if(nrow(x) 1) x) l2 -

[R] reshaping data

2012-07-24 Thread AC Del Re
Hi, I am trying to reshape data from a long to wide format but have a specific task that I cannot get to output properly. # SAMPLE DATA; id - c(1,2,2,3,3,3) time -c(0,0,5, 0, 2, 10) x - rnorm(length(id)) long - data.frame(id,time,x) # To reshape, I would like to exclude 'id' values that have NO

Re: [R] reshaping data

2012-07-24 Thread Rui Barradas
Hello, Try the following. # We are going to use this twice sl - split(long, long$id) # Remove groups with only one row l2 - lapply(sl, function(x) if(nrow(x) 1) x) l2 - do.call(rbind, l2) l2 # Create a new variable l3 - lapply(sl, function(x) cbind(x, NEW_VARIABLE=seq_len(nrow(x l3 -

Re: [R] reshaping data

2012-07-24 Thread Peter Ehlers
On 2012-07-24 22:01, Rui Barradas wrote: Hello, Try the following. # We are going to use this twice sl - split(long, long$id) # Remove groups with only one row l2 - lapply(sl, function(x) if(nrow(x) 1) x) l2 - do.call(rbind, l2) l2 # Create a new variable l3 - lapply(sl, function(x)

[R] Reshaping columns

2012-06-09 Thread efulas
Dear all, I have a data frame with 2 columns and 102500 rows. The data looks like below V1V2 809811... 9099001100... 0023110011... 654511... . . . . . . . . . . I want to split the

Re: [R] Reshaping columns

2012-06-09 Thread R. Michael Weylandt
Perhaps something like this: x - c(11, 001100, 001001) # Test data strsplit(x,) # See what strsplit does do.call(rbind, strsplit(x,)) # Now combine the list elements nicely. Incidentally, your question was grossly malformed, involving both incomplete data and that in a non-reproducible

Re: [R] Reshaping columns

2012-06-09 Thread arun
) names(dat2)-c(V1,LETTERS[1:6]) dat2     V1 A B C D E F 1 8098 1 1 0 0 0 0 2 9099 0 0 1 1 0 0 3 0023 1 1 0 0 1 1 4 6545 1 1 1 1 1 1 A.K. - Original Message - From: efulas ef_u...@hotmail.com To: r-help@r-project.org Cc: Sent: Saturday, June 9, 2012 6:21 AM Subject: [R] Reshaping columns

Re: [R] Reshaping data from long to wide without a timevar

2012-03-21 Thread Paul Miller
Hello All, Tried some more Internet searches and came to the conclusion that one probably does need to create a timevar before reshaping from long to wide. Below is some code that creates the timevar and transposes the data. connection - textConnection( 005 1 Gemcitabine 005 2 Erlotinib 006 1

[R] Reshaping data from long to wide without a timevar

2012-03-20 Thread Paul Miller
Hello All, I was wondering if it's possible to reshape data from long to wide in R without using a timevar. I've pasted some sample data below along with some code. The data are sorted by Subject and Drug. I want to transpose the Drug variable into multiple columns in alphabetical order. My

Re: [R] Reshaping data from long to wide without a timevar

2012-03-20 Thread R. Michael Weylandt
If I understand you right, library(reshape2) dcast(melt(TestData, id.var = Subject, measure.var = Drug), Subject ~ value) Michael On Tue, Mar 20, 2012 at 9:50 AM, Paul Miller pjmiller...@yahoo.com wrote: Hello All, I was wondering if it's possible to reshape data from long to wide in R

Re: [R] Reshaping data from long to wide without a timevar

2012-03-20 Thread Paul Miller
, Erlotinib. That's what I mean when I say I want the columns in alphabetical order. Thanks, Paul --- On Tue, 3/20/12, R. Michael Weylandt michael.weyla...@gmail.com wrote: From: R. Michael Weylandt michael.weyla...@gmail.com Subject: Re: [R] Reshaping data from long to wide without a timevar

Re: [R] reshaping a dataset for a network

2012-03-14 Thread Marco Guerzoni
Of Marco Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b

Re: [R] reshaping a dataset for a network

2012-03-14 Thread R. Michael Weylandt
Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c

Re: [R] reshaping a dataset for a network

2012-03-14 Thread Marco Guerzoni
13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a- c(1,2,3,4,4,4,5,5) b- c(11,7,4,9,8,3,12,4) df-cbind(a,b) I

Re: [R] reshaping a dataset for a network

2012-03-14 Thread William Dunlap
Message- From: Marco Guerzoni [mailto:marco.guerz...@unito.it] Sent: Wednesday, March 14, 2012 1:02 AM To: William Dunlap Cc: r-help@r-project.org Subject: Re: [R] reshaping a dataset for a network Thank you fro the reply. I managed to arrive till here, then I would like to have

Re: [R] reshaping a dataset for a network

2012-03-14 Thread Marco Guerzoni
, 2012 1:02 AM To: William Dunlap Cc: r-help@r-project.org Subject: Re: [R] reshaping a dataset for a network Thank you fro the reply. I managed to arrive till here, then I would like to have it in matrix where the $1 $2...$5 are the first column. Il 3/13/2012 8:15 PM, William Dunlap ha scritto

[R] reshaping a dataset for a network

2012-03-13 Thread Marco Guerzoni
dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a - c(1,2,3,4,4,4,5,5) b - c(11,7,4,9,8,3,12,4) df -cbind(a,b) I would like to have one which looks like this: a 1 11 2 7 3 4 4 9 8 3 5 12 4 a are

Re: [R] reshaping a dataset for a network

2012-03-13 Thread William Dunlap
Guerzoni Sent: Tuesday, March 13, 2012 10:51 AM To: r-help@r-project.org Subject: [R] reshaping a dataset for a network dear all, apologizes for bothering with a probably stupid question but I really don' t know how to proceed. I have a dataset which look like df a - c(1,2,3,4,4,4,5,5

[R] reshaping

2012-03-02 Thread robgriffin247
Hello, I have a large data set which I am trying to get in to a long/narrow format. I have given an example below of how I want my data to look before and after... any ideas for an easy way to do this? *###Start With this... *set.seed(1) a=rnorm(10) b=rnorm(10) c=rnorm(10) d=rnorm(10) e=rnorm(10)

Re: [R] reshaping

2012-03-02 Thread Ista Zahn
Hi, I *think* this is what you want... On Fri, Mar 2, 2012 at 12:29 PM, robgriffin247 robgriffin...@hotmail.com wrote: Hello, I have a large data set which I am trying to get in to a long/narrow format. I have given an example below of how I want my data to look before and after... any ideas

Re: [R] Reshaping data from wide to tall format for multilevel modeling

2011-09-08 Thread Jim Lemon
On 09/08/2011 12:02 AM, dadrivr wrote: Hi, I'm trying to reshape my data set from wide to tall format for multilevel modeling. Unfortunately, the function I typically use (make.univ from the multilevel package) does not appear to work with unbalanced data frames, which is what I'm dealing

[R] reshaping data

2011-09-07 Thread B77S
I have the following data (see RawData using dput below) How do I get it in the following 3 column format (CO2 measurements are the elements of the original data frame). I'm sure the package reshape is where I should look, but I haven't figured out how. Thanks ahead of time Month Year CO2

[R] Reshaping data from wide to tall format for multilevel modeling

2011-09-07 Thread dadrivr
Hi, I'm trying to reshape my data set from wide to tall format for multilevel modeling. Unfortunately, the function I typically use (make.univ from the multilevel package) does not appear to work with unbalanced data frames, which is what I'm dealing with. Below is an example of the columns of

Re: [R] reshaping data

2011-09-07 Thread Justin Haynes
look at the melt function in reshape, specifically ?melt.data.frame require(reshape) Raw.melt-melt(RawData,id.vars='Year',variable_name='Month') there is an additional feature in the melt function for handling na values. names(Raw.melt)[3]-'CO2' head(Raw.melt) Year MonthCO2 1 1958 J

Re: [R] reshaping data

2011-09-07 Thread B77S
The terminology (melt, cast, recast) just isn't intuitive to me; but I understand how to use melt now. Thanks! Justin Haynes wrote: look at the melt function in reshape, specifically ?melt.data.frame require(reshape) Raw.melt-melt(RawData,id.vars='Year',variable_name='Month') there

[R] Reshaping data with xtabs reorders my rows

2011-06-15 Thread filip.biele...@rega.kuleuven.be
Dear, I have a data frame melted from a list of matrices (melt from reshape package), then I impute some missing values and then want to tabulate the data again to the array (or list, doesn't matter) of matrices form. However when using xtabs function it orders my rows alphabetically and

Re: [R] Reshaping data with xtabs reorders my rows

2011-06-15 Thread filip.biele...@rega.kuleuven.be
Dnia 2011-06-15, o godz. 12:05:01 Jim Lemon j...@bitwrit.com.au napisał(a): On 06/15/2011 06:46 PM, filip.biele...@rega.kuleuven.be wrote: Dear, I have a data frame melted from a list of matrices (melt from reshape package), then I impute some missing values and then want to tabulate

[R] reshaping issue

2011-05-17 Thread Stijn Van Daele
Dear R users, I have a problem with reshaping data. I know such questions have been asked before, but I can't get it right, neither with the reshape function nor with the melt function. My dataset has about 407 variables and about 48000 cases. Each case looks as follows: V1 v2 v3

Re: [R] reshaping issue

2011-05-17 Thread Scott Chamberlain
Can you provide a brief reproducible example for us to play with? Scott On Tuesday, May 17, 2011 at 12:31 PM, Stijn Van Daele wrote: Dear R users, I have a problem with reshaping data. I know such questions have been asked before, but I can't get it right, neither with the reshape function

Re: [R] reshaping issue

2011-05-17 Thread Dennis Murphy
Hi: Here's one way, using an abbreviated example: du - data.frame(v1 = factor(rep(1:10, each = 4)), v2 = factor(rep(rep(1:2, each = 2), 10)), v3 = factor(rep(1:2, 20)), x1 = rnorm(40), y1 = rnorm(40), x2 =

[R] Reshaping and plotting tabular data

2011-04-14 Thread tsippel
Hi- Tabular data have been provided to me within .csv files. I need to transform the data from tabular format into a dataframe with three columns. The columns need to be the table row id, table column id, and the tabulated variable. An example dataset can be downloaded here:

[R] reshaping list into a contingency table

2011-02-24 Thread fbarreto
Hi all, I have been struggling with this problem for a few days. I have a data table like this: gene rpkm1 diff1 rpkm2 diff2 gene1 23 50 13 120 gene2 111 220 827 1200 gene3

Re: [R] reshaping list into a contingency table

2011-02-24 Thread Henrique Dallazuanna
Try this: reshape(x, direction = 'long', varying = list(c(2, 4), c(3, 5)), idvar = 'gene') On Thu, Feb 24, 2011 at 3:19 PM, fbarreto fbarr...@ucsd.edu wrote: Hi all, I have been struggling with this problem for a few days. I have a data table like this: gene rpkm1

Re: [R] Reshaping data

2010-07-20 Thread Thomas Jensen
Hi Dennis, Thanks for the answer, it works perfectly for two time intervals, but if I add a third interval like this: ID begin_t1end_t1 begin_t2end_t2 begin_t3end_t3 Thomas 11/03/0413/05/0604/02/07

Re: [R] Reshaping data

2010-07-20 Thread Ista Zahn
$variable - NULL dat.final - cast(m.dat, ... ~ begin.end) Hope it helps, Ista --- On Mon, 7/19/10, Thomas Jensen thomas.jen...@eup.gess.ethz.ch wrote: From: Thomas Jensen thomas.jen...@eup.gess.ethz.ch Subject: [R] Reshaping data To: R-help@r-project.org Received: Monday, July 19, 2010, 6:48 PM

[R] Reshaping data

2010-07-19 Thread Thomas Jensen
Dear All, I have some data in the following shape: ID begin_t1end_t1 begin_t2end_t2 Thomas 11/03/0413/05/0604/02/0716/05/08 ... ... ... ...

Re: [R] Reshaping data

2010-07-19 Thread Dennis Murphy
Hi: Here's one solution using function reshape() in the stats package (adapted from an R-help solution by Thomas Lumley on Nov. 26, 2002): d - read.table(textConnection( + ID begin_t1end_t1 begin_t2 end_t2 + Thomas 11/03/0413/05/06

Re: [R] Reshaping data

2010-07-19 Thread John Kane
wrote: From: Thomas Jensen thomas.jen...@eup.gess.ethz.ch Subject: [R] Reshaping data To: R-help@r-project.org Received: Monday, July 19, 2010, 6:48 PM Dear All, I have some data in the following shape: ID            begin_t1    end_t1        begin_t2    end_t2 Thomas        11/03

Re: [R] reshaping data

2010-05-21 Thread Mia Bengtsson
Thank you Dennis and Henrique for your help! Both solutions work! I just need to find a way of removing the empty cells from the final long dataframe since they are not NAs. Maybe there is an easier way of doing this of the data is not treated as a dataframe? The original data file that is

Re: [R] reshaping data

2010-05-21 Thread William Dunlap
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Mia Bengtsson Sent: Friday, May 21, 2010 3:39 AM To: Dennis Murphy; Henrique Dallazuanna Cc: r-help@r-project.org Subject: Re: [R] reshaping data Thank you Dennis

Re: [R] reshaping data

2010-05-21 Thread Mia Bengtsson
] On Behalf Of Mia Bengtsson Sent: Friday, May 21, 2010 3:39 AM To: Dennis Murphy; Henrique Dallazuanna Cc: r-help@r-project.org Subject: Re: [R] reshaping data Thank you Dennis and Henrique for your help! Both solutions work! I just need to find a way of removing the empty cells from

  1   2   >