How to convert a text mining termDocumentMatrix into excel or csv in R?

0 votes

To have more clarity on the Question take an example I have character vector "exmp"

exmp[1]<-"Josh, Ron, Sam"

exmp[2]<-"Alice, Joshua, Pam, Bob, Darren"

I don't know how to do it.

Thank you in Advance.

Apr 5, 2018 in Data Analytics by DataKing99
• 8,100 points
66 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

By assuming that all the values are separated by commas

#max number of elements

max_m<-max(unlist(lapply(strsplit(exmp,","),length)))

#all rows should have same length

lapply(strsplit(Names,','),function(x) {length(x) <- max_m;x})

#Create a data Frame

ras <- do.call(rbind,lapply(strsplit(Names,','),function(x) {length(x) <- max_m;x}))

#save the file

write.csv(ras,'output.csv')
answered Apr 5, 2018 by DeepCoder786
• 1,700 points

Related Questions In Data Analytics

+1 vote
2 answers
0 votes
1 answer
0 votes
1 answer

How to convert JSON into CSV in R programming?

Use the jsonlite::fromJSON to read the data into ...READ MORE

answered Jan 24 in Data Analytics by Sophie may
• 9,250 points
125 views
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

answered Apr 12, 2018 in Data Analytics by nirvana
• 3,060 points

edited Apr 12, 2018 by nirvana 1,493 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
36 views
0 votes
1 answer

How to spilt a column of a data frame into multiple columns

it is easily achievable by using "stringr" ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
29 views
0 votes
1 answer

How to sort a data frame by columns in R?

You can just use the order function ...READ MORE

answered Apr 10, 2018 in Data Analytics by darklord
• 6,140 points
60 views
0 votes
1 answer

How to replace NA values in a dataframe with Zero's ?

It is simple and easy: df1<-as.data.frame(matrix(sample(c(NA, 1:10), 100, ...READ MORE

answered Apr 10, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
75 views
0 votes
2 answers

How to write lines to a text file in R?

sink("outfile.txt") cat("hello") cat("\n" ...READ MORE

answered May 24 in Data Analytics by anonymous
783 views
0 votes
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,700 points
38 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.