From 89540f03e8c051d47443062b63c4c723aae3d9f3 Mon Sep 17 00:00:00 2001 From: Graeme Grimes Date: Wed, 20 Sep 2023 15:21:16 +0100 Subject: [PATCH] Update 03-basics-factors-dataframes.Rmd If using R > 4.0 the sample_id will be a character so using the as.numeric will show NAs, using factor_snps vectopr for example instead --- episodes/03-basics-factors-dataframes.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/episodes/03-basics-factors-dataframes.Rmd b/episodes/03-basics-factors-dataframes.Rmd index e1d77763..3d89f6b6 100644 --- a/episodes/03-basics-factors-dataframes.Rmd +++ b/episodes/03-basics-factors-dataframes.Rmd @@ -618,11 +618,11 @@ snp_chromosomes_2 ``` Trouble can really start when we try to coerce a factor. For example, when we -try to coerce the `sample_id` column in our data frame into a numeric mode +try to coerce the `factor_snps` vector into a numeric mode look at the result: ```{r, purl=FALSE} -as.numeric(variants$sample_id) +as.numeric(factor_snps) ``` Strangely, it works! Almost. Instead of giving an error message, R returns