-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi
I have to replace the last element of a vector with 0, but the length of
x is not known at coding time. So I do the following:
x - 1:10
x
x[length(x)] - 0
x
it is working nicely, but I am wondering: is there a more elegant
solution( like
Another way:
x - replace(x, length(x), 0)
On Thu, Jul 29, 2010 at 8:12 AM, Rainer M Krug r.m.k...@gmail.com wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Hi
I have to replace the last element of a vector with 0, but the length of
x is not known at coding time. So I do the
Hi,
The function head also works.
x - 1:10
head(x,-1)
-
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/Replace-last-element-in-a-vector-elegant-solution-tp2306315p2306471.html
Sent from the R help mailing list archive at Nabble.com.
3 matches
Mail list logo