Re: [R] Format printing with R
Hi All How about data.frame or zapsmall. Apologies for the small set but it seems to show the point Mean = c(0.311,0.188,45.319) sdd = c(0.36,0.39,16.31) data.frame(Mean = Mean, St.dev = sdd) Mean St.dev 1 0.311 0.36 2 0.188 0.39 3 45.319 16.31 print(data.frame(Mean = Mean, St.dev = sdd),digits = 2) Mean St.dev 1 0.31 0.36 2 0.19 0.39 3 45.32 16.31 zapsmall(data.frame(Mean = Mean, St.dev = sdd),digits = 4) Mean St.dev 1 0.31 0.36 2 0.19 0.39 3 45.32 16.31 zapsmall(cbind(Mean = Mean,sdd),digits = 4) Mean sdd [1,] 0.31 0.36 [2,] 0.19 0.39 [3,] 45.32 16.31 Regards Duncan Mackay -- Original Message -- From: "Jim Lemon" To: "Steven T. Yen" Cc: "R-help Mailing List" Sent: Tuesday, 22 Nov, 2022 At 8:09 AM Subject: Re: [R] Format printing with R Hi Steven, I thought that the problem might be in the two large numbers, but using a subset (I didn't want to edit out all the line numbers), I get what I expected: sydf<-read.table(text="Mean Std.dev [1,] 0.3107966 0.462820 [2,] 0.1880302 0.390736 [3,] 45.3185794 16.313635 [4,] 0.5066370 0.499956 [5,] 0.4933630 0.499956 [6,] 0.7029150 0.456974 [7,] 0.2970850 0.456974 [8,] 0.7967066 0.402449 [9,] 0.2032934 0.402449", stringsAsFactors=FALSE,header=TRUE) print(sydf,digits=2) Mean Std.dev [1,] 0.310.46 [2,] 0.190.39 [3,] 45.32 16.31 [4,] 0.510.50 [5,] 0.490.50 [6,] 0.700.46 [7,] 0.300.46 [8,] 0.800.40 [9,] 0.200.40 I don't think it is your use of "cbind", but I didn't edit out Mean and Std.dev and try it. Jim On Tue, Nov 22, 2022 at 7:41 AM Steven T. Yen via R-help wrote: Hi, I have two variables with 86 observations each. Below I print with the print command with digit=2. But, I am getting three decimal places for my first variable and two for the second. Please help. Thanks. cbind(Mean,Std.dev) Mean Std.dev [1,] 0.3107966 0.462820 [2,] 0.1880302 0.390736 [3,] 45.3185794 16.313635 [4,] 0.5066370 0.499956 [5,] 0.4933630 0.499956 [6,] 0.7029150 0.456974 [7,] 0.2970850 0.456974 [8,] 0.7967066 0.402449 [9,] 0.2032934 0.402449 [10,] 0.6582301 0.474303 [11,] 0.3417699 0.474303 [12,] 0.7262913 0.445861 [13,] 0.2737087 0.445861 [14,] 0.6415484 0.479546 [15,] 0.3584516 0.479546 [16,] 0.9110264 0.284706 [17,] 0.0889736 0.284706 [18,] 0.5211453 0.499553 [19,] 0.4788547 0.499553 [20,] 0.5481055 0.497680 [21,] 0.4518945 0.497680 [22,] 0.9135090 0.281088 [23,] 0.0864910 0.281088 [24,] 0.8727269 0.333279 [25,] 0.1272731 0.333279 [26,] 0.1015717 0.302084 [27,] 0.6043692 0.488986 [28,] 0.2940592 0.455619 [29,] 0.2735274 0.445769 [30,] 0.3777426 0.484823 [31,] 0.3487300 0.476568 [32,] 0.1603127 0.366896 [33,] 0.1723783 0.377709 [34,] 0.1230961 0.328547 [35,] 0.1779381 0.382461 [36,] 0.0964334 0.295185 [37,] 0.1584698 0.365181 [38,] 0.1113717 0.314592 [39,] 0.3349813 0.471984 [40,] 0.4081109 0.491484 [41,] 0.2569078 0.436928 [42,] 0.1034356 0.304527 [43,] 0.6741233 0.468701 [44,] 0.1254412 0.331218 [45,] 0.096 0.295958 [46,] 0.0587457 0.235148 [47,] 0.4401115 0.496400 [48,] 0.4689114 0.499033 [49,] 0.0322313 0.176614 [50,] 0.5907618 0.491693 [51,] 0.1591195 0.365787 [52,] 0.1132923 0.316950 [53,] 0.1124207 0.315883 [54,] 0.0244058 0.154305 [55,] 0.7058787 0.455647 [56,] 0.2941213 0.455647 [57,] 0.0746892 0.262889 [58,] 0.4749110 0.499370 [59,] 0.3471837 0.476075 [60,] 0.0435036 0.203988 [61,] 0.0597126 0.236954 [62,] 0.0478775 0.213507 [63,] 0.1152615 0.319337 [64,] 0.2074968 0.405514 [65,] 0.2440626 0.429530 [66,] 0.1605995 0.367161 [67,] 0.0804598 0.272004 [68,] 0.1442422 0.351335 [69,] 0.3443231 0.475147 [70,] 0.4280560 0.494797 [71,] 0.0528221 0.223678 [72,] 0.0805222 0.272100 [73,] 0.0457169 0.208870 [74,] 0.0485596 0.214945 [75,] 0.1333443 0.339946 [76,] 0.0932917 0.290841 [77,] 0.0653987 0.247228 [78,] 0.0573934 0.232593 [79,] 0.1399086 0.346892 [80,] 0.0887337 0.284359 [81,] 0.0984479 0.297919 [82,] 0.0914421 0.288237 [83,] 0.1155505 0.319685 [84,] 0.1363764 0.343188 [85,] 0.1134570 0.317151 [86,] 1.2985286 0.739096 print(cbind(Mean,Std.dev),digits=2) Mean Std.dev [1,] 0.3110.46 [2,] 0.1880.39 [3,] 45.319 16.31 [4,] 0.5070.50 [5,] 0.4930.50 [6,] 0.7030.46 [7,] 0.2970.46 [8,] 0.7970.40 [9,] 0.2030.40 [10,] 0.6580.47 [11,] 0.3420.47 [12,] 0.7260.45 [13,] 0.2740.45 [14,] 0.6420.48 [15,] 0.3580.48 [16,] 0.9110.28 [17,] 0.0890.28 [18,] 0.5210.50 [19,] 0.4790.50 [20,] 0.5480.50 [21,] 0.4520.50 [22,] 0.9140.28 [23,] 0.0860.28 [24,] 0.8730.33 [25,] 0.1270.33 [26,] 0.1020.30 [27,] 0.6040.49 [28,] 0.2940.46 [29,] 0.2740.45 [30,] 0.3780.48 [31,] 0.3490.48 [32,]
Re: [R] Unicode chars
Thank you for the reply I tried xeLatex at least once and possibly twice and it failed to compile I now tried it again and found that I had missed the inputenc error when I tried before. After removing the line it now compiles. Thank you Regards Duncan -- Original Message -- From: "Jeff Newmiller" To: r-help@r-project.org; "dulcalma dulcalma" ; r-help@R-project.org Sent: Thursday, 25 Aug, 2022 At 1:25 PM Subject: Re: [R] Unicode chars Are you aware that pdfLatex does not support Unicode? You need to use xeLatex. But I don't use Sweave, so I don't know how you go about making that choice. On August 24, 2022 8:03:02 PM PDT, dulcalma dulcalma wrote: Dear All I was trying the supplementary file GS_main.R from https://esajournals.onlinelibrary.wiley.com/doi/abs/10.1002/ecy.3475 I have tried to prevent latex compilation from failing using Sweave after trying all the online fixes I could find including using Rterm I could fix it if it was in the input but not in the output I am using R version 4.2 on windows 11 with 64 GB memory Sweave code \begin{small} <>= library(emdbook) # version 1.3.12 library(bbmle) # version 1.0.23.1 library(pbmcapply) # version 1.5.0 library(tidyverse) # version 1.3.0 library(ggpubr) # version 0.4.0 @ %% <>= summaryTable <- tibble(model = m.names, dim = m.dims[model], score = m.loo[model], delScore = score - min(score), se_ose = se_ose[model], se_mod = se_mod[model]) %>% arrange(dim) %>% mutate(index = 1:length(dim)) summaryTable @ %% Output \begin{Schunk} \begin{Sinput} summaryTable <- tibble(model = m.names, dim = m.dims[model], score = m.loo[model], delScore = score - min(score), se_ose = se_ose[model], se_mod = se_mod[model]) %>% arrange(dim) %>% mutate(index = 1:length(dim)) summaryTable \end{Sinput} \begin{Soutput} # A tibble: 10 × 7 model dim score delScore se_ose se_mod index 1 zero 2 908. 5.84 40.1 4.14 1 2 d 3 904. 1.71 40.6 2.52 2 3 q 3 907. 4.92 40.2 3.80 3 4 qd 4 902. 0 40.7 0 4 5 qdi 5 903. 0.632 40.5 1.60 5 6 x 6 908. 5.58 40.2 5.53 6 7 xq 7 907. 4.81 40.3 5.36 7 8 xd 7 905. 2.96 40.5 5.04 8 9 xqd 8 903. 0.908 40.5 4.52 9 10 xqdi 9 904. 1.89 40.4 4.70 10 \end{Soutput} \end{Schunk} The problem is the output from tibble # A tibble: 10 × 7 the \times character is Unicode U+00D7 or hex \xd7 and pdflatex lualatex etc fail where this occurs Is there a way of adding "sanitizing" code in the output before compiling Or do I have to change it manually before compiling I do not want to switch to knitr. Regards Duncan Mackay [[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. -- 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] Multi-level (nested) correlation structures via geepack package
Hi Your choice of package should partly depend on the type of dependent variable or Y that you are going to be dealing with categorical/ordinal data may involve different packages than continuous or binary data see multgee for one. The number of samples can also make a difference GEE with the "correct model" should normally have no problems with numbers 30-40; 25 or less would normally require corrections and a diffence package. The doi for multgee paper is 10./biom.12054 and Touloumis paper in Journal of Statistical Software For longitudinal data there is the following doi: 10.2307/2531248 and 10.1097/EDE.0b013e3181caeb90 10.1093/biomet/90.1.29 10.1007/s00362-017-0881-0 10.1002/sim.2368 a search for gee in the list of available packages should show you the alternatives. As a check of the result do the statistics on another package. I remember doing a simple gee with an example from a book using 4 different packages 2 of which gave poor or unreasonable answers Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 -- Original Message -- From: "Phat Chau" To: "r-help@R-project.org" ; "sor...@math.aau.dk" Sent: Sunday, 12 Jul, 2020 At 11:52 PM Subject: Re: [R] Multi-level (nested) correlation structures via geepack package Hello, I have a multi-level, cohort dataset with three levels: repeat measures of a response (level 1), that are collected from individual participants (level 2) who are students within a school (level 3). I would like to do a generalized estimating equation (GEE) analysis of this clustered data, but to do so I need to specify ‘nested’ correlation structures (e.g. exchangeable, compound symmetric, Toeplitz) to account for the within-individual and within-cluster correlations. Here is a reference paper that describes a nested exchangeable correlation structure and nested compound symmetry: doi:10./j.1541-0420.2009.01374.x. The geepack is available in R to do GEE analyses, but it seems to me that it only allows the user to specify a correlation structure via the geepack(…‘corstr = ‘) option which only accounts for the within-individual correlations (that arise from repeated measures). Would it be possible to specify the nested correlation structures that I refer to here to also account for the within-cluster correlations using this package? Thank you, Edward [[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.