> Date: Mon, 30 Mar 2015 09:54:39 -0400
> From: Vikram Chhatre
> To: r-help@r-project.org
> Subject: [R] changing column labels for data frames inside a list
> Message-ID:
> Content-Type: text/plain; charset="UTF-8"
>
> > summary(mygenfreqt)
> Length Class Mode
> dat1.s
Regarding the averages, someone else mentioned that it's preferred to
start a new question in a new post to the list.
That said, you are confusing "inside" the list with "outside" the list.
Try this:
(the following R expression is supposed to be all on one line, but my
email software may cause a
On 30 March 2015 at 17:50, Sarah Goslee wrote:
> On Mon, Mar 30, 2015 at 11:43 AM, Sven E. Templer
> wrote:
> >
> >
> > On 30 March 2015 at 17:31, Bert Gunter wrote:
> >>
> >> Sarah's statement is correct.
> >>
> >> So is yours. They are not contradictory, and I believe Sarah's point
> >> was t
On Mon, Mar 30, 2015 at 11:43 AM, Sven E. Templer
wrote:
>
>
> On 30 March 2015 at 17:31, Bert Gunter wrote:
>>
>> Sarah's statement is correct.
>>
>> So is yours. They are not contradictory, and I believe Sarah's point
>> was that the OP needed to learn the appropriate syntax.
>>
>
> That's why
On 30 March 2015 at 17:31, Bert Gunter wrote:
> Sarah's statement is correct.
>
> So is yours. They are not contradictory, and I believe Sarah's point
> was that the OP needed to learn the appropriate syntax.
>
>
That's why I pointed to ?return.
Sarah's statement was not so clear (and might have
On 30 March 2015 at 17:19, Vikram Chhatre wrote:
> First of all, thank you for all the quick replies. Here is a solution that
> worked for me.
>
> mylist2 <- lapply(mylist, function(e){colnames(e) <- paste0('pop',1:12);
> return(e)})
>
> > head(mylist2[[1]])
> pop1 pop2 pop3 pop4 pop
Sarah's statement is correct.
So is yours. They are not contradictory, and I believe Sarah's point
was that the OP needed to learn the appropriate syntax.
-- Bert
Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374
"Data is not information. Information is not knowledge. And knowledge
First of all, thank you for all the quick replies. Here is a solution that
worked for me.
mylist2 <- lapply(mylist, function(e){colnames(e) <- paste0('pop',1:12);
return(e)})
> head(mylist2[[1]])
pop1 pop2 pop3 pop4 pop5 pop6 pop7 pop8 pop9 pop10 pop11
pop12
L0001.1 0.60 0.500 0.
On 30 March 2015 at 16:47, Sarah Goslee wrote:
> colnames(e) <- paste0('pop',1:12)
>
> isn't a function and doesn't return anything.
>
But
function(e){colnames(e) <- paste0('pop', 1:2)}
is a function and it returns something (the last evaluated expression! -
here the paste0 return):
> mylist2 <
I am not sure it would do it since there is no reproducible example, but
try names() instead of colnames().
HTH,
Ivan
--
Ivan Calandra, ATER
University of Reims Champagne-Ardenne
GEGENAA - EA 3795
CREA - 2 esplanade Roland Garros
51100 Reims, France
+33(0)3 26 77 36 89
ivan.calan...@univ-reims.
Assuming that the elements of mylist are data frames, try this:
mylist <- lapply(mylist, function(e) { names(e) <- paste0('pop',1:12) ; e})
With certain exceptions, the result of a function is the result of the
last expression in the function body. As you defined it, the last
expression was
co
colnames(e) <- paste0('pop',1:12)
isn't a function and doesn't return anything.
> mylist <- list(
+ data.frame(a = runif(10), b = runif(10)),
+ data.frame(c = runif(10), d = runif(10)),
+ data.frame(e = runif(10), f = runif(10)))
> mylist2 <- lapply(mylist, function(e){colnames(e) <- paste0('pop'
12 matches
Mail list logo