[R] function using values separated by a comma
burgundy
sauburn at yahoo.com
Mon Oct 18 08:37:54 CEST 2010
Hi,
Thanks again for your help with this. I would like to use a variation of
this function in a similar dataset (numeric) with elements separated by a
comma e.g.
dat <- read.table(tc <- textConnection(
'0,1 1,3 40,10 0,0
20,5 4,2 10,40 10,0
0,11 1,2 120,10 0,0'), sep="")
to simply calculate the frequency of the first number divided by the total
number, i.e. x[1]/sum(x).
to produce:
[,1] [,2] [,3] [,4]
[1,] 0 0.25 0.8 NaN
[2,] 0.8 0.33 0.2 1
[3,] 0 0.33 0.92 NaN
My actual dataset is an enormous file (800,000 rows and 100 columns). Any
advice on how I can do this, maybe using gsubfn?
Thank you very much!
--
View this message in context: http://r.789695.n4.nabble.com/function-using-values-separated-by-a-comma-tp2967870p2999723.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list