Re: [R] [External] openxlsx::read.xlsx can't read data without a header
?openxlsx::read.xlsx The fourth argument by default is TRUE colNames: If ‘TRUE’, the first row of data will be used as column names. You will need to specify it explicitly as colNames=FALSE The other arguments will probably also be useful to you. On Thu, Oct 22, 2020 at 11:56 PM John wrote: > > Hi, > >I try to read 6 rows (from 5th to 10th) from Excel, but I can always get > 5. The first row of the 6 becomes the header. How can I add something like > "header = FALSE" in the formula, so that the resulting data would be all > the 6 rows? A similar problem occurs in readxl::read_xlsx. Thank you! > > > temp <- openxlsx::read.xlsx(fl_trilem_sgko, sheet="Korea", rows=5:10, > cols=25,skipEmptyRows = FALSE, na.strings = "NA") > > temp > 0.12101775061124695 > 1 0.09613981 > 2 0.16259886 > 3 0.07914472 > 4 0.10195485 > 5 0.07700853 > > nrow(temp) > [1] 5 > > > John > > [[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. __ 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] openxlsx::read.xlsx can't read data without a header
Hi, I try to read 6 rows (from 5th to 10th) from Excel, but I can always get 5. The first row of the 6 becomes the header. How can I add something like "header = FALSE" in the formula, so that the resulting data would be all the 6 rows? A similar problem occurs in readxl::read_xlsx. Thank you! > temp <- openxlsx::read.xlsx(fl_trilem_sgko, sheet="Korea", rows=5:10, cols=25,skipEmptyRows = FALSE, na.strings = "NA") > temp 0.12101775061124695 1 0.09613981 2 0.16259886 3 0.07914472 4 0.10195485 5 0.07700853 > nrow(temp) [1] 5 John [[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] vanilla session in R Gui or RStudio
This can happens if save an object with an environment part of a package, e.g. $ R --quiet --vanilla > fcn <- Matrix::Matrix > environment(fcn) > quit("yes") # saves the workspace in an .RData file # Loading the .RData file at startup triggers 'Matrix' to be loaded $ R --quiet --no-init-file -e "loadedNamespaces()" > loadedNamespaces() [1] "compiler" "Matrix""graphics" "utils" "grDevices" "stats" [7] "datasets" "grid" "methods" "base" "lattice" > > Also, if you have saved S4 objects (e.g. x <- Matrix::Matrix(0, 3, 2)), they will trigger their corresponding packages to be loaded when "used" (e.g. print():ed) but not before. Not saying it explains all of OPs packages - just wanted to say the content of .RData may trigger packages being loaded. /Henrik On Thu, Oct 22, 2020 at 7:54 PM Jeff Newmiller wrote: > > Can you be more specific about what conditions cause R to automatically load > a package when a .RData file is loaded? My experience has actually been the > opposite. > > On October 22, 2020 6:13:11 PM PDT, Henrik Bengtsson > wrote: > >As Jeff says, it might be that you have a ~/.Rprofile file with > >instructions to load packages when R starts. It could also be that > >you have a .RData file, which is saved if you answer yes to: > > > >> Save workspace image? [y/n/c]: y > > > >when you quit R. If this file exists, then R loads it and all the > >objects you had when you saved it. If there are objects associated > >with packages, then that will cause those packages to be loaded when R > >starts. To avoid this, you need to move or delete the .RData file. > > > >You can use: > > > >> startup::startup(debug = TRUE, dryrun = TRUE) > > > >to get detailed information on what happens when R starts, e.g. if you > >have a .Rprofile file and an .RData file. That might help you to > >track down what's going on. The 'startup' package is on CRAN. > > > >I don't know of an easy way to restart RGui or RStudio Console in > >vanilla mode, similarly how you can start R at the terminal with 'R > >--vanilla'. > > > >/Henrik > > > >On Thu, Oct 22, 2020 at 4:14 PM Jeff Newmiller > > wrote: > >> > >> Have you looked into your .Rprofile file? Loading packages is not > >something R normally does without your telling it to do so, but many > >people forget that they have done so. > >> > >> On October 22, 2020 3:47:04 PM PDT, Michael L Friendly > > wrote: > >> >[env: Windows, R 3.6.6] > >> > > >> >When I start R from the R Gui icon or from RStudio, I get a large > >> >number of packages loaded via a namespace. Not entirely clear where > >> >these come from. > >> > > >> >As a result, I often run into problems updating packages because > >> >something is already loaded. How can start a new gui session with > >> >minimal packages loaded? > >> > > >> >> sessionInfo() > >> >R version 3.6.3 (2020-02-29) > >> >Platform: x86_64-w64-mingw32/x64 (64-bit) > >> >Running under: Windows 7 x64 (build 7601) Service Pack 1 > >> > > >> >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 > >> > > >> >attached base packages: > >> >[1] stats graphics grDevices utils datasets methods base > >> > > >> > > >> >loaded via a namespace (and not attached): > >> >[1] statmod_1.4.34 xfun_0.18tidyselect_1.1.0 > >reshape2_1.4.4 > >> >purrr_0.3.4 mitools_2.4 > >> >[7] splines_3.6.3lattice_0.20-41 coefplot_1.2.6 carData_3.0-4 > >> >colorspace_1.4-1 vctrs_0.3.4 > >> >[13] generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 > >survival_3.2-7 > >> > rlang_0.4.7 pillar_1.4.6 > >> >[19] nloptr_1.2.2.2 glue_1.4.2 DBI_1.1.0 > >lifecycle_0.2.0 > >> > plyr_1.8.6 stringr_1.4.0 > >> >[25] effects_4.2-0munsell_0.5.0gtable_0.3.0 > >evaluate_0.14 > >> > knitr_1.30 fansi_0.4.1 > >> >[31] Rcpp_1.0.5 scales_1.1.1 useful_1.2.6 fs_1.4.2 > >> > lme4_1.1-23 packrat_0.5.0 > >> >[37] ggplot2_3.3.2digest_0.6.25stringi_1.4.6 > >insight_0.9.6 > >> > dplyr_1.0.2 survey_4.0 > >> >[43] grid_3.6.3 cli_2.1.0tools_3.6.3 magrittr_1.5 > >> > tibble_3.0.4 crayon_1.3.4 > >> >[49] pkgconfig_2.0.3 ellipsis_0.3.1 MASS_7.3-53 > >Matrix_1.2-18 > >> > reprex_0.3.0 assertthat_0.2.1 > >> >[55] minqa_1.2.4 rmarkdown_2.4rstudioapi_0.11 R6_2.4.1 > >> > boot_1.3-25 nnet_7.3-14 > >> >[61] nlme_3.1-149 compiler_3.6.3 > >> >> > >> > > >> >Michael Friendly Email: friendly AT yorku DOT ca > >> >Professor, Psychology Dept. & Former Chair, ASA Statistical Graphics > >> >Section > >> >York University Voice: 416 736-2100 x66249 > >> >4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly > >> >Toronto, ONT M3J 1P3 CANADA > >> > > >> >__ > >> >R-help@r-project.org mailing list
Re: [R] vanilla session in R Gui or RStudio
Can you be more specific about what conditions cause R to automatically load a package when a .RData file is loaded? My experience has actually been the opposite. On October 22, 2020 6:13:11 PM PDT, Henrik Bengtsson wrote: >As Jeff says, it might be that you have a ~/.Rprofile file with >instructions to load packages when R starts. It could also be that >you have a .RData file, which is saved if you answer yes to: > >> Save workspace image? [y/n/c]: y > >when you quit R. If this file exists, then R loads it and all the >objects you had when you saved it. If there are objects associated >with packages, then that will cause those packages to be loaded when R >starts. To avoid this, you need to move or delete the .RData file. > >You can use: > >> startup::startup(debug = TRUE, dryrun = TRUE) > >to get detailed information on what happens when R starts, e.g. if you >have a .Rprofile file and an .RData file. That might help you to >track down what's going on. The 'startup' package is on CRAN. > >I don't know of an easy way to restart RGui or RStudio Console in >vanilla mode, similarly how you can start R at the terminal with 'R >--vanilla'. > >/Henrik > >On Thu, Oct 22, 2020 at 4:14 PM Jeff Newmiller > wrote: >> >> Have you looked into your .Rprofile file? Loading packages is not >something R normally does without your telling it to do so, but many >people forget that they have done so. >> >> On October 22, 2020 3:47:04 PM PDT, Michael L Friendly > wrote: >> >[env: Windows, R 3.6.6] >> > >> >When I start R from the R Gui icon or from RStudio, I get a large >> >number of packages loaded via a namespace. Not entirely clear where >> >these come from. >> > >> >As a result, I often run into problems updating packages because >> >something is already loaded. How can start a new gui session with >> >minimal packages loaded? >> > >> >> sessionInfo() >> >R version 3.6.3 (2020-02-29) >> >Platform: x86_64-w64-mingw32/x64 (64-bit) >> >Running under: Windows 7 x64 (build 7601) Service Pack 1 >> > >> >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 >> > >> >attached base packages: >> >[1] stats graphics grDevices utils datasets methods base >> > >> > >> >loaded via a namespace (and not attached): >> >[1] statmod_1.4.34 xfun_0.18tidyselect_1.1.0 >reshape2_1.4.4 >> >purrr_0.3.4 mitools_2.4 >> >[7] splines_3.6.3lattice_0.20-41 coefplot_1.2.6 carData_3.0-4 >> >colorspace_1.4-1 vctrs_0.3.4 >> >[13] generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 >survival_3.2-7 >> > rlang_0.4.7 pillar_1.4.6 >> >[19] nloptr_1.2.2.2 glue_1.4.2 DBI_1.1.0 >lifecycle_0.2.0 >> > plyr_1.8.6 stringr_1.4.0 >> >[25] effects_4.2-0munsell_0.5.0gtable_0.3.0 >evaluate_0.14 >> > knitr_1.30 fansi_0.4.1 >> >[31] Rcpp_1.0.5 scales_1.1.1 useful_1.2.6 fs_1.4.2 >> > lme4_1.1-23 packrat_0.5.0 >> >[37] ggplot2_3.3.2digest_0.6.25stringi_1.4.6 >insight_0.9.6 >> > dplyr_1.0.2 survey_4.0 >> >[43] grid_3.6.3 cli_2.1.0tools_3.6.3 magrittr_1.5 >> > tibble_3.0.4 crayon_1.3.4 >> >[49] pkgconfig_2.0.3 ellipsis_0.3.1 MASS_7.3-53 >Matrix_1.2-18 >> > reprex_0.3.0 assertthat_0.2.1 >> >[55] minqa_1.2.4 rmarkdown_2.4rstudioapi_0.11 R6_2.4.1 >> > boot_1.3-25 nnet_7.3-14 >> >[61] nlme_3.1-149 compiler_3.6.3 >> >> >> > >> >Michael Friendly Email: friendly AT yorku DOT ca >> >Professor, Psychology Dept. & Former Chair, ASA Statistical Graphics >> >Section >> >York University Voice: 416 736-2100 x66249 >> >4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly >> >Toronto, ONT M3J 1P3 CANADA >> > >> >__ >> >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. -- 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] vanilla session in R Gui or RStudio
On Thu, 22 Oct 2020 18:13:11 -0700 Henrik Bengtsson wrote: > As Jeff says, it might be that you have a ~/.Rprofile file with > instructions to load packages when R starts. It could also be that > you have a .RData file, which is saved if you answer yes to: > > > Save workspace image? [y/n/c]: y > > when you quit R. If this file exists, then R loads it and all the > objects you had when you saved it. If there are objects associated > with packages, then that will cause those packages to be loaded when R > starts. I don't believe that the forgoing is *exactly* correct. Perhaps it depends on what is meant by "objects associated with packages". I have vague recollections that funny things can happen if objects in the saved .RData file have complicated environments, but I can't remember details. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 __ 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] vanilla session in R Gui or RStudio
As Jeff says, it might be that you have a ~/.Rprofile file with instructions to load packages when R starts. It could also be that you have a .RData file, which is saved if you answer yes to: > Save workspace image? [y/n/c]: y when you quit R. If this file exists, then R loads it and all the objects you had when you saved it. If there are objects associated with packages, then that will cause those packages to be loaded when R starts. To avoid this, you need to move or delete the .RData file. You can use: > startup::startup(debug = TRUE, dryrun = TRUE) to get detailed information on what happens when R starts, e.g. if you have a .Rprofile file and an .RData file. That might help you to track down what's going on. The 'startup' package is on CRAN. I don't know of an easy way to restart RGui or RStudio Console in vanilla mode, similarly how you can start R at the terminal with 'R --vanilla'. /Henrik On Thu, Oct 22, 2020 at 4:14 PM Jeff Newmiller wrote: > > Have you looked into your .Rprofile file? Loading packages is not something R > normally does without your telling it to do so, but many people forget that > they have done so. > > On October 22, 2020 3:47:04 PM PDT, Michael L Friendly > wrote: > >[env: Windows, R 3.6.6] > > > >When I start R from the R Gui icon or from RStudio, I get a large > >number of packages loaded via a namespace. Not entirely clear where > >these come from. > > > >As a result, I often run into problems updating packages because > >something is already loaded. How can start a new gui session with > >minimal packages loaded? > > > >> sessionInfo() > >R version 3.6.3 (2020-02-29) > >Platform: x86_64-w64-mingw32/x64 (64-bit) > >Running under: Windows 7 x64 (build 7601) Service Pack 1 > > > >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 > > > >attached base packages: > >[1] stats graphics grDevices utils datasets methods base > > > > > >loaded via a namespace (and not attached): > >[1] statmod_1.4.34 xfun_0.18tidyselect_1.1.0 reshape2_1.4.4 > >purrr_0.3.4 mitools_2.4 > >[7] splines_3.6.3lattice_0.20-41 coefplot_1.2.6 carData_3.0-4 > >colorspace_1.4-1 vctrs_0.3.4 > >[13] generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 survival_3.2-7 > > rlang_0.4.7 pillar_1.4.6 > >[19] nloptr_1.2.2.2 glue_1.4.2 DBI_1.1.0lifecycle_0.2.0 > > plyr_1.8.6 stringr_1.4.0 > >[25] effects_4.2-0munsell_0.5.0gtable_0.3.0 evaluate_0.14 > > knitr_1.30 fansi_0.4.1 > >[31] Rcpp_1.0.5 scales_1.1.1 useful_1.2.6 fs_1.4.2 > > lme4_1.1-23 packrat_0.5.0 > >[37] ggplot2_3.3.2digest_0.6.25stringi_1.4.6insight_0.9.6 > > dplyr_1.0.2 survey_4.0 > >[43] grid_3.6.3 cli_2.1.0tools_3.6.3 magrittr_1.5 > > tibble_3.0.4 crayon_1.3.4 > >[49] pkgconfig_2.0.3 ellipsis_0.3.1 MASS_7.3-53 Matrix_1.2-18 > > reprex_0.3.0 assertthat_0.2.1 > >[55] minqa_1.2.4 rmarkdown_2.4rstudioapi_0.11 R6_2.4.1 > > boot_1.3-25 nnet_7.3-14 > >[61] nlme_3.1-149 compiler_3.6.3 > >> > > > >Michael Friendly Email: friendly AT yorku DOT ca > >Professor, Psychology Dept. & Former Chair, ASA Statistical Graphics > >Section > >York University Voice: 416 736-2100 x66249 > >4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly > >Toronto, ONT M3J 1P3 CANADA > > > >__ > >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. __ 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] 3d plot of earth with cut
> It should be a 2D slice/plane embedded into a 3D space. I was able to come up with the plot, attached. My intention was to plot national boundaries on the surface of a sphere. And put the slice inside. However, I haven't (as yet) worked out how to get the coordinates for the boundaries. Let me know, if of any value. And I'll post the code. (But needs to be polished first) __ 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] vanilla session in R Gui or RStudio
Have you looked into your .Rprofile file? Loading packages is not something R normally does without your telling it to do so, but many people forget that they have done so. On October 22, 2020 3:47:04 PM PDT, Michael L Friendly wrote: >[env: Windows, R 3.6.6] > >When I start R from the R Gui icon or from RStudio, I get a large >number of packages loaded via a namespace. Not entirely clear where >these come from. > >As a result, I often run into problems updating packages because >something is already loaded. How can start a new gui session with >minimal packages loaded? > >> sessionInfo() >R version 3.6.3 (2020-02-29) >Platform: x86_64-w64-mingw32/x64 (64-bit) >Running under: Windows 7 x64 (build 7601) Service Pack 1 > >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 > >attached base packages: >[1] stats graphics grDevices utils datasets methods base > > >loaded via a namespace (and not attached): >[1] statmod_1.4.34 xfun_0.18tidyselect_1.1.0 reshape2_1.4.4 >purrr_0.3.4 mitools_2.4 >[7] splines_3.6.3lattice_0.20-41 coefplot_1.2.6 carData_3.0-4 >colorspace_1.4-1 vctrs_0.3.4 >[13] generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 survival_3.2-7 > rlang_0.4.7 pillar_1.4.6 >[19] nloptr_1.2.2.2 glue_1.4.2 DBI_1.1.0lifecycle_0.2.0 > plyr_1.8.6 stringr_1.4.0 >[25] effects_4.2-0munsell_0.5.0gtable_0.3.0 evaluate_0.14 > knitr_1.30 fansi_0.4.1 >[31] Rcpp_1.0.5 scales_1.1.1 useful_1.2.6 fs_1.4.2 > lme4_1.1-23 packrat_0.5.0 >[37] ggplot2_3.3.2digest_0.6.25stringi_1.4.6insight_0.9.6 > dplyr_1.0.2 survey_4.0 >[43] grid_3.6.3 cli_2.1.0tools_3.6.3 magrittr_1.5 > tibble_3.0.4 crayon_1.3.4 >[49] pkgconfig_2.0.3 ellipsis_0.3.1 MASS_7.3-53 Matrix_1.2-18 > reprex_0.3.0 assertthat_0.2.1 >[55] minqa_1.2.4 rmarkdown_2.4rstudioapi_0.11 R6_2.4.1 > boot_1.3-25 nnet_7.3-14 >[61] nlme_3.1-149 compiler_3.6.3 >> > >Michael Friendly Email: friendly AT yorku DOT ca >Professor, Psychology Dept. & Former Chair, ASA Statistical Graphics >Section >York University Voice: 416 736-2100 x66249 >4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly >Toronto, ONT M3J 1P3 CANADA > >__ >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.
[R] vanilla session in R Gui or RStudio
[env: Windows, R 3.6.6] When I start R from the R Gui icon or from RStudio, I get a large number of packages loaded via a namespace. Not entirely clear where these come from. As a result, I often run into problems updating packages because something is already loaded. How can start a new gui session with minimal packages loaded? > sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 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 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] statmod_1.4.34 xfun_0.18tidyselect_1.1.0 reshape2_1.4.4 purrr_0.3.4 mitools_2.4 [7] splines_3.6.3lattice_0.20-41 coefplot_1.2.6 carData_3.0-4 colorspace_1.4-1 vctrs_0.3.4 [13] generics_0.0.2 htmltools_0.5.0 yaml_2.2.1 survival_3.2-7 rlang_0.4.7 pillar_1.4.6 [19] nloptr_1.2.2.2 glue_1.4.2 DBI_1.1.0lifecycle_0.2.0 plyr_1.8.6 stringr_1.4.0 [25] effects_4.2-0munsell_0.5.0gtable_0.3.0 evaluate_0.14 knitr_1.30 fansi_0.4.1 [31] Rcpp_1.0.5 scales_1.1.1 useful_1.2.6 fs_1.4.2 lme4_1.1-23 packrat_0.5.0 [37] ggplot2_3.3.2digest_0.6.25stringi_1.4.6insight_0.9.6 dplyr_1.0.2 survey_4.0 [43] grid_3.6.3 cli_2.1.0tools_3.6.3 magrittr_1.5 tibble_3.0.4 crayon_1.3.4 [49] pkgconfig_2.0.3 ellipsis_0.3.1 MASS_7.3-53 Matrix_1.2-18 reprex_0.3.0 assertthat_0.2.1 [55] minqa_1.2.4 rmarkdown_2.4rstudioapi_0.11 R6_2.4.1 boot_1.3-25 nnet_7.3-14 [61] nlme_3.1-149 compiler_3.6.3 > Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Former Chair, ASA Statistical Graphics Section York University Voice: 416 736-2100 x66249 4700 Keele StreetWeb: http://www.datavis.ca | @datavisFriendly Toronto, ONT M3J 1P3 CANADA __ 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] 3d plot of earth with cut
Thanks for your idea. It should be a 2D slice/plane embedded into a 3D space. Could be static, I just need to make a single figure from it for illustration of the Earth together with its interior in 3D. So, the interior would be a slice in 2D along a fixed longitude. And along this 2D slice would be a heatmap. Again, embedded in 3D, since it would be shown as a slice of Earth in 3D. Duncan’s suggestion is almost exactly what I need so I will try that as a start. Like that it is rotateable which is not a must, but it helps to figure out which angle of view is the best, I hope i can save it as a PDF or image. Also, happy to try other solutions as well, if you think I overcomplicate it! Balint On Thu 22. Oct 2020 at 23:54, aBBy Spurdle, ⍺XY wrote: > If you have "value" as a function of latitude and radius, isn't that a > 2D (not 3D) scalar field? > Which can be plotted using a regular heatmap. > > If you want a curved edge where depth=0 (radius=?), that's not too > difficult to achieve. > Not quite sure what continent boundaries mean in this context, but > that could possibly be added to. > > Or do you want a 2D slice superimposed within a 3D space? > > And if so, does it need to be dynamic? > (i.e. Rotate the whole thing, with a trackball/mouse). > > Note that the further you go down the list above, the more work is > required. > > > On Fri, Oct 23, 2020 at 7:41 AM Balint Radics > wrote: > > > > Hello, > > > > Could someone suggest a package/way to make a 3D raster plot of the Earth > > (with continent boundaries), and then make a "cut" or "slice" of it such > > that one can also visualize some scalar quantity as a function of the > > Radius/Depth across that given slice ? > > > > Formally, I would have a given, fixed longitude, and a list of vectors > > {latitude, radius, Value} > > that would show the distribution of the quantity "Value" at various > depths > > and latitudes in 3D. > > > > Thanks a lot in advance, > > Balint > > > > [[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. > [[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] 3d plot of earth with cut
Hello, this is very close to exactly what I need! I have tried it and it works nicely, I just have to map some values onto to the polygon or 2D plane that cuts into the 3D object. Thanks! Balint On Thu 22. Oct 2020 at 21:28, Duncan Murdoch wrote: > On 21/10/2020 8:45 a.m., Balint Radics wrote: > > Hello, > > > > Could someone suggest a package/way to make a 3D raster plot of the Earth > > (with continent boundaries), and then make a "cut" or "slice" of it such > > that one can also visualize some scalar quantity as a function of the > > Radius/Depth across that given slice ? > > > > Formally, I would have a given, fixed longitude, and a list of vectors > > {latitude, radius, Value} > > that would show the distribution of the quantity "Value" at various > depths > > and latitudes in 3D. > > The rgl package has a full sphere of the Earth with (obsolete) political > boundaries in example(persp3d). To cut it in half along the plane > through a given longitude (and that longitude + 180 deg), you could use > clipPlanes3d, or clipObj3d. For example, > > library(rgl) > lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE) > long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50) > > r <- 6378.1 # radius of Earth in km > x <- r*cos(lat)*cos(long) > y <- r*cos(lat)*sin(long) > z <- r*sin(lat) > > open3d() > ids <- persp3d(x, y, z, col = "white", > texture = system.file("textures/worldsmall.png", package = "rgl"), > specular = "black", axes = FALSE, box = FALSE, xlab = "", ylab > = "", zlab = "", > normal_x = x, normal_y = y, normal_z = z) > > clipFn <- function(coords) { >pmax(coords[,1], coords[,2]) # Just an example... > } > clipObj3d(ids["surface"], clipFn) > > > Filling in the exposed surface could be done with polygon3d(), with some > work to construct the polygon. Displaying the function across that > surface could be done in a couple of ways, either by using a texture map > (like for the map), or subdividing the polygon and setting colour by the > coordinates of each vertex. > > Note that the clipObj3d function isn't on CRAN yet; there you'd have to > use clipPlanes3d. You can get the newer version from R-forge. > > Duncan Murdoch > [[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] 3d plot of earth with cut
Hi Thanks a lot for this pointer, I will need to look at it. I did indeed google but did not find an example. In the meantime some additional solutions were suggested, that I also need to try. Cheers, Balint On Thu 22. Oct 2020 at 20:56, Bert Gunter wrote: > 1. Have you looked here: > https://cran.r-project.org/web/views/Spatial.html > (I assume you have done some web searches on possible terms like "3D Earth > Data R" or whatever) > > 2. You might try posting on the r-sig-geo list rather than here, where > relative expertise may more likely be available. > > Cheers, > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Thu, Oct 22, 2020 at 11:41 AM Balint Radics > wrote: > >> Hello, >> >> Could someone suggest a package/way to make a 3D raster plot of the Earth >> (with continent boundaries), and then make a "cut" or "slice" of it such >> that one can also visualize some scalar quantity as a function of the >> Radius/Depth across that given slice ? >> >> Formally, I would have a given, fixed longitude, and a list of vectors >> {latitude, radius, Value} >> that would show the distribution of the quantity "Value" at various depths >> and latitudes in 3D. >> >> Thanks a lot in advance, >> Balint >> >> [[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. >> > [[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] 3d plot of earth with cut
If you have "value" as a function of latitude and radius, isn't that a 2D (not 3D) scalar field? Which can be plotted using a regular heatmap. If you want a curved edge where depth=0 (radius=?), that's not too difficult to achieve. Not quite sure what continent boundaries mean in this context, but that could possibly be added to. Or do you want a 2D slice superimposed within a 3D space? And if so, does it need to be dynamic? (i.e. Rotate the whole thing, with a trackball/mouse). Note that the further you go down the list above, the more work is required. On Fri, Oct 23, 2020 at 7:41 AM Balint Radics wrote: > > Hello, > > Could someone suggest a package/way to make a 3D raster plot of the Earth > (with continent boundaries), and then make a "cut" or "slice" of it such > that one can also visualize some scalar quantity as a function of the > Radius/Depth across that given slice ? > > Formally, I would have a given, fixed longitude, and a list of vectors > {latitude, radius, Value} > that would show the distribution of the quantity "Value" at various depths > and latitudes in 3D. > > Thanks a lot in advance, > Balint > > [[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. __ 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] 3d plot of earth with cut
On 21/10/2020 8:45 a.m., Balint Radics wrote: Hello, Could someone suggest a package/way to make a 3D raster plot of the Earth (with continent boundaries), and then make a "cut" or "slice" of it such that one can also visualize some scalar quantity as a function of the Radius/Depth across that given slice ? Formally, I would have a given, fixed longitude, and a list of vectors {latitude, radius, Value} that would show the distribution of the quantity "Value" at various depths and latitudes in 3D. The rgl package has a full sphere of the Earth with (obsolete) political boundaries in example(persp3d). To cut it in half along the plane through a given longitude (and that longitude + 180 deg), you could use clipPlanes3d, or clipObj3d. For example, library(rgl) lat <- matrix(seq(90, -90, len = 50)*pi/180, 50, 50, byrow = TRUE) long <- matrix(seq(-180, 180, len = 50)*pi/180, 50, 50) r <- 6378.1 # radius of Earth in km x <- r*cos(lat)*cos(long) y <- r*cos(lat)*sin(long) z <- r*sin(lat) open3d() ids <- persp3d(x, y, z, col = "white", texture = system.file("textures/worldsmall.png", package = "rgl"), specular = "black", axes = FALSE, box = FALSE, xlab = "", ylab = "", zlab = "", normal_x = x, normal_y = y, normal_z = z) clipFn <- function(coords) { pmax(coords[,1], coords[,2]) # Just an example... } clipObj3d(ids["surface"], clipFn) Filling in the exposed surface could be done with polygon3d(), with some work to construct the polygon. Displaying the function across that surface could be done in a couple of ways, either by using a texture map (like for the map), or subdividing the polygon and setting colour by the coordinates of each vertex. Note that the clipObj3d function isn't on CRAN yet; there you'd have to use clipPlanes3d. You can get the newer version from R-forge. Duncan Murdoch __ 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] Function of "matrix"
> 10.1/0.1 was successfully calculated Note that 'computed as' is not the same as 'printed as'. Computations are done with 52 binary digits of precision and printing is, by default, done with 7 decimal digits of precision. See FAQ 7.31. > 101 - 10.1/0.1 [1] 1.421085e-14 > options(digits=17) > 10.1/0.1 [1] 100.99 > trunc(10.1/0.1) [1] 100 On Thu, Oct 22, 2020 at 11:42 AM 奈良県奈良市 wrote: > Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[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. > [[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] [External] Function of "matrix"
FAQ 7.31 > 10.1/.1 [1] 101 > print(10.1/.1, digits=17) [1] 100.99 > floor(10.1/.1) [1] 100 > floor(10.1*10) [1] 101 > matrix(0, 2.9, 3.9) [,1] [,2] [,3] [1,]000 [2,]000 > note that the dimension arguments are passed through floor() before they are used. On Thu, Oct 22, 2020 at 2:42 PM 奈良県奈良市 wrote: > > Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[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. __ 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] Function of "matrix"
(Neglected to cc the list--please reply-all to this version) What was the warning? I hazard a guess you've run into precision issues for binary representation, and the result of your division is not *exactly* 101. Pat On Thu, Oct 22, 2020 at 2:42 PM 奈良県奈良市 wrote: > > Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[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. -- Patrick S. Malone, Ph.D., Malone Quantitative NEW Service Models: http://malonequantitative.com He/Him/His __ 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] Function of "matrix"
1. Answers on this list are from volunteers who are not part of any R project team. We have no official status and what we say comes with no guarantees. 2. There is no such thing as a "matrix 'environment' ". 3. The answer to your question is "computer arithmetic." See FAQ 7.31. Someone may follow up with a more specific answer for your particular calculation, however. Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Oct 22, 2020 at 11:41 AM 奈良県奈良市 wrote: > Dear R project team > > I used the function of "matrix" as follows: > matrix(c(1:3030), 10.1/0.1) > However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. > Therefore, a warning message appeared. > On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was > OK. Of course, simply, 10.1/0.1 was successfully calculated. However, > In the "matrix" environment, 10.1/0.1 was calculated as 100. > > Would you give me some answers? > > Sincerely > > Kazuki Sakura > > [[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. > [[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] 3d plot of earth with cut
1. Have you looked here: https://cran.r-project.org/web/views/Spatial.html (I assume you have done some web searches on possible terms like "3D Earth Data R" or whatever) 2. You might try posting on the r-sig-geo list rather than here, where relative expertise may more likely be available. Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Oct 22, 2020 at 11:41 AM Balint Radics wrote: > Hello, > > Could someone suggest a package/way to make a 3D raster plot of the Earth > (with continent boundaries), and then make a "cut" or "slice" of it such > that one can also visualize some scalar quantity as a function of the > Radius/Depth across that given slice ? > > Formally, I would have a given, fixed longitude, and a list of vectors > {latitude, radius, Value} > that would show the distribution of the quantity "Value" at various depths > and latitudes in 3D. > > Thanks a lot in advance, > Balint > > [[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. > [[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.
[R] Function of "matrix"
Dear R project team I used the function of "matrix" as follows: matrix(c(1:3030), 10.1/0.1) However, in the function, matrix, 10.1/0.1 was regarded as 100 not as 101. Therefore, a warning message appeared. On the other hand, matrix(c(1:3030), 101) or matrix(c(1:3030), 10.1*10) was OK. Of course, simply, 10.1/0.1 was successfully calculated. However, In the "matrix" environment, 10.1/0.1 was calculated as 100. Would you give me some answers? Sincerely Kazuki Sakura [[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.
[R] 3d plot of earth with cut
Hello, Could someone suggest a package/way to make a 3D raster plot of the Earth (with continent boundaries), and then make a "cut" or "slice" of it such that one can also visualize some scalar quantity as a function of the Radius/Depth across that given slice ? Formally, I would have a given, fixed longitude, and a list of vectors {latitude, radius, Value} that would show the distribution of the quantity "Value" at various depths and latitudes in 3D. Thanks a lot in advance, Balint [[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] Fitting Mixed Distributions in the fitdistrplus package
dmixgampar <- function (x, param1, param2, ...) { #compute density at x } On Wed, Oct 21, 2020 at 8:03 PM Charles Thuo wrote: > > Dear Sirs, > > The below listed code fits a gamma and a pareto distribution to a data set > danishuni. However the distributions are not appropriate to fit both tails > of the data set hence a mixed distribution is required which has ben > defined as "mixgampar" > as shown below. > > library(fitdistrplus) > x<- danishuni$Loss > fgam<- fitdist(x,"gamma",lower=0) > fpar<- fitdist(x,"pareto",start = list(shape=2,scale=2),lower=0) > fmixgampar<- fitdist(x,"mixgampar",start = > list(prob=1/2,nu=1,lambda=1,alpha=1,theta=1),lower=0) > Error in fitdist(x, "mixgampar", start = list(prob = 1/2, nu = 1, lambda = > 1, : > > The dmixgampar function must be defined > > Kindly assist to define the dmixgampar > > Charkes > > [[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. __ 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.