I have a CSV file where I want to write data to another CSV file based on the functions that I perform, for example
data.csv
Identity,State,City,BusinessName,BusinessNeed
12,California,Los Angeles,Ray brothers,IT
34,texas,Dallas,abc,TV
45,washington,seattle,Microsft,Software
My expected output is similar to
BusinessId,Campaignname
12,geo|California|Los Angeles
12,cat|Ray brothers,IT
34,geo|texas|Dallas
34,cat|abc|TV
45,geo|washington|seattle
45,cat|Microsoft|Software
How do I format the output the way I want?
My code looks like
newlistings <- read.csv("Data.csv",header=TRUE)
Identity <- newlistings$Identity
campaignname <- paste("geo","|",(tolower(as.character(newlistings$state))),"|",(tolower(as.character(newlistings$Market))),sep="")
... again, this should be the name of the campaign
campaignname <- paste("cat","|",(tolower(as.character(newlistings$BusinessName))),"|",(tolower(as.character(newlistings$BusinessNeed))),sep="")
I want to achieve this without using a loop. new to R. any help is appreciated.