Ista Zahn
2010-May-04 05:20 UTC
[R] Objective: to create a Joint Probability Table and save as a csv file (with headers).Input: A csv file (with headers) containing raw data, arranged by columns.Variable: number of bins for each column of data, default to 5 bins per column.Data
Hi Roscoe, I couldn't make it though that excel worksheet without my eyes glazing over... but do you want something like data(mtcars) tab <- xtabs(~cyl + gear, data=mtcars) tab/sum(tab) ? Best, Isat On Mon, May 3, 2010 at 10:08 PM, Roscoe <Roscoe at exemail.com.au> wrote:> Dear R-Help, > > First post, be gentle... > > I am new to R: I can perform basic functions using R code - import and > export data, load packages and not much else at this stage. > > Objective: to create a Joint Probability Table and save as a csv file > (with headers). > > Input: A csv file (with headers) containing raw data, arranged by > columns. > > Variable: number of bins for each column of data, default to 5 bins > per column. > > Data import and export in R I can do, however I am a complete n00b at > this type of statistical processing and I would really appreciate some > guidance please. > > I want to take the input data and create, as final output, a Joint > Probability Table. I can do this manually in Excel, however I am > hoping that there is a better and more repeatable way to do so in R. > > An example of the steps taken is available in an Excel spreadsheet at > http://parametricplanet.com/rvince/ScenariosExample.xls > > Is what I am attempting to do covered by some available function(s) or > package(s) in R? After spending a while searching the manual and the > various on-line help pages for ?Joint Probability Table ?I am > beginning to suspect that it may not be, but my lack of experience in > both stats and R could well mean that I am missing the clues. > > Thanks in advance. > > > -- > Warm regards, > ?Ross Bond ? ? ? ? ? ? ? ? ? ? ? ? ?mail to: Roscoe at Exemail.com.au > ?Bundaberg, Qld > ?Australia > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org
G'Day Ista, Tuesday, May 4, 2010, 3:20:37 PM, you wrote:> I couldn't make it though that excel worksheet without my eyes > glazing over...Heh, yeah, it is a bit long-winded. Essentially you take the input data and run it through those steps to produce the JPT at the end. Part of it is the odometric ordering of the data.> but do you want something like> data(mtcars) > tab <- xtabs(~cyl + gear, data=mtcars) > tab/sum(tab)I don't think so, at least not exactly, but if I can get my head around what that code does it might actually be doing what I want. Thanks for that, I will attempt to break the R code down into chunks that I can understand and go from there. -- Kind regards, Roscoe mail to: Roscoe at Exemail.com.au