RE: [R] working with tables

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

(1) Define a dataframe or matrix to hold the whole table, then assign rows

$ result[i,] <- newLine

Perhaps you can even vectorize the calculation to eliminate the loop...

(2) "as.vector" will strip off the names: mean_a <-

Reid Huntsinger

-----Original Message-----
[] On Behalf Of Carsten Steinhoff Sent: Monday, March 21, 2005 4:57 PM
Subject: [R] working with tables


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


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 mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! 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