update | R Documentation |
Update a data.frame using specific integers for row numbers or a vectorised filter. Also supports dplyr groups. see Examples.
## S3 method for class 'data.frame'
update(object, rows, ...)
object |
a data.frame |
rows |
row numbers or a logical vector |
... |
arguments passed on to |
iris |>
update(3:4, Species = c("A", "B")) |>
head()
iris |>
update(Species == "setosa" & Sepal.Length > 5,
Species = "something else") |>
head()
if (require("dplyr")) {
# also supports dplyr groups:
iris |>
group_by(Species) |>
# update every 2nd to 4th row in group
update(2:4, Species = "test") |>
# groups will be updated automatically
count()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.