Re: [R] cbind question, please

2015-04-24 Thread Kehl Dániel
:41 To: R help Tárgy: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy

Re: [R] cbind question, please

2015-04-24 Thread Rolf Turner
On 24/04/15 10:41, Erin Hodgess wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example.

Re: [R] cbind question, please

2015-04-24 Thread John Kane
-Original Message- From: erinm.hodg...@gmail.com Sent: Thu, 23 Apr 2015 18:41:05 -0400 To: r-h...@stat.math.ethz.ch Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7

Re: [R] cbind question, please

2015-04-24 Thread Martin Maechler
To: R help Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix

Re: [R] cbind question, please

2015-04-24 Thread Erin Hodgess
, cat, tree, big.char))) John Kane Kingston ON Canada -Original Message- From: erinm.hodg...@gmail.com Sent: Thu, 23 Apr 2015 18:41:05 -0400 To: r-h...@stat.math.ethz.ch Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have

Re: [R] cbind question, please

2015-04-24 Thread Michael Hannon
Is this what you're looking for? dog - 1:3 bat - 2:4 tree - 5:7 big.char - c(dog,bat,tree) do.call(cbind,lapply(big.char, get)) [,1] [,2] [,3] [1,]125 [2,]236 [3,]347 On Thu, Apr 23, 2015 at 3:41 PM, Erin Hodgess erinm.hodg...@gmail.com wrote:

Re: [R] cbind question, please

2015-04-24 Thread Berwin A Turlach
G'day Erin, On Thu, 23 Apr 2015 20:51:18 -0400 Erin Hodgess erinm.hodg...@gmail.com wrote: Here is the big picture. I have a character vector with all of the names of the variables in it. I want to cbind all of the variables to create a matrix. Doing 3 is straightforward, but many, not

Re: [R] cbind question, please

2015-04-24 Thread Rolf Turner
I am amazed at the number of rather obtuse misunderstandings of the actual nature of Erin's question. The suggestion that Erin should read the intro to R made me smile. Erin is a long time and highly sophisticated user of R; she has no need to read the intro. The person who made that

Re: [R] cbind question, please

2015-04-24 Thread David Kienle
Hello Erin, I think you have explain your goal more detailed. Maybe I am completely lost but as far as I understand now you only need the command cbind: m1 - cbind(dog, dat, tree) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 But I can't imagine that is the solution

Re: [R] cbind question, please

2015-04-24 Thread William Dunlap
You could do something tricky like do.call(cbind, lapply(big.char, as.name)) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 but you are usually better off creating these things as part of a list and passing that to do.call(cbind, list). There is a slight danger

Re: [R] cbind question, please

2015-04-24 Thread Clint Bowman
Perhaps: dog - 1:3 cat - 2:4 tree - 5:7 big.char - cbind(dog,cat,tree) big.char dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 colnames(big.char)-c(dog,cat,tree) big.char dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 Clint Bowman

Re: [R] cbind question, please

2015-04-24 Thread Jim Lemon
Hi Erin, Well, if I do this: dog - 1:3 cat - 2:4 tree - 5:7 dct-cbind(dog,cat,tree) I get this: dct dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 If I assume that you want to include the character vector as well: rownames(dct)-big.char dct Jim On Fri, Apr 24, 2015

Re: [R] cbind question, please

2015-04-24 Thread Marc Schwartz
On Apr 23, 2015, at 5:41 PM, Erin Hodgess erinm.hodg...@gmail.com wrote: Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of

Re: [R] cbind question, please

2015-04-24 Thread Steve Taylor
: Friday, 24 April 2015 10:41a To: R help Subject: [R] cbind question, please Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat

Re: [R] cbind question, please

2015-04-24 Thread Erin Hodgess
These are great! Thank you! On Thu, Apr 23, 2015 at 7:14 PM, William Dunlap wdun...@tibco.com wrote: You could do something tricky like do.call(cbind, lapply(big.char, as.name)) dog cat tree [1,] 1 25 [2,] 2 36 [3,] 3 47 but you are usually better

[R] cbind question, please

2015-04-23 Thread Erin Hodgess
Hello! I have a cbind type question, please: Suppose I have the following: dog - 1:3 cat - 2:4 tree - 5:7 and a character vector big.char - c(dog,cat,tree) I want to end up with a matrix that is a cbind of dog, cat, and tree. This is a toy example. There will be a bunch of variables. I

Re: [R] cbind in a loop...better way? | summary

2014-10-09 Thread Evan Cooch
Two solutions proposed -- not entirely orthogonal, but both do the trick. Instead of nesting cbin in a loop (as I did originally -- OP, below), 1\ do.call(cbind, lapply(mat_list, as.vector)) or 2\ sapply(mat_list,function(x) as.vector(x)) Both work fine. Thanks to Jeff Laake (2) +

Re: [R] cbind in a loop...better way? | summary

2014-10-09 Thread David L Carlson
Subject: Re: [R] cbind in a loop...better way? | summary Two solutions proposed -- not entirely orthogonal, but both do the trick. Instead of nesting cbin in a loop (as I did originally -- OP, below), 1\ do.call(cbind, lapply(mat_list, as.vector)) or 2\ sapply(mat_list,function(x) as.vector(x

Re: [R] cbind in a loop...better way? | summary

2014-10-09 Thread Wensui Liu
] On Behalf Of Evan Cooch Sent: Thursday, October 9, 2014 7:37 AM To: Evan Cooch; r-help@r-project.org Subject: Re: [R] cbind in a loop...better way? | summary Two solutions proposed -- not entirely orthogonal, but both do the trick. Instead of nesting cbin in a loop (as I did originally -- OP

Re: [R] cbind in a loop...better way? | summary

2014-10-09 Thread Evan Cooch
, 2014 7:37 AM To: Evan Cooch; r-help@r-project.org Subject: Re: [R] cbind in a loop...better way? | summary Two solutions proposed -- not entirely orthogonal, but both do the trick. Instead of nesting cbin in a loop (as I did originally -- OP, below), 1\ do.call(cbind, lapply(mat_list, as.vector

[R] cbind in a loop...better way?

2014-10-08 Thread Evan Cooch
...or some such. I'm trying to work up a function wherein the user passes a list of matrices to the function, which then (1) takes each matrix, (2) performs an operation to 'vectorize' the matrix (i.e., given an (m x n) matrix x, this produces the vector Y of length m*n that contains the

Re: [R] cbind in a loop...better way?

2014-10-08 Thread David L Carlson
of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Evan Cooch Sent: Wednesday, October 8, 2014 2:13 PM To: r-help@r-project.org Subject: [R] cbind in a loop...better way

Re: [R] cbind in a loop...better way?

2014-10-08 Thread Evan Cooch
[mailto:r-help-boun...@r-project.org] On Behalf Of Evan Cooch Sent: Wednesday, October 8, 2014 2:13 PM To: r-help@r-project.org Subject: [R] cbind in a loop...better way? ...or some such. I'm trying to work up a function wherein the user passes a list of matrices to the function, which then (1

Re: [R] cbind with row names to serveral files in R

2014-04-19 Thread arun
Hi, The rownames part is not clear as your expected output and input files didn't show them as rownames. ##Suppose you have all the files in a folder ##here I am creating the names of those files files1 - paste0(sample, rep(1:777, each=29),chr,1:29,.txt) length(files1) #[1] 22533 lst1 - 

[R] cbind() function : Not able to display columns

2013-10-22 Thread Vivek Singh
Hi All, I have create a matrix using cbind() function as follows: a=c(1,2,3) b=c('a','b','c') c=c(ee,tt,rr) k=cbind(a,b,c) Problem: when we print the matrix k, k a b c [1,] 1 a ee [2,] 2 b tt [3,] 3 c rr we can see that rows are represented by [1,] , [2,] and [3,].

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread arun
Hi, Try:   k[,a] #[1] 1 2 3  k[,b] #[1] a b c  k[,c] #[1] ee tt rr A.K. On Tuesday, October 22, 2013 11:37 PM, Vivek Singh vksingh.ii...@gmail.com wrote: Hi All, I have create a matrix using cbind() function as follows: a=c(1,2,3) b=c('a','b','c') c=c(ee,tt,rr) k=cbind(a,b,c)

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread Jeff Newmiller
Hard to say, not sure what you want to do. But the columns are not denoted by [a], [b] or [c]. You should learn to use the str function to understand what various expressions really are, and return to the Introduction to R document that comes with the software. There is a distinct difference

Re: [R] cbind() function : Not able to display columns

2013-10-22 Thread Richard M. Heiberger
In addition to what the others have told you, it looks like you might be confusing matrices with data.frames. Please see ?data.frame I think what you are looking for is b - c('a','b','c') c - c(ee,tt,rr) k - cbind(a,b,c) K - data.frame(a, b, c) K a b c 1 1 a ee 2 2 b tt 3 3 c rr I

Re: [R] cbind with headers

2013-08-08 Thread arun
Hi, You can save it in file.  I copy and paste: Subtype,Gender,Expression A,m,-0.54 A,f,-0.8 B,f,-1.03 C,m,-0.41 on the gedit and save it as data1.csv.  You might be able to do the same with notepad. x - read.csv(data1.csv,header=T,sep=,) x2 - read.csv(data2N.csv,header=T,sep=,) x3 -

[R] cbind with headers

2013-08-08 Thread Docbanks84
Hi, I can't seem to get this to work: http://www.endmemo.com/program/R/cbind.php Do I save the data as data1.csv in note pad and pull in the file? Do I type data1.csv-Subtype,Gender,Expression,A,m,-0.54,A,f,-0.8,B,f,-1.03,C,m,-0.41?? I can do a simple matrix. But, I want to have headers and

[R] cbind error with check.names

2013-07-23 Thread Fg Nu
Hello all, I posted a question about cbind and an error when specifying the check.names argument here: http://stackoverflow.com/questions/17810470/cbind-error-with-check-names I was advised to take this to R-devel, but before that, I'd like to get the opinions of people on this list.

Re: [R] cbind for list of zoo objects

2013-04-09 Thread Harry Mamaysky
Thanks for the explanations. Wouldn't the following bit of checking in do.call() make it easier to figure such things out in the future? my.call - function(what,args,...) { ## Get the name of the function to call. if (!is.character(what)) whatStr - deparse(substitute(what))

Re: [R] cbind for list of zoo objects

2013-04-09 Thread Joshua Ulrich
On Tue, Apr 9, 2013 at 7:31 AM, Harry Mamaysky h.mamay...@gmail.com wrote: Thanks for the explanations. Wouldn't the following bit of checking in do.call() make it easier to figure such things out in the future? Sure, it would have helped you figure out your issue, but you don't want a

Re: [R] cbind for list of zoo objects

2013-04-09 Thread Harry Mamaysky
That's true. So perhaps there should be a flag that turns on this error checking. Often args is just a list that gets generated automatically and you don't know what all of its elements are. It just leads to a bit of non-deterministic behavior. It would be useful to have the option of flagging

Re: [R] cbind for list of zoo objects

2013-04-09 Thread Gabor Grothendieck
On Tue, Apr 9, 2013 at 9:15 AM, Harry Mamaysky h.mamay...@gmail.com wrote: That's true. So perhaps there should be a flag that turns on this error checking. Often args is just a list that gets generated automatically and you don't know what all of its elements are. It just leads to a bit of

Re: [R] cbind for list of zoo objects

2013-04-09 Thread Harry Mamaysky
That's a nice solution. Thanks. Sent from my iPhone On Apr 9, 2013, at 10:00 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Tue, Apr 9, 2013 at 9:15 AM, Harry Mamaysky h.mamay...@gmail.com wrote: That's true. So perhaps there should be a flag that turns on this error checking.

[R] cbind for list of zoo objects

2013-04-08 Thread Harry Mamaysky
Can someone explain why this happens when one of the list elements is named 'all'? zz - list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) ) names(zz)-c('test','bar','foo') do.call(cbind,zz) test bar foo 1 1 101 201 2 2 102 202 3 3 103 203 4 4 104 204 5 5 105

Re: [R] cbind for list of zoo objects

2013-04-08 Thread Joshua Ulrich
Because 'all' is the name of one of the arguments to cbind.zoo: R args(cbind.zoo) function (..., all = TRUE, fill = NA, suffixes = NULL, drop = FALSE) NULL do.call constructs a call somewhat like: R cbind(test=zz$test, all=zz$all, foo=zz$foo) The same thing would happen for list elements named

Re: [R] cbind for list of zoo objects

2013-04-08 Thread Gabor Grothendieck
On Mon, Apr 8, 2013 at 3:54 PM, Harry Mamaysky h.mamay...@gmail.com wrote: Can someone explain why this happens when one of the list elements is named 'all'? zz - list( zoo(1:10,1:10), zoo(101:110,1:10), zoo(201:210,1:10) ) names(zz)-c('test','bar','foo') do.call(cbind,zz) test bar foo

[R] cbind and cbind.data.frame

2012-07-09 Thread James Long
## Hi, I'm having trouble understanding how the cbind function decides what method to apply to its arguments. Easy cut and paste code below. ## create two columns c1 - c(A,A,B,B) c2 - 1:4 ## cbind outputs a matrix with elements that are characters, seems reasonable out -

Re: [R] cbind and cbind.data.frame

2012-07-09 Thread Michael Weylandt
Short answer: there is a default method used here which returns a matrix. It's defined at the C-level for speed so you don't see it with methods() Longer: cbind() isn't a regular S3 generic since it has no UseMethod(). Look at WRE and R-Internals (internal generics) for more info. Best (and

Re: [R] Cbind help

2012-04-16 Thread Osvald Wiklander
Hi, we have a problem concerning the use and forecasting on the GARCH (1, 1) on financial data. We would like to make predictions on future returns in a loop which moves the window of estimation forward one unit for each iteration. Our code is as follows: BJORN -

[R] cbind, data.frame | numeric to string?

2012-04-10 Thread Anser Chen
Complete newbie to R -- struggling with something which should be pretty basic. Trying to create a simple data set (which I gather R refers to as a data.frame). So a - c(1,2,3,4,5); b - c(0.3,0.4,0.5,0,6,0.7); Stick the two together into a data frame (call test) using cbind test -

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread R. Michael Weylandt
Don't use cbind() -- it forces everything into a single type, here string, which in turn becomes factor. Simply, data.frame(a, b, c) Like David mentioned a few days ago, I have no idea who is promoting this data.frame(cbind(...)) idiom, but it's a terrible idea (albeit one that seems to be very

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread Jessica Streicher
Still didn't work for me without cbind , although you really don't need it ;) worked after i set options(stringsAsFactors=F). options(stringsAsFactors=F) df-data.frame(intVec,chaVec) df intVec chaVec 1 1 a 2 2 b 3 3 c df$chaVec [1] a b c documentation of

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread Rainer Schuermann
cbind() works as well, but only if c is attached to the existing test variable: tst - cbind( test, c ) tst ab c

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread R. Michael Weylandt
Sorry, I missed that the OP's real question was in character/factor, not in the why are these all factors bit...good catch. Rant about cbind() still stands though. :-) [Your way with cbind() would give him all characters, not some characters and some numerics since cbind() gives a matrix by

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread David Winsemius
On Apr 10, 2012, at 11:58 AM, Rainer Schuermann wrote: cbind() works as well, but only if c is attached to the existing test variable: tst - cbind( test, c ) tst ab c 1 1 0.3 y1 2 2 0.4 y2 3 3 0.5 y3 4 4 0.6 y4 5 5 0.7 y5 str( tst ) 'data.frame': 5 obs. of 3

Re: [R] cbind, data.frame | numeric to string?

2012-04-10 Thread David Winsemius
On Apr 10, 2012, at 12:19 PM, David Winsemius wrote: On Apr 10, 2012, at 11:58 AM, Rainer Schuermann wrote: cbind() works as well, but only if c is attached to the existing test variable: tst - cbind( test, c ) tst ab c 1 1 0.3 y1 2 2 0.4 y2 3 3 0.5 y3 4 4 0.6 y4 5

[R] cbind alternate

2012-01-06 Thread Mary Kindall
I have two one dimensional list of elements and want to perform cbind and then write into a file. The number of entries are more than a million in both lists. R is taking a lot of time performing this operation. Is there any alternate way to perform cbind? x = table1[1:100,1] y =

Re: [R] cbind alternate

2012-01-06 Thread Bos, Roger
, 2012 12:43 PM To: r-help@r-project.org Subject: [R] cbind alternate I have two one dimensional list of elements and want to perform cbind and then write into a file. The number of entries are more than a million in both lists. R is taking a lot of time performing this operation. Is there any

Re: [R] cbind alternate

2012-01-06 Thread Marc Schwartz
On Jan 6, 2012, at 11:43 AM, Mary Kindall wrote: I have two one dimensional list of elements and want to perform cbind and then write into a file. The number of entries are more than a million in both lists. R is taking a lot of time performing this operation. Is there any alternate way to

Re: [R] cbind alternate

2012-01-06 Thread David Winsemius
On Jan 6, 2012, at 12:43 PM, Mary Kindall wrote: I have two one dimensional list of elements and want to perform cbind and then write into a file. The number of entries are more than a million in both lists. R is taking a lot of time performing this operation. Is there any alternate way

Re: [R] cbind alternate

2012-01-06 Thread Marc Schwartz
On Jan 6, 2012, at 12:39 PM, Marc Schwartz wrote: On Jan 6, 2012, at 11:43 AM, Mary Kindall wrote: I have two one dimensional list of elements and want to perform cbind and then write into a file. The number of entries are more than a million in both lists. R is taking a lot of time

Re: [R] cbind alternate

2012-01-06 Thread Rui Barradas
Hello, I believe this function can handle a problem of that size, or bigger. It does NOT create the full matrix, just writes it to a file, a certain number of lines at a time. write.big.matrix - function(x, y, outfile, nmax=1000){ if(file.exists(outfile)) unlink(outfile) testf

Re: [R] cbind alternate

2012-01-06 Thread Rui Barradas
Sorry Mary, My function would write the remainder twice, I had only tested it with multiples of the chunk size. (And without looking at the lenghty output correctly.) Now checked: write.big.matrix - function(x, y, outfile, nmax=1000){ if(file.exists(outfile)) unlink(outfile) testf -

Re: [R] cbind alternate

2012-01-06 Thread jim holtman
What is it you want to do with the data after you save it? Are you just going to read it back into R? If so, consider using save/load. On Fri, Jan 6, 2012 at 12:43 PM, Mary Kindall mary.kind...@gmail.com wrote: I have two one dimensional list of elements and want to perform cbind and then

Re: [R] cbind giving NA's?

2011-10-24 Thread Joshua Ulrich
Note that this issue was raised on StackOverflow recently. http://stackoverflow.com/questions/7678090/xts-merge-odd-behaviour Here's the solution: index(a) - index(a) index(b) - index(b) merge(a,b) ZWD.UGX SCHB.Close 2010-03-31 NA 28.02 2010-04-01 7.6343 NA

[R] cbind giving NA's?

2011-08-26 Thread Hasan Diwan
I have two xts objects, call them a and b, and am trying to merge them... class(a) [1] xts zoo class(b) [1] xts zoo head(a) 2010-04-01 7.6343 2010-04-02 7.6343 2010-04-03 7.5458 2010-04-04 7.4532 2010-04-05 7.4040 2010-04-06 7.3317 head(b) 2010-04-01 568.80 2010-04-05 571.01

Re: [R] cbind giving NA's?

2011-08-26 Thread R. Michael Weylandt
Hmm, that's quite puzzling. I don't know but I'd willing to guess the time/date stamps on a,b are more different than the output is leading us to believe. My experience is that there's always more to a time/date object to trick us up than one would expect. If you could, dput() them so we can see

Re: [R] cbind giving NA's?

2011-08-26 Thread Hasan Diwan
On 26 August 2011 03:37, R. Michael Weylandt michael.weyla...@gmail.com wrote: If you could, dput() them so we can see everything about them. You also might see if merge() gives you more expected behavior Ok... dput(a) structure(c(7.6343, 7.6343, 7.5458, 7.4532, 7.404, 7.3317), class =

Re: [R] cbind giving NA's?

2011-08-26 Thread Petr PIKAL
Hi On 26 August 2011 03:37, R. Michael Weylandt michael.weyla...@gmail.com wrote: If you could, dput() them so we can see everything about them. You also might see if merge() gives you more expected behavior Ok... dput(a) structure(c(7.6343, 7.6343, 7.5458, 7.4532, 7.404,

Re: [R] cbind giving NA's?

2011-08-26 Thread Dennis Murphy
Hi: Try this: require('xts') merge.zoo(zoo(a), zoo(b), all = c(TRUE, TRUE)) ZWD.UGX SCHB.Close 2010-03-31 NA 28.02 2010-04-01 7.6343 NA 2010-04-02 7.6343 NA 2010-04-03 7.5458 NA 2010-04-04 7.4532 28.30 2010-04-05 7.4040 28.38

Re: [R] cbind giving NA's?

2011-08-26 Thread Petr PIKAL
I was rather too quick It has probably something to do with versions of zoo and xts after updating to zoo 1.7.4 and xts 0.8.2 I got with your examples merge(a,b) ZWD.UGX SCHB.Close 2010-04-01 NA 28.02 2010-04-01 7.6343 NA 2010-04-02 7.6343 NA 2010-04-03

Re: [R] cbind giving NA's?

2011-08-26 Thread R. Michael Weylandt
This seems to be the easiest way to handle the problem: a = xts(coredata(a), time(a)) b = xts(coredata(b), time(b)) merge(a,b) ZWD.UGX SCHB.Close 2010-03-31 NA 28.02 2010-04-01 7.6343 NA 2010-04-02 7.6343 NA 2010-04-03 7.5458 NA 2010-04-04

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-15 Thread peter dalgaard
For a little lateral thinking, consider the use of . on the LHS. That could play out as follows: myvars - c(Ozone,Wind) f - . ~ Month j - union(all.vars(f[[3]]), myvars) aggregate(. ~ Month, data=airquality[j], mean, na.rm=T) MonthOzone Wind 1 5 23.61538 11.457692 2 6

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-15 Thread Dimitri Liakhovitski
Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Thursday, July 14, 2011 1:45 PM To: David Winsemius Cc: r-help Subject: Re: [R] cbind in aggregate

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-15 Thread peter dalgaard
On Jul 15, 2011, at 15:06 , peter dalgaard wrote: For a little lateral thinking, consider the use of . on the LHS. That could play out as follows: myvars - c(Ozone,Wind) f - . ~ Month j - union(all.vars(f[[3]]), myvars) aggregate(. ~ Month, data=airquality[j], mean, na.rm=T) Month

[R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread Dimitri Liakhovitski
Hello! I am aggregating using a formula in aggregate - of the type: aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata) However, I actually have an object (vector of my variables to be aggregated): myvars-c(var1,var2,var3) I'd like my aggregate formula (its cbind part) to be able

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread David Winsemius
On Jul 14, 2011, at 3:05 PM, Dimitri Liakhovitski wrote: Hello! I am aggregating using a formula in aggregate - of the type: aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata) However, I actually have an object (vector of my variables to be aggregated):

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread Dimitri Liakhovitski
Thank you, David, it does work. Could you please explain why? What exactly does changing it to as matrix do? Thank you! Dimitri On Thu, Jul 14, 2011 at 3:25 PM, David Winsemius dwinsem...@comcast.net wrote: On Jul 14, 2011, at 3:05 PM, Dimitri Liakhovitski wrote: Hello! I am aggregating

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread Bert Gunter
Dmitri: Look at my vars from myvars-c(value1,value2) It's just a character vector of length 2! You can't cbind a character vector of length 2! These are not references/pointers. It's not at all clear to me what you ultimately want to do, but IF it's: pass a character vector of names to be used

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread David Winsemius
Dmitri: as.matrix makes a matrix out of the dataframe that is passed to it. As a further note I attempted and failed for reasons that are unclear to me to construct a formula that would (I hoped) preserve the column names which are being mangle in the posted effort: form -

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread Dimitri Liakhovitski
Thanks a lot! actually, what I tried to do is very simple - just passing tons of variable names into the formula. Maybe that get thing suggested by Bert would work... Dimitri On Thu, Jul 14, 2011 at 4:01 PM, David Winsemius dwinsem...@comcast.net wrote: Dmitri: as.matrix makes a matrix out

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread Dimitri Liakhovitski
David - I tried exactly the thing you did (and after that asked my question to the forum): form - as.formula(paste( cbind(, paste( myvars, collapse=,), ) ~ group+mydate, sep= ) ) And it did not work - although

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread William Dunlap
To: David Winsemius Cc: r-help Subject: Re: [R] cbind in aggregate formula - based on an existing object (vector) Thanks a lot! actually, what I tried to do is very simple - just passing tons of variable names into the formula. Maybe that get thing suggested by Bert would work... Dimitri On Thu, Jul

Re: [R] cbind in aggregate formula - based on an existing object (vector)

2011-07-14 Thread Dennis Murphy
Hi: I think Bill's got the right idea for your problem, but for the fun of it, here's how Bert's suggestion would play out: # Kind of works, but only for the first variable in myvars... aggregate(get(myvars) ~ group + mydate, FUN = sum, data = example) group mydate get(myvars) 1 group1

Re: [R] cbind 3 or more matrices

2011-06-04 Thread Jim Silverton
How can I cbind three or more matrices like A,B and C. This does not work: cbind(A,B,C) -- Thanks, Jim. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] cbind 3 or more matrices

2011-06-04 Thread Sarah Goslee
do.call(cbind, list(A, B, C)) On Sat, Jun 4, 2011 at 7:14 PM, Jim Silverton jim.silver...@gmail.com wrote: How can I cbind three or more matrices like A,B and C. This does not work: cbind(A,B,C) -- Thanks, Jim. -- Sarah Goslee http://www.functionaldiversity.org

Re: [R] cbind 3 or more matrices

2011-06-04 Thread baptiste auguie
A, B, C should have the same number of rows. mlist = replicate(3, matrix(rnorm(6), 2), simplify=FALSE) names(mlist) = LETTERS[seq_along(mlist)] with(mlist, cbind(A,B,C)) or, do.call(cbind, mlist) HTH, baptiste On 5 June 2011 11:14, Jim Silverton jim.silver...@gmail.com wrote: How can I

Re: [R] cbind 3 or more matrices

2011-06-04 Thread Phil Spector
Jim - In what sense does cbind(A,B,C) not work? A = matrix(rnorm(10),5,2) B = matrix(rnorm(15),5,3) C = matrix(rnorm(20),5,4) cbind(A,B,C) [,1] [,2] [,3] [,4] [,5][,6] [1,] -0.54194873 -1.1105170 -0.479010 0.619911163 0.1610162 0.49028633 [2,]

Re: [R] Cbind query

2010-10-23 Thread karthicklakshman
Hello jholtman, Thanks very much for the suggestion. I tried using as.is=TRUE and it worked as the way I expected. Sorry for not being clear about the problem in my mail. The characters are very much needed, cos I am trying to create a signaling network using Rgraphviz. Thanks again. Regards,

[R] Cbind query

2010-10-22 Thread karthicklakshman
I am new to R and request your kind help. I have a table like the one below, one two 1 apple fruit 2 ball game 3 chair wood 4 wood plain 5 fruitbanana 6 cloth silk Note: duplicate entries are there the task is to create relations to each

Re: [R] Cbind query

2010-10-22 Thread jim holtman
This comes about since when using read.table (which I assume you did, but you did not show us what commands you were using), characters are converted to factors. If you are not using factors, then you probably want the data read in as characters. You should understand the use of 'str' to look at

[R] cbind

2010-08-21 Thread r.ookie
Is there a way to rename the columns to something like A and B in the cbind function? x - rnorm(n = 10, mean = 0, sd = 1) y - rnorm(n = 10, mean = 0, sd = 1) cbind(x,y) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] cbind

2010-08-21 Thread RICHARD M. HEIBERGER
cbind(A=x, B=y) On Sat, Aug 21, 2010 at 6:53 PM, r.ookie r.oo...@live.com wrote: Is there a way to rename the columns to something like A and B in the cbind function? x - rnorm(n = 10, mean = 0, sd = 1) y - rnorm(n = 10, mean = 0, sd = 1) cbind(x,y)

Re: [R] cbind

2010-08-21 Thread Peter Ehlers
On 2010-08-21 16:53, r.ookie wrote: Is there a way to rename the columns to something like A and B in the cbind function? x- rnorm(n = 10, mean = 0, sd = 1) y- rnorm(n = 10, mean = 0, sd = 1) cbind(x,y) Unless I completely misunderstand your query, ?cbind tells you: ... vectors or

Re: [R] cbind

2010-08-21 Thread r.ookie
Thanks. On Aug 21, 2010, at 4:01 PM, RICHARD M. HEIBERGER wrote: cbind(A=x, B=y) On Sat, Aug 21, 2010 at 6:53 PM, r.ookie r.oo...@live.com wrote: Is there a way to rename the columns to something like A and B in the cbind function? x - rnorm(n = 10, mean = 0, sd = 1) y - rnorm(n = 10, mean

[R] CBIND / MERGE two time series objects along time (overlapping indices, redundant data)

2010-07-30 Thread Bernhard Von Boyen
Hi there, I need to merge/bind two time series objects (from RPackage: timeSeries) by column. The theory is laid out nicely, even for overlapping indices. In my example, I have overlapping indices (01.01.2001), where in one time series I have one data point and in the other redundant data.

[R] cbind in for loops

2010-07-12 Thread jd6688
I have 30 files in the current directories, i would like to perform the cbind(fil1,file2,file3,file4file30) how could i do this in a for loop: such as: file2 - list.files(pattern=.out3$) for (j in file2) { cbind(j)...how to implement cbind here } Thanks.

Re: [R] cbind in for loops

2010-07-12 Thread Joshua Wiley
Hi, Assuming that you have read the files into R, and that their names (in R) are held in some object (e.g., 'file2'), then this works do.call(what = cbind, args = mget(x = file2, envir = .GlobalEnv) Here is a reproducible example: x1 - data.frame(x = 1:10) x2 - data.frame(y = 1:10) file.names

Re: [R] cbind in for loops

2010-07-12 Thread David Winsemius
On Jul 12, 2010, at 2:32 AM, Joshua Wiley wrote: Hi, Assuming that you have read the files into R, and that their names (in R) are held in some object (e.g., 'file2'), then this works do.call(what = cbind, args = mget(x = file2, envir = .GlobalEnv) Here is a reproducible example: x1 -

Re: [R] cbind in for loops

2010-07-12 Thread Henrique Dallazuanna
Try this: do.call(cbind, lapply(dir(pattern = '.out3$'), read.table)) On Mon, Jul 12, 2010 at 1:08 AM, jd6688 jdsignat...@gmail.com wrote: I have 30 files in the current directories, i would like to perform the cbind(fil1,file2,file3,file4file30) how could i do this in a for loop:

Re: [R] cbind with vectors of different lengths?

2010-06-10 Thread Roman Luštrik
I wrote a function that cbinds vectors of different lengths. Basically, the function adds NAs to shorter vectors and cbinds in the end. I'm attaching the code for guidance. # This function takes in a list() of vectors and cbinds them into a data.frame. timerMelt - function(x, write.down = FALSE,

[R] cbind with vectors of different lengths?

2010-06-09 Thread Arantzazu Blanco Bernardeau
Hello R help I have a dataframe, with 71 samples (rows) and 30 variables. I got linear models for some of the variables,  and I want to join fitted and residuals of these models to the data frame. Sometimes, these vectors have the same length of the dependant variable, but in a few cases, NA

Re: [R] cbind and automatic type conversion

2010-05-02 Thread Uwe Ligges
On 01.05.2010 21:09, Giovanni Azua wrote: Hello, I have three method types and 100 generalization errors for each, all in the range [0.65,0.81]. I would like to make a stacked histogram plot using ggplot2 with this data ... Therefore I need a data frame of the form e.g. Method

[R] cbind and automatic type conversion

2010-05-01 Thread Giovanni Azua
Hello, I have three method types and 100 generalization errors for each, all in the range [0.65,0.81]. I would like to make a stacked histogram plot using ggplot2 with this data ... Therefore I need a data frame of the form e.g. Method GE -- --

[R] cbind, row names

2010-01-29 Thread soeren . vogel
Hello, I read the help as well as the examples, but I can not figure out why the following code does not produce the *given* row names, x and y: x - 1:20 y - 21:40 rbind( x=cbind(N=length(x), M=mean(x), SD=sd(x)), y=cbind(N=length(y), M=mean(y), SD=sd(y)) ) Could you please help? Thank

Re: [R] cbind, row names

2010-01-29 Thread Henrique Dallazuanna
This gives what you want: rbind.data.frame( x=cbind(N=length(x), M=mean(x), SD=sd(x)), y=cbind(N=length(y), M=mean(y), SD=sd(y)) ) On Fri, Jan 29, 2010 at 8:49 AM, soeren.vo...@eawag.ch wrote: Hello, I read the help as well as the examples, but I can not figure out why the following

Re: [R] cbind, row names

2010-01-29 Thread K. Elo
Hi! 29.01.2010 12:49, soeren.vo...@eawag.ch wrote: Hello, I read the help as well as the examples, but I can not figure out why the following code does not produce the *given* row names, x and y: x - 1:20 y - 21:40 rbind( x=cbind(N=length(x), M=mean(x), SD=sd(x)),

  1   2   >