--
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77840-4352
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Ben Tupper
> Sent: Thursday,
oun...@r-project.org] On Behalf Of Ben Tupper
Sent: Thursday, April 6, 2017 11:42 AM
To: Ulrik Stervbo
Cc: R-help Mailing List
Subject: Re: [R] readr to generate tibble from a character matrix
Hi,
Thanks for this solution! Very slick!
I see what you mean about the two calls to as_tibble(). I
Hi,
Thanks for this solution! Very slick!
I see what you mean about the two calls to as_tibble(). I suppose I could do
the following, but I doubt it is a gain...
mm <- lapply(colnames(m), function(nm, m) type.convert(m[,nm], as.is = TRUE),
m=m)
names(mm) <- colnames(m)
as_tibble(mm)
# # A t
Hi Ben,
type.convert should do the trick:
m %>%
as_tibble() %>%
lapply(type.convert) %>%
as_tibble()
I am not too happy about to double 'as_tibble' but it get the job done.
HTH
Ulrik
On Thu, 6 Apr 2017 at 16:41 Ben Tupper wrote:
> Hello,
>
> I have a workflow yields a character matrix
Hello,
I have a workflow yields a character matrix that I convert to a tibble. Here is
a simple example.
library(tibble)
library(readr)
m <- matrix(c(letters[1:12], 1:4, (11:14 + 0.2)), ncol = 5)
colnames(m) <- LETTERS[1:5]
x <- as_tibble(m)
# # A tibble: 4 × 5
# A B C D
5 matches
Mail list logo