Have the following function that is called by the statement below. Trying to return the two dataframes, but instead get one large list including both tables. ReadInputDataFrames <- function() { dbs.this= read.delim("this.txt", header = TRUE, sep = "\t", quote="\"", dec=".") dbs.that= read.delim("that.txt", header = TRUE, sep = "\t", quote="\"", dec=".") c(this= dbs.this,patdb = dbs.that) } Called by: c <- ReadInputDataFrames() Results: str(c) yields a list of 106 items $this.variabe1..53, $that$variable1..53 -- View this message in context: http://r.789695.n4.nabble.com/Question-about-user-define-function-tp2256513p2256513.html Sent from the R help mailing list archive at Nabble.com.
On Jun 15, 2010, at 4:39 PM, GL wrote:> > Have the following function that is called by the statement below. > Trying to > return the two dataframes, but instead get one large list including > both > tables. > > ReadInputDataFrames <- function() { > > dbs.this= read.delim("this.txt", header = TRUE, sep = "\t", > quote="\"", > dec=".") > dbs.that= read.delim("that.txt", header = TRUE, sep = "\t", > quote="\"", > dec=".")## Possible that you want to cbind() them rather than c() them> cbind(this= dbs.this,patdb = dbs.that) > > }Which would require that they have the same number of columns and possibly that the column names match up. ?cbind> > Called by: > > c <- ReadInputDataFrames() > > Results: > > str(c) yields a list of 106 items $this.variabe1..53, $that > $variable1..53 >David Winsemius, MD West Hartford, CT
On 15/06/10 21:39, GL wrote:> Have the following function that is called by the statement below. Trying to > return the two dataframes, but instead get one large list including both > tables. > > ReadInputDataFrames<- function() { > > dbs.this= read.delim("this.txt", header = TRUE, sep = "\t", quote="\"", > dec=".") > dbs.that= read.delim("that.txt", header = TRUE, sep = "\t", quote="\"", > dec=".") > c(this= dbs.this,patdb = dbs.that) > >If you really want to return "two dataframes", then return(list(this = dbs.this, that = dbs.that)) More likely, you want to return all the data in one dataframe. If they have the same structure (columns and column names) then you want return(rbind(dbs.this, dbs,that)) If you want something else, provide an example. Hope this helps a little. Allan