r - Adding a special column to an existing data frame -
this question has answer here:
- column multiple values in data.frame 1 answer
i add column containing 3 values existing data frame in loop, each time appending existing row:
existing data frame mktdata many rows this:
bidprice askprice last volume xlu 39.14 39.15 39.15 9242 and new column consists of 3 values called weights 100, 200, 300
so final data frame should be
bidprice askprice last volume weights xlu 39.14 39.15 39.15 9242 100,200,300 thank help.
you can use paste.
df$weights<-paste0(c(100,200,300),collapse=",")
Comments
Post a Comment