swirldev / swirl

:cyclone: Learn R, in R.
http://swirlstats.com
Other
1.14k stars 599 forks source link

Problem with && Operator in Course 1 Unit 8 #905

Open ttenishev opened 1 year ago

ttenishev commented 1 year ago

Hello! I have a problem with this task in Course 1 (R Programming) Unit 8 (Logic):

| Now we'll type the same expression except we'll use the && operator. Type the expression | TRUE && c(TRUE, FALSE, FALSE).

TRUE && c(TRUE, FALSE, FALSE) Error in TRUE && c(TRUE, FALSE, FALSE) : 'length = 3' in coercion to 'logical(1)'

My OS is Windows 11, this is what I get from infoSession():

sessionInfo() R version 4.3.0 (2023-04-21 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 11 x64 (build 22621)

Matrix products: default

locale: [1] LC_COLLATE=Russian_Russia.utf8 LC_CTYPE=Russian_Russia.utf8
[3] LC_MONETARY=Russian_Russia.utf8 LC_NUMERIC=C
[5] LC_TIME=Russian_Russia.utf8

time zone: Europe/Berlin tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] swirl_2.4.5 rafalib_1.0.0 faraway_1.0.8 lubridate_1.9.2 forcats_1.0.0
[6] stringr_1.5.0 dplyr_1.1.2 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0
[11] tibble_3.2.1 tidyverse_2.0.0 ggplot2_3.4.2

loaded via a namespace (and not attached): [1] utf8_1.2.3 generics_0.1.3 bitops_1.0-7 stringi_1.7.12
[5] lattice_0.21-8 lme4_1.1-33 hms_1.1.3 digest_0.6.31
[9] magrittr_2.0.3 grid_4.3.0 timechange_0.2.0 RColorBrewer_1.1-3 [13] Matrix_1.5-4 brio_1.1.3 httr_1.4.5 fansi_1.0.4
[17] scales_1.2.1 cli_3.6.1 rlang_1.1.0 munsell_0.5.0
[21] splines_4.3.0 yaml_2.3.7 withr_2.5.0 tools_4.3.0
[25] tzdb_0.3.0 nloptr_2.0.3 minqa_1.2.5 colorspace_2.1-0
[29] boot_1.3-28.1 curl_5.0.0 vctrs_0.6.2 R6_2.5.1
[33] lifecycle_1.0.3 MASS_7.3-58.4 pkgconfig_2.0.3 pillar_1.9.0
[37] gtable_0.3.3 glue_1.6.2 Rcpp_1.0.10 tidyselect_1.2.0
[41] rstudioapi_0.14 nlme_3.1-162 testthat_3.1.7 compiler_4.3.0
[45] RCurl_1.98-1.12

Could you please help me fix it?

ttenishev commented 1 year ago

Trying to skip causes the same problem:

skip() Error in TRUE && c(TRUE, FALSE, FALSE) : 'length = 3' in coercion to 'logical(1)'

| Leaving swirl now. Type swirl() to resume.

datenjunkie commented 1 year ago

Same for me

Sidraamir commented 1 year ago

yup same for me .

Sidraamir commented 1 year ago

TRUE &&c(TRUE) [1] TRUE

| Not quite! Try again. Or, type info() for more options.

| As you'll see, the && version of AND works differently. Type: TRUE && c(TRUE, | FALSE, FALSE)

Sidraamir commented 1 year ago

Using vectors of more than one element in && or || will give an error.

Roi-Shir-Dishon commented 1 year ago

same for me. it also happens in course - The R Programming Environment Logic

nponeill commented 1 year ago

It looks like an update to R version 4.3.0 (2023-04-21) causes an error for && Operator in Course 8 and elsewhere.

Per CRAN R Project release News (2023-04-21),

" SIGNIFICANT USER-VISIBLE CHANGES: • Calling && or || with LHS or (if evaluated) RHS of length greater than one is now always an error, with a report of the form 'length = 4' in coercion to 'logical(1)' Environment variable _R_CHECK_LENGTH_1LOGIC2 no longer has any effect. "

mjos19 commented 1 year ago

Same Issue for me!

Roi-Shir-Dishon commented 1 year ago

It looks like an update to R version 4.3.0 (2023-04-21) causes an error for && Operator in Course 8 and elsewhere.

Per CRAN R Project release News (2023-04-21),

" SIGNIFICANT USER-VISIBLE CHANGES: • Calling && or || with LHS or (if evaluated) RHS of length greater than one is now always an error, with a report of the form 'length = 4' in coercion to 'logical(1)' Environment variable _R_CHECK_LENGTH_1LOGIC2 no longer has any effect. "

indeed - hte reason is an update to R enviroment. but the course(s) should be updated as well

nitsujh commented 1 year ago

Will this get fixed?

hudme commented 1 year ago

With a little more googling, I was able to find a work around to this problem. If you install an earlier version of R (pre version 4.3.0) the swirl Logics course is able to proceed with the && inputs.

If you are using Windows: https://cran.r-project.org/bin/windows/base/old/

I downloaded/installed R version 4.2.3 Open RStudio if you are using it, got to the "Tools" tab and select "Global Options" In the window, in the R General section, change your R version to the older version like 4.2.3 by checking "Choose version of R" and selecting an older version. Hit "OK", "Apply", and "Ok" You will then need to close and reopen RStudio to apply the changes. You might also need to install the swirl package again. Screenshot (34)