[R] I need help with this
install.packages("titanic") library(titanic) training_set <- titanic_train#Saves the train set as a variable so that we do not affect the original data testing_set <- titanic_test #Saves the test set as a variable so that we do not affect the original data names(training_set) #Prints the name of each catergory Sent from Mail for Windows [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Checking a function for undeclared variables
Thanks! Peter On Tue, Apr 5, 2022 at 6:01 PM Jeff Newmiller wrote: > > ?codetools::findGlobals > > On April 5, 2022 5:36:54 PM PDT, Peter Langfelder > wrote: > >Hi all, > > > >I'd like to check a function for undeclared global variables using > >something similar to what R CMD check does when "checking R code for > >possible problems". My search came up empty but I hope there is way to > >do it without building a package just for this purpose, isn't there? > > > >Thanks! > > > >Peter > > > >__ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > >and provide commented, minimal, self-contained, reproducible code. > > -- > Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] replacing a value
Hi Ani, It seems to work for me: a<-c(20, 20, 14.2375646029948, 19.9, 20, 20, 16.3092078677214, 20, 20, 20, 20, 20, 20, 20, 20, 14.8590932408795, 16.178935255298, 20, 20, 20, 20, 27.6404077886079, 20, 20, 20, 20, 20, 21.9857063037444, 20, 20, 20, 20) > a==20 [1] TRUE TRUE FALSE FALSE TRUE TRUE FALSE TRUE TRUE TRUE TRUE TRUE [13] TRUE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE FALSE TRUE TRUE [25] TRUE TRUE TRUE FALSE TRUE TRUE TRUE TRUE > a[a==20]<-0 > a [1] 0.0 0.0 14.23756 20.0 0.0 0.0 16.30921 0.0 [9] 0.0 0.0 0.0 0.0 0.0 0.0 0.0 14.85909 [17] 16.17894 0.0 0.0 0.0 0.0 27.64041 0.0 0.0 [25] 0.0 0.0 0.0 21.98571 0.0 0.0 0.0 0.0 Notice that it didn't make 19.99 equal to 20, but did round it up when printing the result. How do you know that it failed? Jim On Wed, Apr 6, 2022 at 12:48 PM ani jaya wrote: > > Dear R-Help, > > I try to change a specific value here by following these: > > https://www.journaldev.com/39695/replace-in-r > https://stackoverflow.com/questions/5824173/replace-a-value-in-a-data-frame-based-on-a-conditional-if-statement > https://stackoverflow.com/questions/54615462/how-to-replace-certain-values-in-a-specific-rows-and-columns-with-na-in-r > ..and many more > > however, it is not change anything. I believe it "should" be easy but > I think I am missing something. I am afraid it is my system that has a > problem but restarting r is not solve the problem. > I just want to change 20 to 0 in my data. > > > dput(a) > c(20, 20, 14.2375646029948, 19.9, 20, 20, 16.3092078677214, > 20, 20, 20, 20, 20, 20, 20, 20, 14.8590932408795, 16.178935255298, > 20, 20, 20, 20, 27.6404077886079, 20, 20, 20, 20, 20, 21.9857063037444, > 20, 20, 20, 20) > > what I did: > a[a==20]<-0 #fail > a<-replace(a,a==20,0) #fail > a[which(a==20)]<-0 #fail > > > sessionInfo() > R version 4.1.2 (2021-11-01) > Platform: x86_64-w64-mingw32/x64 (64-bit) > Running under: Windows 10 x64 (build 19043) > > Matrix products: default > > locale: > [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > system code page: 949 > > Best, > Ani > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Checking a function for undeclared variables
?codetools::findGlobals On April 5, 2022 5:36:54 PM PDT, Peter Langfelder wrote: >Hi all, > >I'd like to check a function for undeclared global variables using >something similar to what R CMD check does when "checking R code for >possible problems". My search came up empty but I hope there is way to >do it without building a package just for this purpose, isn't there? > >Thanks! > >Peter > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. -- Sent from my phone. Please excuse my brevity. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2
hi, Richard, > I get these warnings, and the package did not install: ... > 1: In install.packages("ggplot2", dependencies = TRUE) : > installation of package ‘curl’ had non-zero exit status Ivan and Kimmo have both pointed out you need the right development tools. in terms of debugging your problem -- if the development tools are installed, etc. -- then you might choose one of the packages that didn't install -- `curl` in the above case, and try > install.packages("curl") and seeing what failed *there*. and, recursing, looking for a package that doesn't depend on any other package, that can't be installed. then, try to figure out the error messages. again, in this case, things will hopefully work once you install the compiler and other development tools. cheers and good luck, Greg __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2
I use Fedora Linux. After completing install.packages("ggplot2", dependencies=TRUE) I get these warnings, and the package did not install: Warning messages: 1: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘curl’ had non-zero exit status 2: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘openssl’ had non-zero exit status 3: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘jpeg’ had non-zero exit status 4: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘RcppEigen’ had non-zero exit status 5: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘units’ had non-zero exit status 6: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘diffobj’ had non-zero exit status 7: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘httr’ had non-zero exit status 8: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘latticeExtra’ had non-zero exit status 9: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘s2’ had non-zero exit status 10: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘interp’ had non-zero exit status 11: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘rgeos’ had non-zero exit status 12: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘textshaping’ had non-zero exit status 13: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘covr’ had non-zero exit status 14: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘pillar’ had non-zero exit status 15: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘ragg’ had non-zero exit status 16: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘sf’ had non-zero exit status 17: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘tibble’ had non-zero exit status 18: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘rematch2’ had non-zero exit status 19: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘dplyr’ had non-zero exit status 20: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘ggplot2’ had non-zero exit status 21: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘viridis’ had non-zero exit status 22: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘waldo’ had non-zero exit status 23: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘Hmisc’ had non-zero exit status 24: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘testthat’ had non-zero exit status 25: In install.packages("ggplot2", dependencies = TRUE) : installation of package ‘vdiffr’ had non-zero exit status > .packages("ggplot2", dependencies=TRUE) On Mon, Apr 4, 2022 at 6:23 PM David Winsemius wrote: > > On 4/4/22 04:39, Ebert,Timothy Aaron wrote: > > install.packages("ggplot2") > > > Depending on your OS, there might be a better chance of success with > > > install.packages("ggplot2", dependencies=TRUE) > > The Linux install process doesn't need this but the binary install on > MacOS or Windows may need this to prevent the sort of error message that > was offered. > > -- > David > > > library(ggplot2) > > > > An alternative > > install.packages("tidyverse") > > library(tidyverse) > > > > The first only installs ggplot2. The alternative installs a bunch of > other stuff as well. > > > > Tim > > > > -Original Message- > > From: R-help On Behalf Of Richard Vickery > > Sent: Sunday, April 3, 2022 12:49 PM > > To: R-help@r-project.org > > Subject: [R] ggplot2 > > > > [External Email] > > > > Hi there, > > > > I am finally getting to some material I had problems with in university, > where I was introduced to R - one of those that because of time > constraints, I had challenges figuring out, particularly because I decided > long ago on using Fedora Linux. The book, "Understanding Statistics Using > R" by Andy Field et. al., says to install ggplot2 into R and the version of > R that the dnf command installs will neigher install this package nor > 'scales'. The result I get is below, and I attempted installing the > packages via the tar command, and that neither worked, and I attempted > > library("ggplot2") and R said the package was unavailable. What can I do > to move forward? > > > > Thanks, > > > > Richard > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_li