Re: [R] Basic Vector and Matrix Operations

From: Erik Iverson <>
Date: Mon, 07 Jul 2008 16:24:30 -0500

Eric Turkheimer wrote:
> I am wondering if it is possible to perform the following two basic
> functions with primitive R functions. I know I could write functions for
> either, but it seems as though they are probably built-in somewhere.
> 1) Fill out a vector to a desired length with missing values or zeros. So,
> x<-c(3,4,5)
> f(x,5)
> 3,4,5,NA,NA

For the NA case, see ?length.

> 2) Find the [row,col] location of a particular value in a matrix, eg
> x<-matrix(1:9,ncol=3)
> f(x,2)
> 2,1
> Thanks.
> mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 07 Jul 2008 - 21:34:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 22:31:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive