@stey@ m@iii@g oii m@th@m@ps@com
2019-Jul-02 00:13 UTC
[R] read.xls without row number, column numbers, or factors
Is there a way to use read.xls to copy a portion of a single row of an XLS spreadsheet to a list, without getting assigning row and column numbers, and, if the data consists of strings, without assigning levels? Or alternatively, to take the single-row data frame generated by read.xls and convert it to a list, without row numbers, column numbers, or levels. Right now I'm using version 3.2.3, on Linux Mint 18. Can certainly upgrade if this would be desirable. thanks for any assistance George H
Ivan Krylov
2019-Jul-02 14:34 UTC
[R] read.xls without row number, column numbers, or factors
On Mon, 01 Jul 2019 20:13:34 -0400 asteya at mathnmaps.com wrote:> Is there a way to use read.xls to copy a portion of a single row of > an XLS spreadsheet to a list, without getting assigning row and > column numbers, and, if the data consists of strings, without > assigning levels?If you mean the read.xls function from gdata package, it uses read.csv to read the temporary CSV file produced from the XLS file and passes its arguments using ..., so it should be possible to pass as.is = TRUE and prevent factors from appearing. It doesn't seem to be possible to prevent row and column names from being produced (except passing header = F if your CSV doesn't have a header). The readxl[*] package offers somewhat saner defaults, so you might want to try that, too. -- Best regards, Ivan [*] https://readxl.tidyverse.org/
David Carlson
2019-Jul-02 15:18 UTC
[R] read.xls without row number, column numbers, or factors
Converting a one-row data frame to a list is not difficult, but there are several ways to represent the data as a list. Here is a possibility:> dta <- data.frame(t(LETTERS[1:10]), stringsAsFactors=FALSE) > dtaX1 X2 X3 X4 X5 X6 X7 X8 X9 X10 1 A B C D E F G H I J> dta.lst <- as.list(unname(dta)) > str(dta.lst)List of 10 $ : chr "A" $ : chr "B" $ : chr "C" $ : chr "D" $ : chr "E" $ : chr "F" $ : chr "G" $ : chr "H" $ : chr "I" $ : chr "J" -------------------------------- David L Carlson Anthropology Department Texas A&M University On Tue, Jul 2, 2019 at 9:34 AM Ivan Krylov <krylov.r00t at gmail.com> wrote:> > On Mon, 01 Jul 2019 20:13:34 -0400 > asteya at mathnmaps.com wrote: > > > Is there a way to use read.xls to copy a portion of a single row of > > an XLS spreadsheet to a list, without getting assigning row and > > column numbers, and, if the data consists of strings, without > > assigning levels? > > If you mean the read.xls function from gdata package, it uses read.csv > to read the temporary CSV file produced from the XLS file and passes its > arguments using ..., so it should be possible to pass as.is = TRUE and > prevent factors from appearing. > > It doesn't seem to be possible to prevent row and column names from > being produced (except passing header = F if your CSV doesn't have a > header). > > The readxl[*] package offers somewhat saner defaults, so you might want > to try that, too. > > -- > Best regards, > Ivan > > [*] https://urldefense.proofpoint.com/v2/url?u=https-3A__readxl.tidyverse.org_&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcfIrXdkDpHnJBBZ9Q1u5LcXz9s&m=s6RiIjcvAhy9p3vCQ3IDY_pMKDIbJiJ19N3qoaMBdbo&s=wksjPQ0xfh5OAk0mgysq2vQ14kBIKPHysHxS9HLBvhQ&e> > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcfIrXdkDpHnJBBZ9Q1u5LcXz9s&m=s6RiIjcvAhy9p3vCQ3IDY_pMKDIbJiJ19N3qoaMBdbo&s=lnFWD1ZhtIQG1olqJnp7SIngLVTRqXOJujo2Flejesw&e> PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=u6LDEWzohnDQ01ySGnxMzg&r=VAaHUElasUXjP9TzIcfIrXdkDpHnJBBZ9Q1u5LcXz9s&m=s6RiIjcvAhy9p3vCQ3IDY_pMKDIbJiJ19N3qoaMBdbo&s=FMnhiFANOvftI6jg5OxVSP4w3bKgFR1t9X5JMmgQrqc&e> and provide commented, minimal, self-contained, reproducible code.