Here are a few other options for you.
Fruit<-c("Banana", "Apple", "Banana", "Orange", "Appel")
Origin<-c("New Guinea", "China","Germany", "USA", "Germany")
Quality<-c("Good", "Bad", "Good", "Very bad", "Decent")
Price<-c(1,2,1,3,2)
Fruits<-data.frame(Fruit, Origin, Quality, Price)
Using base R
Fruits$xyz <- with(Fruits, paste(Fruit, Origin, Quality, sep = ", "))
Fruits[, c("xyz", "Price")]
xyz Price
1 Banana, New Guinea, Good 1
2 Apple, China, Bad 2
3 Banana, Germany, Good 1
4 Orange, USA, Very bad 3
5 Appel, Germany, Decent 2
Using dplyr
library(dplyr)
Fruits %>%
mutate(xyz = paste(Fruit, Origin, Quality, sep = ", ")) %>%
select(xyz, Price)
xyz Price
1 Banana, New Guinea, Good 1
2 Apple, China, Bad 2
3 Banana, Germany, Good 1
4 Orange, USA, Very bad 3
5 Appel, Germany, Decent 2