The complete
takes the first argument as ‘data’, followed by the columns to expand. By default, the fill
is NA, but we can change it to 0 by specifying it in a list
.
complete(df, PERSON, FRUIT, fill = list(A=0, B = 0))
More Related Contents:
- R spreading multiple columns with tidyr [duplicate]
- Reshape multiple values at once
- Changing Million/Billion abbreviations into actual numbers? ie. 5.12M -> 5,120,000 [duplicate]
- How to transpose a dataframe in tidyverse?
- Dynamically select data frame columns using $ and a character value
- Simultaneously merge multiple data.frames in a list
- Count number of rows within each group
- Drop unused factor levels in a subsetted data frame
- Why is it not advisable to use attach() in R, and what should I use instead?
- Create an empty data.frame
- Create a group number for each consecutive sequence
- Subset data frame based on multiple conditions [duplicate]
- R – Concatenate two dataframes?
- What can R do about a messy data format?
- What is the right way to multiply data frame by vector?
- Split one row into multiple rows [duplicate]
- Shift values in single column of dataframe up
- How to use tidyr::separate when the number of needed variables is unknown [duplicate]
- What is about the first column in R’s dataset mtcars?
- combine two data frames with all posible combinations
- Last Observation Carried Forward In a data frame? [duplicate]
- tidyverse pivot_longer several sets of columns, but avoid intermediate mutate_wider steps [duplicate]
- finding close match from data frame 1 in data fame 2
- Combine several data frames in the global environment by row (rbind)
- Define dimensions of an empty dataframe
- use multiple columns as variables with sapply
- Reshape a dataframe to long format with multiple sets of measure columns [duplicate]
- Count unique values for every column
- What you can do with a data.frame that you can’t with a data.table?
- Override column types when importing data using readr::read_csv() when there are many columns