[R] adding rows

2014-09-25 Thread eliza botto
Dear useRs, Here is my data with two columns and 20 rows. dput(TT) structure(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336, 360, 384, 408, 432, 456, 480), .Dim = c(20L, 2L), .Dimnames = list(NULL, c(,

Re: [R] adding rows

2014-09-25 Thread Rui Barradas
Hello, Try the following. fun - function(x, r){ if(r 0){ m - length(x) %/% r y - numeric(m) for(i in seq_len(m)){ y[i] - sum(x[((i - 1)*r + 1):(i*r)]) } y }else{

Re: [R] adding rows

2014-09-25 Thread David L Carlson
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Thursday, September 25, 2014 3:34 PM To: eliza botto; r-help@r-project.org Subject: Re: [R] adding rows Hello, Try the following. fun - function(x, r){ if(r

Re: [R] adding rows

2014-09-25 Thread Sven E. Templer
To: eliza botto; r-help@r-project.org Subject: Re: [R] adding rows Hello, Try the following. fun - function(x, r){ if(r 0){ m - length(x) %/% r y - numeric(m) for(i in seq_len(m)){ y[i] - sum(x[((i - 1)*r + 1

Re: [R] adding rows

2014-09-25 Thread Bert Gunter
Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Thursday, September 25, 2014 3:34 PM To: eliza botto; r-help@r-project.org Subject: Re: [R] adding rows Hello, Try the following. fun - function(x, r){ if(r 0

Re: [R] adding rows

2014-05-10 Thread arun
HI, If you want to try other ways: fun1 - function(mat, rowN) {     dm - dim(mat)[1]     rowN1 - rowN - 1     indx - rep(1:rowN, dm - rowN1) + rep(seq(0, dm - rowN), each = rowN)     indx1 - (seq_along(indx)-1)%/%rowN+1     as.vector(tapply(indx, list(indx1), FUN = function(i) sum(mat[i, ]))) }

Re: [R] adding rows

2014-05-10 Thread eliza botto
Thankyou very much arun. Its always nice to hear from you. Eliza Date: Sat, 10 May 2014 03:55:29 -0700 From: smartpink...@yahoo.com Subject: Re: [R] adding rows To: r-help@r-project.org CC: ruipbarra...@sapo.pt; eliza_bo...@hotmail.com HI, If you want to try other ways: fun1

[R] adding rows

2014-05-09 Thread eliza botto
Dear useRs, I have a matrix, say el of 30 rows and 10 columns, as el-matrix(sample(1:300),ncol=10) I want to sum up various sets of three rows of each column in the following manner sum(el[c(1,2,3),]) ##adding row number 1, 2 and 3 of each column sum(el[c(2,3,4),])##adding row number 2, 3 and 4

Re: [R] adding rows

2014-05-09 Thread Rui Barradas
Hello, Try the following. sapply(1:(30 - 2), function(i) sum(el[i:(i+2), ])) but with number of rows instead of 30. Hope this helps, Rui Barradas Em 09-05-2014 22:35, eliza botto escreveu: Dear useRs, I have a matrix, say el of 30 rows and 10 columns, as el-matrix(sample(1:300),ncol=10) I

Re: [R] adding rows

2014-05-09 Thread eliza botto
Dear Rui and Murphy, Thanks for your help. Eliza Date: Fri, 9 May 2014 22:55:27 +0100 From: ruipbarra...@sapo.pt To: eliza_bo...@hotmail.com; r-help@r-project.org Subject: Re: [R] adding rows Hello, Try the following. sapply(1:(30 - 2), function(i) sum(el[i:(i+2

Re: [R] adding rows without loops

2013-05-23 Thread Blaser Nello
Amin Sent: Donnerstag, 23. Mai 2013 07:01 To: r-help@r-project.org Subject: [R] adding rows without loops I'm comparing a variety of datasets with over 4M rows. I've solved this problem 5 different ways using a for/while loop but the processing time is murder (over 8 hours doing this row by row

Re: [R] adding rows without loops

2013-05-23 Thread Adeel - SafeGreenCapital
to compute. Even the bigmemory package is causing OOM issues. -Original Message- From: Blaser Nello [mailto:nbla...@ispm.unibe.ch] Sent: Thursday, May 23, 2013 12:15 AM To: Adeel Amin; r-help@r-project.org Subject: RE: [R] adding rows without loops Merge should do the trick. How to best use

Re: [R] adding rows...

2013-05-23 Thread Adeel - SafeGreenCapital
Hi Rainer: Thanks for the reply. Posting the large dataset is a task. There are 8M rows between the two of them and the first discrepancy in the data doesn't happen until at least the 40,000th row on each dataframe. The examples I posted are a pretty good abstraction of the root of the issue.

Re: [R] adding rows without loops

2013-05-23 Thread Rainer Schuermann
issues. -Original Message- From: Blaser Nello [mailto:nbla...@ispm.unibe.ch] Sent: Thursday, May 23, 2013 12:15 AM To: Adeel Amin; r-help@r-project.org Subject: RE: [R] adding rows without loops Merge should do the trick. How to best use it will depend on what you want to do

Re: [R] adding rows without loops

2013-05-23 Thread William Dunlap
, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Adeel - SafeGreenCapital Sent: Thursday, May 23, 2013 5:54 AM To: 'Blaser Nello'; r-help@r-project.org Subject: Re: [R] adding rows without

Re: [R] adding rows without loops

2013-05-23 Thread Adeel Amin
, 2013 12:15 AM To: Adeel Amin; r-help@r-project.org Subject: RE: [R] adding rows without loops Merge should do the trick. How to best use it will depend on what you want to do with the data after. The following is an example of what you could do. This will perform best, if the rows

[R] adding rows without loops

2013-05-22 Thread Adeel Amin
I'm comparing a variety of datasets with over 4M rows. I've solved this problem 5 different ways using a for/while loop but the processing time is murder (over 8 hours doing this row by row per data set). As such I'm trying to find whether this solution is possible without a loop or one in which

Re: [R] Adding rows to a table with a loop

2011-10-26 Thread MJS
Thanks for the response, and the advice, glmulti looks like it could be quite a good alternative. As for the adding to the results table problem from within the loop, this webpage: http://ryouready.wordpress.com/2009/01/23/r-combining-vectors-or-data-frames-of-unequal-length-into-one-data-frame/

[R] Adding rows to a table with a loop

2011-10-24 Thread MJS
Hi All, Its a bit of a beginners question I'm afraid. I have a looped stepwise regression (using MASS and StepAIC) to take random predictors out of the total number. For this example a random sample of 5 out of a total of 20. The loop will continue until all combinations of variables have been

Re: [R] Adding rows to a table with a loop

2011-10-24 Thread Weidong Gu
It surely can be done. One way is to keep track of selected variables in a set. If a new variable is selected, you expand the selected set and set the frequency to be one, otherwise just increase the freqency of the selected variable (if... else). Also, you might want to have a look at glmulti

[R] Adding rows based on column value

2011-07-15 Thread Bansal, Vikas
Dear all, I have one problem and did not find any solution. I have attached the question in text file also because sometimes spacing is not good in mail. I have a file(file.txt) attached with this mail.I am reading it using this code to make a data frame (file)-

Re: [R] Adding rows based on column value

2011-07-15 Thread Dennis Murphy
Hi: This seems to work: library(plyr) # select the variables to summarize: vars - paste('Case', c('A', 'C', 'G', 'T'), sep = '') # Alternatively, # vars - names(df)[grep('Case', names(df))] # One way: the ddply() function in package plyr in # conjunction with the colwise() function ddply(df,

Re: [R] Adding rows based on column value

2011-07-15 Thread Bansal, Vikas
From: Dennis Murphy [djmu...@gmail.com] Sent: Friday, July 15, 2011 7:38 PM To: Bansal, Vikas Cc: r-help@r-project.org Subject: Re: [R] Adding rows based on column value Hi: This seems to work: library(plyr) # select the variables to summarize: vars - paste('Case', c('A', 'C', 'G

Re: [R] Adding rows based on column value

2011-07-15 Thread Bansal, Vikas
[djmu...@gmail.com] Sent: Friday, July 15, 2011 7:38 PM To: Bansal, Vikas Cc: r-help@r-project.org Subject: Re: [R] Adding rows based on column value Hi: This seems to work: library(plyr) # select the variables to summarize: vars - paste('Case', c('A', 'C', 'G', 'T'), sep = '') # Alternatively

[R] Adding rows based on column value

2011-07-14 Thread Bansal, Vikas
Dear all, I have one problem and did not find any solution.(I have also attached the problem in text file because sometimes column spacing is not good in mail) I have a file(file.txt) attached with this mail.I am reading it using this code to make a data frame (file)-

Re: [R] Adding rows based on column value

2011-07-14 Thread Bert Gunter
?tapply (in base R) ?aggregate ?by (wrapper for tapply) ?ave (in base R -- based on tapply) Also package plyr (and several others, undoubtedly). Also google on R summarize data by groups or similar gets many relevant hits. -- Bert 2011/7/14 Bansal, Vikas vikas.ban...@kcl.ac.uk: Dear all,

Re: [R] Adding rows based on column value

2011-07-14 Thread Bansal, Vikas
, 2011 4:54 PM To: Bansal, Vikas Cc: r-help@r-project.org Subject: Re: [R] Adding rows based on column value ?tapply (in base R) ?aggregate ?by (wrapper for tapply) ?ave (in base R -- based on tapply) Also package plyr (and several others, undoubtedly). Also google on R summarize data by groups

Re: [R] Adding rows based on column value

2011-07-14 Thread Bansal, Vikas
Thanking you, Warm Regards Vikas Bansal Msc Bioinformatics Kings College London From: Bansal, Vikas Sent: Thursday, July 14, 2011 6:07 PM To: Bert Gunter Subject: RE: [R] Adding rows based on column value Yes sir.I am trying. I am using this- aggregate

Re: [R] Adding rows based on column value

2011-07-14 Thread Ben Bolker
Bansal, Vikas vikas.bansal at kcl.ac.uk writes: I am using this- aggregate(x = file[,3:6], by = list(file[,2]), FUN = sum) Better, although still not reproducible (please *do* read the posting guide -- it is listed at the bottom of every R list post and is the *first* google hit for

Re: [R] Adding rows based on column value

2011-07-14 Thread Bansal, Vikas
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Ben Bolker [bbol...@gmail.com] Sent: Thursday, July 14, 2011 6:24 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Adding rows based on column value Bansal, Vikas vikas.bansal at kcl.ac.uk writes: I am using

Re: [R] Adding rows based on column value

2011-07-14 Thread Ben Bolker
To: r-h...@stat.math.ethz.ch Subject: Re: [R] Adding rows based on column value Bansal, Vikas vikas.bansal at kcl.ac.uk writes: I am using this- aggregate(x = file[,3:6], by = list(file[,2]), FUN = sum) Better, although still not reproducible (please *do* read the posting guide

Re: [R] Adding rows based on column value

2011-07-14 Thread Bert Gunter
From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Ben Bolker [bbol...@gmail.com] Sent: Thursday, July 14, 2011 6:24 PM To: r-h...@stat.math.ethz.ch Subject: Re: [R] Adding rows based on column value Bansal, Vikas vikas.bansal

[R] Adding rows to column

2010-10-21 Thread amb1networks
I'm new to R. I'm extracting important columns from single table using following code: File2-file.txt table2- read.delim(File2, skip=19, sep=;, header=F, na.strings=NA, fill=T) #extracting column 7 where rows match ID col1- table2[grep(ID, table2[,1]),7] #similarly extracting column 9,11,13,15

Re: [R] Adding rows to column

2010-10-21 Thread Ivan Calandra
Hi! Would df- table2[grep(ID,table2[,1]), c(7,9,11,13,15)] do what you expect? Ivan Le 10/21/2010 15:42, amb1networks a écrit : I'm new to R. I'm extracting important columns from single table using following code: File2-file.txt table2- read.delim(File2, skip=19, sep=;, header=F,

Re: [R] Adding rows to column

2010-10-21 Thread 1Rnwb
sorry i got clik happy df2-df1[, c(3,5,7,9,11,13,15)] df2-df2[grep('ID', df2$Group), ] -- View this message in context: http://r.789695.n4.nabble.com/Adding-rows-to-column-tp3005607p3006302.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Adding rows to column

2010-10-21 Thread 1Rnwb
If I understand correctly you want to create a new dataframe with selected columns which can be achieved this was as well, it will right away create a new dataframe with column headers df2-df1[ ,c(3,7,9,11,13,15)] -- View this message in context:

[R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Ferry
Dear R users, Suppose I have the following data.frame: myID myType myNum1 myNum2 myNum3 a Single 10 11 12 b Single 15 25 35 c Double 22 33 44 d Double4 6 8 and I want

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread jim holtman
This should get you close: x - read.table(textConnection(myID myType myNum1 myNum2 myNum3 + a Single 10 11 12 + b Single 15 25 35 + c Double 22 33 44 + d Double4 6 8),

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Ferry
Thanks much Jim. On Fri, Dec 5, 2008 at 2:05 PM, jim holtman [EMAIL PROTECTED] wrote: This should get you close: x - read.table(textConnection(myID myType myNum1 myNum2 myNum3 + a Single 10 11 12 + b Single 15 25 35 + c

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Gabor Grothendieck
Here is a solution using sqldf library(sqldf) DF2 - structure(list(myID = structure(1:4, .Label = c(a, b, c, d), class = factor), myType = structure(c(2L, 2L, 1L, 1L), .Label = c(Double, Single), class = factor), myNum1 = c(10, 15, 22, 4), myNum2 = c(11, 25, 33, 6), myNum3 = c(12, 35, 44, 8)),

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread rmailbox
[EMAIL PROTECTED] Cc: r-help@r-project.org Date: Fri, 5 Dec 2008 17:50:42 -0500 Subject: Re: [R] adding rows as arithmatic calculation on original rows Here is a solution using sqldf library(sqldf) DF2 - structure(list(myID = structure(1:4, .Label = c(a, b, c, d), class = factor), myType = structure

Re: [R] adding rows as arithmatic calculation on original rows

2008-12-05 Thread Ferry
) - Original message - From: Gabor Grothendieck [EMAIL PROTECTED] To: Ferry [EMAIL PROTECTED] Cc: r-help@r-project.org Date: Fri, 5 Dec 2008 17:50:42 -0500 Subject: Re: [R] adding rows as arithmatic calculation on original rows Here is a solution using sqldf library(sqldf

[R] adding rows to table

2008-09-17 Thread Galanidis Alexandros
Greetings everyone, I'm trying to add a specific table or a specific number of rows (e.g.44) to a table with no success. This is my basic table head(dataA) yearplot spp prop.BDCA1DCA2DCA3DCA4 1 20001 a1 0.031079 -0.0776 -0.0009 0.0259 -0.0457 2 2000

[R] adding rows to table

2008-09-17 Thread Galanidis Alexandros
Greetings everyone, I'm trying to add a specific table or a specific number of rows (e.g.44) to a table with no success. This is my basic table head(dataA) yearplot spp prop.BDCA1DCA2DCA3DCA4 1 20001a1 0.031079 -0.0776 -0.0009 0.0259 -0.0457 2