-1

I want to split data on various factor like below

my data : "vs=1;am=0" fetched from one column from excel file

I want an output as below:

vs  am
1   0

I have tried:

s <- unlist(strsplit(Condition, split = ";"))
s <- strsplit(s, split = "=")
data<- data.frame(Condition = unlist(s))

but its getting all data in one column like below:

vs
1
am
0

Please help in splitting this into required structure(dataframe)

Robert
  • 5,038
  • 1
  • 25
  • 43

1 Answers1

0

Try this:

data<- data.frame(t(do.call("rbind",s)))
colnames(data)=data[1,]
data <- data[-1,]
Robert
  • 5,038
  • 1
  • 25
  • 43