[R] cbind question, please

Clint Bowman clint at ecy.wa.gov
Fri Apr 24 01:30:39 CEST 2015


Perhaps:

> dog <- 1:3
> cat <- 2:4
> tree <- 5:7
> big.char <- cbind(dog,cat,tree)
> big.char
      dog cat tree
[1,]   1   2    5
[2,]   2   3    6
[3,]   3   4    7
> colnames(big.char)<-c("dog","cat","tree")
> big.char
      dog cat tree
[1,]   1   2    5
[2,]   2   3    6
[3,]   3   4    7



Clint Bowman			INTERNET:	clint at ecy.wa.gov
Air Quality Modeler		INTERNET:	clint at math.utah.edu
Department of Ecology		VOICE:		(360) 407-6815
PO Box 47600			FAX:		(360) 407-7534
Olympia, WA 98504-7600

         USPS:           PO Box 47600, Olympia, WA 98504-7600
         Parcels:        300 Desmond Drive, Lacey, WA 98503-1274

On Thu, 23 Apr 2015, 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.  There will be a bunch of variables.
>
> I experimented with "do.call", but all I got was
> 1
> 2
> 3
>
> Any suggestions would be much appreciated.  I still think that do.call
> might be the key, but I'm not sure.
>
> R Version 3-1.3, Windows 7.
>
> Thanks,
> Erin
>
>
> -- 
> Erin Hodgess
> Associate Professor
> Department of Mathematical and Statistics
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list