[R] Replace values in a dataframe

Shane Carey careyshan at gmail.com
Wed Jun 17 19:31:13 CEST 2015


Hey all,

I have a dataframe that consists of:

structure(list(Color = c("5", "<4","5", "<5", "5"), Unit = c("Hazen",
"Hazen",
"Hazen", "Hazen", "Hazen")), .Names = c("Color", "Unit"), row.names =
c("1:2",
"1:3", "1:4", "1:5","1:6"), class = "data.frame")

I need to find the <4 and have a new column with the result of 4 ÷ 2 = 2

Similarly

I need to find the <5 and have the new column with the result of 5 ÷ 2 = 2.5


All other numeric values would be added to the new column also to end up
with:



  Color New value Unit 1:2 5 5 Hazen 1:3 <4 2 Hazen 1:4 5 5 Hazen 1:5 <5
2.5 Hazen 1:6 5 5 Hazen



Thanks for your help!!

-- 
Shane

	[[alternative HTML version deleted]]



More information about the R-help mailing list