Here is solution using function ddply()
from library plyr
library(plyr)
ddply(df,.(a,b),nrow)
a b V1
1 1 2.5 1
2 1 3.5 2
3 2 2.0 2
4 3 1.0 1
5 4 2.2 1
6 4 7.0 1
More Related Contents:
- Row-wise sum for select columns while ignoring NAs [closed]
- Multirow axis labels with nested grouping variables
- How to drop columns by name in a data frame
- Idiomatic R code for partitioning a vector by an index and performing an operation on that partition
- How to unload a package without restarting R
- data.table join then add columns to existing data.frame without re-copy
- How to suppress warnings globally in an R Script
- Using two scale colour gradients ggplot2 [duplicate]
- Avoid clipping of points along axis in ggplot
- Issue with geom_text when using position_dodge
- Shiny: what is the difference between observeEvent and eventReactive?
- More than one value for “each” argument in “rep” function?
- Convert currency with commas into numeric
- Function not found in R doParallel ‘foreach’ – Error in { : task 1 failed – “could not find function “raster””
- How to delete columns that contain ONLY NAs?
- Calculate multiple aggregations on several variables using lapply(.SD, …)
- RcppArmadillo pass user-defined function
- poly() in lm(): difference between raw vs. orthogonal
- Find the most frequent value by row
- How to separate comma separated values in R in a new row?
- What is the difference between = and == in R?
- Shiny: passing input$var to aes() in ggplot2
- R: Select values from data table in range
- Apply a ggplot-function per group with dplyr and set title per group
- Can’t loop with R’s leaflet package to produce multiple maps
- dplyr: put count occurrences into new variable [duplicate]
- Convert accented characters into ascii character
- in r combine a list of lists into one list
- What does the error “arguments imply differing number of rows: x, y” mean?
- Change the position of the strip label in ggplot from the top to the bottom?