I have a dataset consisting of 1500 rows and 3 rows. I want to create a new row, that gives a name based on the data from another row.
What I have:
Bbg_Parks %>%
mutate(City = ifelse(FID_BBG2012_Clip %in% 1:4455,
"Rotterdam",
ifelse(FID_BBG2012_Clip %in% 4744:5655 & 10335,
"The_Hague",
ifelse(FID_BBG2012_Clip %in% 5861:7015,
"Utrecht",
ifelse(FID_BBG2012_Clip %in% 7110:10190,
"Amsterdam", "no")))))
What I want:
Bbg_Parks %>%
mutate(City = ifelse(FID_BBG2012_Clip %in% 1:4455 & 5736 & 10220:10330,
"Rotterdam",
ifelse(FID_BBG2012_Clip %in% 4744:5655 & 10335,
"The_Hague",
ifelse(FID_BBG2012_Clip %in% 5861:7015 & 10381:10385,
"Utrecht",
ifelse(FID_BBG2012_Clip %in% 7110:10190 & 10447:10488,
"Amsterdam", "no")))))
However, the last code doesn't work, as it gives me the error:
Error: Problem with mutate()
input City
. x unused arguments ("Rotterdam", ifelse(FID_BBG2012_Clip %in% 4744:5655, 10335, "The_Hague", ifelse(FID_BBG2012_Clip %in% 5861:7015, 10381:10385, "Utrecht", ifelse(FID_BBG2012_Clip %in% 7110:10190, 10447:10488, "Amsterdam", "no")))). i Input City
is ifelse(...)
. Run rlang::last_error()
to see where the error occurred.
So, basically I want to include a few more data points from the columns FID_BBG2012_Clip into the newly created column "City". Could someone help a brother out?