Okay, here is something where it proved useful last night:
In a given vector of values what is the index of the 3rd non-NA value?
> x <- c(1,NA,2,NA,3)
> which(!is.na(x))[3]
[1] 5
A little different from DWin’s use, although I’d say his is compelling too!
More Related Contents:
- Removing duplicate combinations (irrespective of order)
- Painless way to install a new version of R?
- How to use an image as a point in ggplot?
- How to merge 2 vectors alternating indexes?
- How to put labels over geom_bar in R with ggplot2
- Wrap long axis labels via labeller=label_wrap in ggplot2
- How to efficiently calculate distance between pair of coordinates using data.table :=
- Access variable value where the name of variable is stored in a string
- R Shiny – add tabPanel to tabsetPanel dynamically (with the use of renderUI)
- How do I change the formatting of numbers on an axis with ggplot? [duplicate]
- How do keep only unique words within each string in a vector
- Displaying a greater than or equal sign
- How to change order of boxplots when using ggplot2?
- Find start and end positions/indices of runs/consecutive values
- R package lattice won’t plot if run using source()
- Modifying fonts in ggplot2
- listing contents of an R data file without loading
- How do you determine the namespace of a function?
- R: Plotting a 3D surface from x, y, z
- How to fill with different colors between two lines? (originally: fill geom_polygon with different colors above and below y = 0 (or any other value)?)
- How to extract certain columns from a list of data frames
- How to find out which package version is loaded in R?
- ggplot geom_point() with colors based on specific, discrete values
- Moving color key in R heatmap.2 (function of gplots package)
- GGplot custom scale transformation with custom ticks
- Save imported csv data in vector – R
- Function to concatenate paths?
- How can I label points in this scatterplot?
- Error when using predict() on a randomForest object trained with caret’s train() using formula
- Aggregating all unique values of each column of data frame