RE: [R] working with tables

From: Huntsinger, Reid <reid_huntsinger_at_merck.com>
Date: Tue 22 Mar 2005 - 09:12:10 EST


(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@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Carsten Steinhoff Sent: Monday, March 21, 2005 4:57 PM
To: r-help@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@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

R-help@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 Received on Tue Mar 22 09:17:05 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:52 EST