Skip to content

Replace a list of values in data frame

1 message · Martin Elff

#
On Friday 29 February 2008 (14:50:53), Silvia Lipski wrote:
What about:

colorful <- within(colorful,
		test1 <- replace(response,
			c("black","brown"),
			"dark"
			)
		)

or

colorful <- within(colorful,
		test1 <- response
		test1[test1 %in% c("black","brown")] <- "dark"
		)