I use the tail
function:
tail(vector, n=1)
The nice thing with tail
is that it works on dataframes too, unlike the x[length(x)]
idiom.
More Related Contents:
- How to convert a list consisting of vector of different lengths to a usable data frame in R?
- Convert data.frame column to a vector?
- Convert Named Character Vector to data.frame
- Converting two columns of a data frame to a named vector
- Convert a dataframe to a vector (by rows)
- Unlist a data frame by rows, not columns
- Dynamically select data frame columns using $ and a character value
- Merging a lot of data.frames [duplicate]
- dplyr: nonstandard column names (white space, punctuation, starts with numbers)
- Remove columns with zero values from a dataframe
- Calculating statistics on subsets of data [duplicate]
- How to convert dataframe into time series?
- Identifying duplicate columns in a dataframe
- Merge unequal dataframes and replace missing rows with 0
- R pass variable column indices to ggplot2 [duplicate]
- Get last row of each group in R [duplicate]
- Create empty data frame with column names by assigning a string vector? [duplicate]
- Add extra level to factors in dataframe
- Determine the data types of a data frame’s columns
- Changing Million/Billion abbreviations into actual numbers? ie. 5.12M -> 5,120,000 [duplicate]
- Extract text after “/” in a data frame column
- What is difference between dataframe and list in R?
- use multiple columns as variables with sapply
- Merge overlapping ranges into unique groups, in dataframe
- Deleting specific rows from a data frame
- Count number of non-NA values for every column in a dataframe [duplicate]
- Undefined columns selected when subsetting data frame
- How do you create vectors with specific intervals in R?
- How to create a new variable in a data.frame based on a condition?
- Interpolating timeseries