From: jim holtman <jholtman_at_gmail.com>

Date: Mon, 07 Jul 2008 22:43:50 -0400

Date: Mon, 07 Jul 2008 22:43:50 -0400

For the first case, just extend the vector:

*> x<-c(3,4,5)
**> x
*

[1] 3 4 5

*> x[5] <- NA
**> x
*

[1] 3 4 5 NA NA

*>
*

the second would use 'which'

On Mon, Jul 7, 2008 at 5:07 PM, Eric Turkheimer <ent3c_at_virginia.edu> 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
**>
**> 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.
**>
**> --
**> Eric Turkheimer, PhD
**> Department of Psychology
**> University of Virginia
**> PO Box 400400
**> Charlottesville, VA 22904-4400
**>
**> http://www.people.virginia.edu/~ent3c
**>
**> 434-982-4732
**> 434-982-4766 (FAX)
**>
**> [[alternative HTML version deleted]]
**>
**> ______________________________________________
**> R-help_at_r-project.org mailing list
**> 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.
**>
*

-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help_at_r-project.org mailing list 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.Received on Tue 08 Jul 2008 - 02:47:28 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 Tue 08 Jul 2008 - 03:31:19 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*