[R] as.data.frame doesn't set col.names

David L Carlson
Tue, 24 Oct 2017 20:45:23 -0000

You left out all the most important bits of information. What is yo? Are you
trying to assign a data frame to a single column in another data frame? Printing
head(samples) tells us nothing about what data types you have, especially if the
things that look like text are really factors that were created when you used
one of the read.*() functions. Use str(samples) to see what you are dealing
with.

----------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77843-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ed Siefker
Sent: Tuesday, October 24, 2017 1:00 PM
To: r-help <r-help at r-project.org>
Subject: Re: [R] as.data.frame doesn't set col.names

Wait.  Now I'm really confused.

>
> head(samples)
                          quant_samples   age sapply(yo, toupper)
E11.5 F20het BA40     E11.5 F20het BA40 E11.5              F20HET
E11.5 F20het BA45     E11.5 F20het BA45 E11.5              F20HET
E11.5 F20het BB84     E11.5 F20het BB84 E11.5              F20HET
E11.5 F9.20DKO KTr3 E11.5 F9.20DKO KTr3 E11.5            F9.20DKO
E11.5 F9.20DKO PEd2 E11.5 F9.20DKO PEd2 E11.5            F9.20DKO
E11.5 F9.20DKO j0J1 E11.5 F9.20DKO j0J1 E11.5
F9.20DKO
> colnames(samples)
[1] "quant_samples" "age"           "geno"

Really, really confused.

On Tue, Oct 24, 2017 at 12:58 PM, Ed Siefker <ebs15242 at gmail.com>
wrote:
> Why doesn't this work?
>
>> samples$geno <- as.data.frame(sapply(yo, toupper),
col.names="geno")
>> samples
>                           quant_samples   age sapply(yo, toupper)
> E11.5 F20het BA40     E11.5 F20het BA40 E11.5              F20HET
> E11.5 F20het BA45     E11.5 F20het BA45 E11.5              F20HET

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.