s-news
[Top] [All Lists]

Building Data Frames row by row

To: S-News <s-news@wubios.wustl.edu>
Subject: Building Data Frames row by row
From: "Kim Elmore" <Kim.Elmore@noaa.gov>
Date: Thu, 20 Jan 2005 11:23:04 -0600
I want to build a data frame, row by row, by plugging in a list for each row. The first element of the list is a character string, the next two are numeric, and the last is logical. If I just naively say something like

my.df <- data.frame(Name = character(94), value1=numeric(94), value2=numeric(94), value3=logical(94))
my.df[1,] <- my.output.list

I get a warning about what I'm putting into the first column, as that will default to a factor. So, I set stringsAsFactors=F, and tried again. This time, I simply get a 1 in column 1, not the string I wanted. The other columns look fine. Obviously, I'd like to do this all at once with a simple assignment.

What else should I try?

Kim Elmore
                          Kim Elmore, Ph.D.
                       University of Oklahoma
        Cooperative Institute for Mesoscale Meteorological Studies
"All of weather is divided into three parts: Yes, No, and Maybe. The
greatest of these is Maybe" The original Latin appears to be garbled.


<Prev in Thread] Current Thread [Next in Thread>