<p>Suppose I have a vector that is nested in a dataframe one or two levels.  Is there a quick and dirty way to access the last value, without using the <code>length()</code> function?  Something ala PERL's <code>$#</code> special var?</p>

<p>So I would like something like:</p>

<pre><code>dat$vec1$vec2[$#]
</code></pre>

<p>instead of</p>

<pre><code>dat$vec1$vec2[length(dat$vec1$vec2)]
</code></pre>

If you're looking for something as nice as Python's x[-1] notation, I think you're out of luck.  The standard idiom is
```
```
x[length(x)]
```
```
but it's easy enough to write a function to do this:
```
```
last <- function(x) { return( x[length(x)] ) }
```
```
This missing feature in R annoys me too!