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
Good morning Michael,
On Thu, Apr 5, 2012 at 7:01 AM, Michael Bach pha...@gmail.com 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
Michael Bach phaebz at 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)
ken knoblauch ken.knoblauch at inserm.fr writes:
Michael Bach phaebz at 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
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
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
6 matches
Mail list logo