Regarding creating a data set in accordance with a given data format

Go To StackoverFlow.com

0

I am learning to use topicmodels package and R as well, and explored one of its example data set by using

str(testdata)

'data.frame': 3104 obs. of 5 variables:

$ Article_ID: int 41246 41257 41268 41279 41290 41302 41314 41333 41344 41355 ...

$ Date : chr "1-Jan-96" "2-Jan-96" "3-Jan-96" "4-Jan-96" ...

$ Title : chr "Nation's Smaller Jails Struggle To Cope With Surge in Inmates" "FEDERAL IMPASSE SADDLING STATES WITH INDECISION" "Long, Costly Prelude Does Little To Alter Plot of Presidential Race" "Top Leader of the Bosnian Serbs Now Under Attack From Within" ...

$ Subject : chr "Jails overwhelmed with hardened criminals" "Federal budget impasse affect on states" "Contenders for 1996 Presedential elections" "Bosnian Serb leader criticized from within" ...

$ Topic.Code: int 12 20 20 19 1 19 1 1 20 15 ...

If I want to create a data set according to the above format in R, how to do that?

2012-04-03 19:38
by user288609
Not sure I understand your question... the data set is right there. head(testdata) will show you its first few rows. If you're wanting to see its string representation, ?dput. Or you can write it out to disk with write.table - Justin 2012-04-03 20:08
@user288609: Do you now know enough about SO and R that you can either clarify your question, accept my answer, or delete your question? Thanks - flodel 2013-07-08 01:30


0

test.data is a data.frame, one of the few fundamental R objects. You should probably start here: http://cran.r-project.org/doc/manuals/R-intro.pdf.

Some functions for creating data.frames are data.frame, read.table, read.csv. For each of these you can access their documentation by typing ?data.frame for example. Good luck.

2012-04-03 22:50
by flodel
Ads