[R] working with tables
Huntsinger, Reid
reid_huntsinger at merck.com
Mon Mar 21 23:12:10 CET 2005
(1) Define a dataframe or matrix to hold the whole table, then assign rows
like
$ result[i,] <- newLine
Perhaps you can even vectorize the calculation to eliminate the loop...
(2) "as.vector" will strip off the names: mean_a <-
as.vector(result$estimate[1]).
Reid Huntsinger
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Carsten Steinhoff
Sent: Monday, March 21, 2005 4:57 PM
To: r-help at stat.math.ethz.ch
Subject: [R] working with tables
Hi,
two questions - I think simple to solve for you ...
(1) I've written a function containing some loops.
Each loop will generate a few outputs. Finally I have to combine them to get
something like a "spreadsheet" that my colleagues can import in EXCEL.
Up to now I'm doing it as follows:
With each loop-step I assign new values for each "column" of my desired
output like
colum_A=c(column_A,new_value)
At the end I combine all columns: my_table=cbind(column_A,column_B ... )
I think there should be another easier way to assign the new lines directly,
isn't it?
(2) I often have to use the "fitdistr" function included in library MASS.
The generated output for e.g. $estimate has the following format:
mean sd
0.01664940 0.97682797
Now I want to write ONLY THE VALUE in a new variable. By doing
mean_a = ...$estimate[1]
I always have the string "mean" IN the variable. How can I eliminate this?
Thanks a lot for your answer !
Carsten
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list