From fbdc0115e9d53cf1b57f0bacd85094402b5af608 Mon Sep 17 00:00:00 2001 From: Marcel Ribeiro Dantas Date: Sat, 9 Apr 2022 00:14:18 +0200 Subject: Update return of class(mat) according to R 4.0.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A matrix is the special case of a two-dimensional ‘array’. Since R 4.0.0, ‘inherits(m, "array")’ is true for a ‘matrix’ ‘m’, which makes class(mat) return "matrix" "array", not only "matrix" as before. --- r.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'r.html.markdown') diff --git a/r.html.markdown b/r.html.markdown index e90d5a97..c3422d2d 100644 --- a/r.html.markdown +++ b/r.html.markdown @@ -405,7 +405,7 @@ mat # [2,] 2 5 # [3,] 3 6 # Unlike a vector, the class of a matrix is "matrix", no matter what's in it -class(mat) # => "matrix" +class(mat) # => "matrix" "array" # Ask for the first row mat[1,] # 1 4 # Perform operation on the first column -- cgit v1.2.3 From c4c53cc95eeb792e25e04871ca7d7b13b11193e9 Mon Sep 17 00:00:00 2001 From: Marcel Ribeiro Dantas Date: Sat, 9 Apr 2022 00:21:01 +0200 Subject: Fix warning about stringsAsFactors In R 4.0.0, stringsAsFactors default value changed from TRUE to FALSE. This commit fixes the warning message in the current file to make this clear for readers. This commit also updates the list of contributors for this file. --- r.html.markdown | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'r.html.markdown') diff --git a/r.html.markdown b/r.html.markdown index c3422d2d..e42b1f5e 100644 --- a/r.html.markdown +++ b/r.html.markdown @@ -4,6 +4,7 @@ contributors: - ["e99n09", "http://github.com/e99n09"] - ["isomorphismes", "http://twitter.com/isomorphisms"] - ["kalinn", "http://github.com/kalinn"] + - ["mribeirodantas", "http://github.com/mribeirodantas"] filename: learnr.r --- @@ -478,9 +479,10 @@ class(students[,3]) # "factor" nrow(students) # 6 ncol(students) # 3 dim(students) # 6 3 -# The data.frame() function converts character vectors to factor vectors -# by default; turn this off by setting stringsAsFactors = FALSE when -# you create the data.frame +# The data.frame() function used to convert character vectors to factor +# vectors by default; This has changed in R 4.0.0. If your R version is +# older, turn this off by setting stringsAsFactors = FALSE when you +# create the data.frame ?data.frame # There are many twisty ways to subset data frames, all subtly unalike -- cgit v1.2.3