If you want a one-liner, something like
df$number.in.group = unlist(lapply(table(df$ID),seq.int))
More Related Contents:
- Forecasting by ID and Product in R [closed]
- Reshaping multiple sets of measurement columns (wide format) into single columns (long format)
- Fitting a density curve to a histogram in R
- Quit and restart a clean R session from within R?
- How to sum a numeric list elements
- melt / reshape in excel using VBA?
- Match values in data frame with values in another data frame and replace former with a corresponding pattern from the other data frame
- ggplot2: Curly braces on an axis?
- Extract matrix column values by matrix column name
- Remove everything after space in string
- Fully reproducible parallel models using caret
- Why is the terminology of labels and levels in factors so weird?
- Speed up plot() function for large dataset
- How to save data file into .RData?
- Analyzing Daily/Weekly data using ts in R
- Returning above and below rows of specific rows in r dataframe
- Remove multiple objects with rm()
- How can I arrange an arbitrary number of ggplots using grid.arrange?
- Issue when importing dataset: `Error in scan(…): line 1 did not have 145 elements`
- How to change the now deprecated dplyr::funs() which includes an ifelse argument?
- Error in new.session() : Could not establish session after 5 attempts
- rolling joins data.table in R
- Split dataframe using two columns of data and apply common transformation on list of resulting dataframes
- How do you read a password protected excel file into r?
- Error in R: (Package which is only available in source form, and may need compilation of C/C++/Fortran)
- ggplot: Boxplot of multiple column values [duplicate]
- The perils of aligning plots in ggplot
- How to create a new variable in a data.frame based on a condition?
- how to plot ellipse given a general equation in R?
- What does the %% operator mean in R? [closed]