s-news
[Top] [All Lists]

Re : Loop with data frames names

To: Tristan Lorino <tristan.lorino@lcpc.fr>
Subject: Re : Loop with data frames names
From: Tristan Lorino <tristan.lorino@lcpc.fr>
Date: Thu, 19 Apr 2007 13:52:09 +0200
Cc: S-News <s-news@lists.biostat.wustl.edu>
In-reply-to: <17510580418.20070419105706@lcpc.fr>
Organization: LCPC
References: <17510580418.20070419105706@lcpc.fr>
Reply-to: Tristan Lorino <tristan.lorino@lcpc.fr>
Thank you to Patrick Burns and "PKuabel"... here is the solution.

********************************************
dfs.name <- as.character(u) # u <- outer(x, y, paste, sep="")

myfun <- function(x)
{
    d.f <- get(x)
    d.f$col3 <- ifelse(d.f$col2  < 1, 1, ifelse(d.f$col2  < 5, 2 ,3))     # 
maybe you could use the function cut()
    assign(x, d.f)
}

sapply(dfs.name, myfun(x) )

Or, if and only if ls() give the 16 data frames in the search, and then

objs <- ls()     # or objects()

sapply(objs, myfun)
********************************************

Tristan Lorino



-- 
Laboratoire Central des Ponts et Chaussées
[Division ESAR ? Section AGR]
Route de Bouaye BP 4129
44341 Bouguenais Cedex
France
Tél. 33 (0)2 40 84 56 18


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