Remove duplicated rows

I have read a CSV file into an R data.frame. Some of the rows have the same element in one of the columns. I would like to remove rows that are duplicates in that column. For example: platform_external_dbus 202 16 google 1 platform_external_dbus 202 16 space-ghost.verbum 1 platform_external_dbus 202 16 localhost 1 platform_external_dbus 202 16 … Read more

ggplot2 line chart gives “geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?”

With this data frame (“df”): year pollution 1 1999 346.82000 2 2002 134.30882 3 2005 130.43038 4 2008 88.27546 I try to create a line chart like this: plot5 <- ggplot(df, aes(year, pollution)) + geom_point() + geom_line() + labs(x = “Year”, y = “Particulate matter emissions (tons)”, title = “Motor vehicle emissions in Baltimore”) The … Read more

Use dynamic name for new column/variable in `dplyr`

I want to use dplyr::mutate() to create multiple new columns in a data frame. The column names and their contents should be dynamically generated. Example data from iris: library(dplyr) iris <- as_tibble(iris) I’ve created a function to mutate my new columns from the Petal.Width variable: multipetal <- function(df, n) { varname <- paste(“petal”, n , … Read more