[Solved] R: Remove list type within dataframe


Try to do this

library('stringr')
apply(data, 1, function(x) str_c(x$columnnane,collapse=","))

where, data is you dataframe and columnname is the column containing list.


edited answer

out = do.call(rbind, lapply(data, function(x) str_c(x,collapse=", ")))

where data is your list object

if the list is stored inside a dataframe then pass the column in place of the data above like this

out = do.call(rbind, lapply(data$columnname, function(x) str_c(x,collapse=", ")))

it will give you this. I hope this is what you are looking for!

out
[,1]
[1,] “qlikview, gpa, access, gpa, access, access, qlikview, gpa, access, gpa”
[2,] “report, qlikview, gpa, access, qlikview, gpa, access, qlikview, gpa, access”
[3,] “qlikview, gpa, access, gpa, access, access, qlikview, gpa, access, gpa”
[4,] “qlikview, gpa, access, gpa, access, access, qlikview, gpa, access, gpa”
[5,] “report, qlikview, gpa, access, access, gpa, access, qlikview, gpa, access, access, gpa, qlikview, gpa, access, qlikview, gpa, access”
[6,] “report, qlikview, access, access, report, qlikview, access, access, gpa, qlikview, access, access, qlikview, access, access”
[7,] “report, report, access, access, report, report, report, report, report, report, data, data, report, access, report, report”
[8,] “report, qlikview, gpa, access, gpa, access”
[9,] “report, gpa, access, access, gpa, gpa, gpa, gpa, gpa, access, gpa, gpa, gpa, report”
[10,] “report, gpa, gpa, access, gpa, access, gpa, access, gpa, gpa, report, gpa, gpa, access, gpa, gpa, gpa, gpa, gpa”

7

solved R: Remove list type within dataframe