Thank you very much for your comments Ista and David! I will
experiment and see which one serves my needs best.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/po
On Apr 5, 2012, at 7:01 AM, Michael Bach wrote:
Dear R users,
how do I e.g. square each second element of a vector with an even
number of elements? Or more generally to apply a function to every
'nth' element of a vector. I looked into the apply functions, but
found no hint.
For example:
v <
ken knoblauch inserm.fr> writes:
>
> Michael Bach gmail.com> writes:
> > how do I e.g. square each second element of a
> vector with an even
> > number of elements? Or more generally to
> apply a function to every
> > 'nth' element of a vector. I looked into the
> apply functions, but
> > fo
Michael Bach gmail.com> writes:
> how do I e.g. square each second element of a
vector with an even
> number of elements? Or more generally to
apply a function to every
> 'nth' element of a vector. I looked into the
apply functions, but
> found no hint.
> For example:
> v <- c(1, 2, 3, 4)
> mys
Good morning Michael,
On Thu, Apr 5, 2012 at 7:01 AM, Michael Bach wrote:
> Dear R users,
>
> how do I e.g. square each second element of a vector with an even
> number of elements? Or more generally to apply a function to every
> 'nth' element of a vector. I looked into the apply functions, but
Dear R users,
how do I e.g. square each second element of a vector with an even
number of elements? Or more generally to apply a function to every
'nth' element of a vector. I looked into the apply functions, but
found no hint.
For example:
v <- c(1, 2, 3, 4)
mysquare <- function (x) { return (x
6 matches
Mail list logo