Re: [R] Sorting vector based on pairs of comparisons

2019-03-14 Thread Richard M. Heiberger
Try this. Anything that appears only in Smaller is candidate for smallest. Among those, order is arbitrary. Anything that appears only in Larger is a candidate for largest. Among those order is arbitrary. Remove rows of matComp containing the already classified items. Repeat with the smaller set

Re: [R] Q re: logical indexing with is.na

2019-03-09 Thread Richard M. Heiberger
>From ?Arithmetic the elements of shorter vectors are recycled as necessary (with a ‘warning’ when they are recycled only _fractionally_). > tmp <- !is.na(y[1:3]) > tmp [1] TRUE TRUE FALSE > c(tmp, tmp) [1] TRUE TRUE FALSE TRUE TRUE FALSE > c(tmp, tmp)[1:4] [1] TRUE TRUE FALSE T

Re: [R] data.frame() versus as.data.frame() applied to a matrix.

2019-02-05 Thread Richard M. Heiberger
To me the interesting difference between matrix() and as.matrix() is that as.matrix() retains the argument names as the rows names of the result. > tmp <- structure(1:3, names=letters[1:3]) > tmp a b c 1 2 3 > matrix(tmp) [,1] [1,]1 [2,]2 [3,]3 > as.matrix(tmp) [,1] a1 b2

Re: [R] [FORGED] Tukey Test

2019-01-24 Thread Richard M. Heiberger
and the mmcplot in the HH package which plots the results from the multcomp package. On Thu, Jan 24, 2019 at 11:14 PM Rolf Turner wrote: > > > On 1/25/19 4:51 PM, reichm...@sbcglobal.net wrote: > > > R-Help > > > > > > > > There is an R library that will perform a Tukey test ... > > > > Surely y

Re: [R] data transformation

2019-01-20 Thread Richard M. Heiberger
this might work for you newy <- sign(oldy)*f(abs(oldy)) where f() is a monotonic transformation, perhaps a power function. On Sun, Jan 20, 2019 at 11:08 AM Adrian Johnson wrote: > > I apologize, I forgot to mention another key operation. > in my matrix -1 to <0 has a different meaning while va

Re: [R] Mailinglist

2019-01-08 Thread Richard M. Heiberger
ed=="False") (this participant 875) > > screenon_true=subset(p1,valuedetailed=="True") (this participant 916) > > > > and for activity probe to none, low and high to find the required values > > > > activity_none=subset(p1,valuedetailed=="none&q

Re: [R] mgcv : 3-way interaction and 3D-plots ?

2019-01-07 Thread Richard M. Heiberger
## Here is an example using the 3-way interaction plot from the HH package install.packages("HH") ## if necessary ## The HH package supports the book ## Statistical Analysis and Data Display ## Richard M. Heiberger and Burt Holland ## http://www.springer.com/us/book/9781493921218

Re: [R] Mailinglist

2019-01-06 Thread Richard M. Heiberger
Questions like this 1. I want to have a summary of how many times a specific subject got called (CallLogProbe) suggest that you should look at the table function. See ?table and run the examples. They show how to get one-way frequency tables and two-way contingency tables. If you have followup q

Re: [R] you are making it far too difficult

2018-12-27 Thread Richard M. Heiberger
I downloaded the Donors dataset https://dcc.icgc.org/search?filters=%7B%22donor%22:%7B%22projectId%22:%7B%22is%22:%5B%22GBM-US%22%5D%7D,%22availableDataTypes%22:%7B%22is%22:%5B%22pexp%22%5D%7D%7D%7D by clicking "Export table as TSV". Then I read it with donors <- read.delim("~/Downloads/donors_

Re: [R] Fwd: UPDATE

2018-12-26 Thread Richard M. Heiberger
gt; > >> >> > > >> >> I worked on directly downloading the file into R as was suggested, > > >> >but > > >> >> have thus far been unsuccessful. This is what I generated on my > > >> >second > > >>

Re: [R] Help converting .txt to .csv file

2018-12-26 Thread Richard M. Heiberger
I looked at the first file. It gives an option to download as TSV (tab separated values). That is the same as CSV except with tabs instead of commas. You do not need any external software to read it. Read the downloaded file directly into R. read.delim looks as if it would work directly on the d

Re: [R] Problem with LM

2018-12-18 Thread Richard M. Heiberger
## This example, with your variable names, works correctly. z2 <- data.frame(y=1:5, x=c(1,5,2,3,5), x2=c(1,5,2,3,5)^2) z2 class(z2) length(z2) dim(z2) lm(y ~ x + x2, data=z2) ## note that that variable names y, x, x2 are column names of the ## data.frame z2 ## please review the definitions and

Re: [R] R code for if-then-do code blocks

2018-12-17 Thread Richard M. Heiberger
304 1538.012 1617.985 1865.149 2177.071 100 b rmh4 850.729 1042.997 1380.842 1416.476 1700.307 2448.545 100 a On Mon, Dec 17, 2018 at 12:49 PM Richard M. Heiberger wrote: > > this can be dome even faster, and I think more easily read, using only base R > > d1 <- data.frame(

Re: [R] R code for if-then-do code blocks

2018-12-17 Thread Richard M. Heiberger
this can be dome even faster, and I think more easily read, using only base R d1 <- data.frame(workshop=rep(1:2,4), gender=rep(c("f","m"),each=4)) ## needed by vector and rowbased, not needed by rmh library(tibble) library(plyr) library(magrittr) microbenchmark( vector = {d1 %>

Re: [R] why the base::round(0.015, 2) returns 0.02?

2018-11-28 Thread Richard M. Heiberger
interesting. this looks like an OS problem, since ?round says ‘round’ rounds the values in its first argument to the specified number of decimal places (default 0). See ‘Details’ about “round to even” when rounding off a 5. Details Note that for rounding off a 5, the IEC 60559

Re: [R] extrat non diagonal

2018-11-14 Thread Richard M. Heiberger
; B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)] > B [,1] [,2] [,3] [1,]247 [2,]368 > On Wed, Nov 14, 2018 at 2:09 PM Richard M. Heiberger wrote: > > Steve's method is very slick. > > I think this is a bit easier to understand. > > A <- mat

Re: [R] extrat non diagonal

2018-11-14 Thread Richard M. Heiberger
Steve's method is very slick. I think this is a bit easier to understand. A <- matrix(1:9, 3, 3) A B <- matrix(nrow=2, ncol=3) B[lower.tri(B, diag=TRUE)] <- A[lower.tri(A)] B[upper.tri(B, diag=FALSE)] <- A[upper.tri(A)] B > A <- matrix(1:9, 3, 3) > A [,1] [,2] [,3] [1,]147 [2,]

Re: [R] Different stack barplots - same color legends

2018-11-01 Thread Richard M. Heiberger
e situatie in zeer hoge mate van toepassing is voor u of uw >>> >>>> > supervisorengroep LIKERT STRING >>> >>>> > 3 de situatie in zeer hoge mate van toepassing is voor u of uw >>> >>>> > supervisorengroep LIKERT STRING >>

Re: [R] Different stack barplots - same color legends

2018-10-31 Thread Richard M. Heiberger
ngroep", > "de situatie in zeer hoge mate van toepassing is voor u of uw > supervisorengroep", > "de situatie in zeer hoge mate van toepassing is voor u of uw > supervisorengroep", > "de situatie in zeer hoge mate van toepassing is voor u of uw > supervisoreng

Re: [R] Different stack barplots - same color legends

2018-10-31 Thread Richard M. Heiberger
7 schreef Richard M. Heiberger : >> >> Please send me the >> dput(teamq) >> >> >> On Wed, Oct 31, 2018 at 03:51 P. Roberto Bakker >> wrote: >>> >>> Thank you for you information. Package 'HH' is interesting. >>&

Re: [R] Different stack barplots - same color legends

2018-10-31 Thread Richard M. Heiberger
ble names would be a > problem. > Same error. > > What could I do? > > Best and thank you in advance. > Roberto > > > Op ma 22 okt. 2018 om 20:10 schreef Richard M. Heiberger : > >> Try the likert function in >> install.packages("HH) ## if necessar

Re: [R] Different stack barplots - same color legends

2018-10-22 Thread Richard M. Heiberger
Try the likert function in install.packages("HH) ## if necessary library(HH) Then using David Carlson's example teamq likert(teamq) Your example in the 1:30PM (Eastern Daylight Time) doesn't work. Error in revalue(teamq, c(`de situatie in zeer geringe mate van toepassing is\nvoor u of uw supervis

Re: [R] Rounding behavior

2018-10-09 Thread Richard M. Heiberger
FAQ 7.31 Open this file in your favorite text editor on your computer system.file("../../doc/FAQ") 57.5 comes out even in binary, and .575 does not. > print(.575*100, digits=17) [1] 57.493 ## The fraction is less than .5, hence it gets rounded down to 57 > print(57.5, digits=17) [1] 5

Re: [R] Boxplot with linear (not categorical) x-axis

2018-09-28 Thread Richard M. Heiberger
install.packages("HH") library(HH) system.file("demo/bwplot.examples.r", package="HH") demo("bwplot.examples", package="HH", ask=FALSE) ## your example dfA <- data.frame(X, Y=c(A, B, C)) dfA$X.factor <- factor(dfA$X) position(dfA$X.factor) <- c(1,3,5) bwplot(Y ~ X.factor, panel=panel.bwplot.interm

Re: [R] For Loop

2018-09-22 Thread Richard M. Heiberger
c1 <- 1:100 len <- 100 system.time( s1 <- log(c1[-1]/c1[-len]) ) s <- c1[-len] system.time( for (i in 1:(len-1)) s[i] <- log(c1[i+1]/c1[i]) ) all.equal(s,s1) > > c1 <- 1:100 > len <- 100 > system.time( + s1 <- log(c1[-1]/c1[-len]) + ) user system elapsed 0.032 0.005 0.03

Re: [R] lattice barchart() with two variables

2018-08-24 Thread Richard M. Heiberger
color for the legend comes from trellis.par.get You can control that for an individual plot with the par.settings argument. tmp <- data.frame(y=sample(10), group=rep(c("Median", "Maximum"), each=5), year=factor(rep(1998:1999, length=10))) barchart(y ~ year, da

Re: [R] plotmath and logical operators?

2018-08-20 Thread Richard M. Heiberger
## I would use microplot in this situation. ## This example produces a pdf file containing the graph. library(lattice) library(microplot) ## Hmisc options for pdflatex ## graphics files are .pdf latexSetOptions() RtoLatex <- function(subset , subset.char=substitute(subset)) { ## you might need

Re: [R] Using rmarkdown with many plots created in a loop

2018-08-20 Thread Richard M. Heiberger
## Don, ## This is how I would approach the task of a set of coordinated plots. ## I would place individual plots inside a table. The rows would index the ## datasets and there would be one or more data or description columns ## in addition to the column containing the graphs. ## I use the micro

Re: [R] Mysterious seg fault --- SOLVED

2018-08-14 Thread Richard M. Heiberger
There is no explanation other than gremlins and the malevolence that the computer gods hold towards me. fortune nomination. On Tue, Aug 14, 2018 at 7:12 PM, Rolf Turner wrote: > On 14/08/18 23:01, peter dalgaard wrote: >> >> Hmm, >> >>> .Fortran(stats:::C_setsmu, as.integer(0)) >> >> [[1]] >> [1

Re: [R] Cannot set correct miktex path for pdflatex

2018-08-14 Thread Richard M. Heiberger
You are getting the correct version. R is using the 8.3 version of the path. MS DOS often can't handle long MS Windows pathnames, particularly with blank space characters. MS therefore provides an 8.3 equivalent for all long names. C:\>dir /x prog* dir /x prog* Volume in drive C has no label. V

Re: [R] Grouped boxplots using ggplot() from ggplot2.

2018-07-29 Thread Richard M. Heiberger
## I recommend using lattice for this task. ## First I show the example from my book and package (HH). ## Then I use this on your example. library(HH) ## Package supporting Heiberger and Holland, ## Statistical Analysis and Data Display (Second edition, 2015) HHscriptnames(

Re: [R] Scaling - does it get any better results than not scaling?

2018-07-17 Thread Richard M. Heiberger
This is a variant of FAQ 7.31 on rounding. For hand arithmetic, for example the variance of c(29,30,31), it was easier to subtract the mean and work with c(-1,0,1). For limited precision computers working directly with many-digit numbers could lead to rounding in intermediate steps and catastrophi

Re: [R] Adding lines to the page

2018-06-27 Thread Richard M. Heiberger
See if the microplot package provides what you need. The package help file and the vignette will get you started. Microplot works with Hmisc::latex or with MS Word into either Word or HTML. On Wed, Jun 27, 2018 at 19:04 Stats Student wrote: > Thanks, Jeff. The Task View page was very informative

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Richard M. Heiberger
matrix("", (n + nc - 1) %/% nc, nc) > > for generalizability, as I may have to increase nc as the list of words > grows ever longer. > > Thanks everyone. Several good suggestions. > > --Chris Ryan > > Richard M. Heiberger wr

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Richard M. Heiberger
I think this is cuter, and it is a hair faster. n <- length(dd) ddm <- matrix("", (n+2) %/% nc, nc) ddm[1:n] <- dd Rich > system.time(for (i in 1:1) { + add <- nc - (length(dd) %% nc) + dd2 <- c(dd, rep("", add)) + ddm <- matrix(dd2, ncol = nc) + }) user system elapsed 0.064 0.100

Re: [R] draw borders of bars inside of the rectangles in a barplot

2018-05-21 Thread Richard M. Heiberger
I recommend instead of no border, that you use a border with the same color as the fill. I do this in the likert functions in the HH package. Rich On Mon, May 21, 2018 at 10:59 AM, Martin Batholdy via R-help wrote: > Dear R-users, > > I want to draw a barplot with beside=TRUE. > One halve of th

Re: [R] Installing an Archived Package

2018-05-16 Thread Richard M. Heiberger
You can tell Macintosh not to automatically unpack tar.gz files. https://apple.stackexchange.com/questions/961/how-to-stop-safari-from-unzipping-files-after-download On Wed, May 16, 2018 at 11:24 AM, Evguenia Ignatova wrote: > Hello, > > I am having difficulty installing the most recent compati

Re: [R] read.csv and Decimal places

2018-05-07 Thread Richard M. Heiberger
The stored numbers are correct. They are rounded on printing. print(RevFCast, digits=17) See ?options And scroll down to digits. On Mon, May 7, 2018 at 11:50 Bill Poling wrote: > Hi, Novice UsR here. > > I have a csv file that contains 13 columns of numeric data that have > decimal places (for

Re: [R] Bivariate Normal Distribution Plots

2018-04-12 Thread Richard M. Heiberger
Please look at my book Statistical Analysis and Data Display https://www.springer.com/us/book/9781493921218 Figures 3.8, 3.9, 3.10 The code for these figures is available in the HH package install.packages("HH") library(HH) HHscriptnames(3) ## this gives the filename on your computer containing

Re: [R] Mean of a row of a data frame

2018-03-20 Thread Richard M. Heiberger
rowMeans is designed for speed. It also has as.matrix inside it. On Tue, Mar 20, 2018 at 10:40 PM, Boris Steipe wrote: > R > rowMeans(roop) > [1] 1.67 5.33 3.00 > R > mean(as.numeric(roop[1,])) > [1] 1.67 > > > :-) > > > > >> On Mar 20, 2018, at 10:18 PM, Sorkin, John wrote: >>

Re: [R] Mean of a row of a data frame

2018-03-20 Thread Richard M. Heiberger
> mean(list(1,4,0)) [1] NA Warning message: In mean.default(list(1, 4, 0)) : argument is not numeric or logical: returning NA > mean(unlist(roop[1,])) [1] 1.67 > apply(roop, 1, mean) [1] 1.67 5.33 3.00 data.frame is a list with some matrix characteristics. The list characteristic

Re: [R] ggplot and boxplots

2018-03-12 Thread Richard M. Heiberger
It looks like your V3 is a factor. testing_ggplot <- data.frame( V1=factor(c(256, 256, 256, 272, 272, 272)), V2=c("Disabled", "Disabled", "Enabled", "Disabled", "Enabled", "Enabled"), V3=681:686) library(ggplot2) ggplot(testing_ggplot, aes(V2,V3 )) + geom_boxplot() + facet_wrap( ~ V

Re: [R] couple of how-to-do it in R questions regarding corelations and mean and SD of likert items

2018-03-06 Thread Richard M. Heiberger
Please look at the microplot package, install.packages("microplot") ## it will bring in lots of other packages. Specifically look at the demo demo("tablesPlusGraphicColumn", package="microplot") The last item in that demo is an MS Word table with the text of the question, some numerical informa

Re: [R] plotting the regression coefficients

2018-02-12 Thread Richard M. Heiberger
Petr, there was a thinko in your response. tmp <- data.frame(m=factor(letters[1:4]), n=1:4) tmp tmp$m <- factor(tmp$m, levels=c("c","b","a","d")) ## right tmp[order(tmp$m),] tmp <- data.frame(m=factor(letters[1:4]), n=1:4) levels(tmp$m) <- c("c","b","a","d") ## wrong tmp[order(tmp$m),] changing

Re: [R] consolidate three function into one

2018-01-14 Thread Richard M. Heiberger
FAQ 7.22 You must print a ggplot object, for example with print(m52.2cluster) For the FAQ, run the line system.file("../../doc/FAQ") in R on your computer. Open up the resulting filepath in your favorite editor and scroll down to 7.22 On Sun, Jan 14, 2018 at 4:21 PM, Ding, Yuan Chun wrote: >

[R] t.trellis doesn't invert

2017-12-15 Thread Richard M. Heiberger
> version _ platform x86_64-w64-mingw32 arch x86_64 os mingw32 system x86_64, mingw32 status Patched major 3 minor 4.3 year 2017 month 12 day12 svn rev73903 language R version.s

[R] change in behavior of c.trellis

2017-12-13 Thread Richard M. Heiberger
> library(latticeExtra) Loading required package: lattice Loading required package: RColorBrewer > t11 <- xyplot(1 ~ 1) > t11 > c(t11, t11) Warning message: In formals(fun) : argument is not a function > version _ platform x86_64-w64-mingw32 arch x86_64 os

Re: [R] update R version in windows

2017-11-10 Thread Richard M. Heiberger
installr is Windows-specific. From the DESCRIPTION OS_type:windows I would guess that some of it would work on other OS, but you would have to check. If it looks useful elsewhere you should tell Tal Maintainer:Tal Galili Rich On Fri, Nov 10, 2017 at 1:18 PM, J C Nash wrote: > However, trying

Re: [R] update R version in windows

2017-11-10 Thread Richard M. Heiberger
Try the installr package. It was designed for this purpose. On Fri, Nov 10, 2017 at 11:49 AM, Bond, Stephen wrote: > Is there a utility which will allow me to upgrade my R version and update all > packages from the old version? > If I manually upgrade, then I have to manually re-install 50 packa

Re: [R] Question - TukeyHSD

2017-11-04 Thread Richard M. Heiberger
Assuming you have as your model a one-way ANOVA, you can use the aovSufficient function in HH. ## install.packages("HH") ## if you don't have it yet library(HH) ?aovSufficient On Sat, Nov 4, 2017 at 9:30 AM, Paul Kent wrote: > Hi, > > > I've been performing some TukeyHSD tests in R and have come

Re: [R] ggplot inside function doesn't plot

2017-11-02 Thread Richard M. Heiberger
FAQ 7.22 Open the file indicated by system.file("../../doc/FAQ") and scroll down to 7.22 On Thu, Nov 2, 2017 at 1:03 PM, Ed Siefker wrote: > I don't really understand. I mean, I understand the solution is > print(ggplot(...)). But why is that required in a function and not at > the console? >

Re: [R] data.matrix output is not numeric

2017-10-13 Thread Richard M. Heiberger
integer is a subclass of numeric. > is.numeric(data.matrix(test.df)[[1]]) [1] TRUE See ?integer, ?numeric, ?storage.mode On Fri, Oct 13, 2017 at 2:07 PM, Ed Siefker wrote: > I have a data frame full of integer values. I need a matrix full of > numeric values. > > ?data.matrix reads: > >

Re: [R] Difficulty Installing Packages

2017-08-27 Thread Richard M. Heiberger
And also to the initial error message I suggest the message be revised to say " unable to move temporary installation. Please close all running R instances, and try again from a fresh 'R --vanilla' instance" On Sun, Aug 27, 2017 at 1:41 PM, Jeff Newmiller wrote: > I think that this response s

Re: [R] likert Package

2017-08-23 Thread Richard M. Heiberger
## There is a bug in likert:::plot.likert. ## The centered argument is not handled correctly. ## In addition to centering, it also flips the order. ## Here it is: likert:::plot.likert(results, type = "bar", centered = TRUE, ## correct order group.order = c("Band 3", "Band 4")

Re: [R] likert Package

2017-08-23 Thread Richard M. Heiberger
most likely you have a factor with default levels which are not ordered the way you want them to be ordered. You can reorder the levels with the factor function. If you still need help after adjusting the order of the levels, then please send the data to the list by including the output of dput(da

Re: [R] Lattice Histogram Scaling

2017-08-15 Thread Richard M. Heiberger
by > > hist(x, 100, freq = FALSE) > > I’ve experimented with xlim, ylim, without success so far... > > url:www.econ.uiuc.edu/~rogerRoger Koenker > emailrkoen...@uiuc.eduDepartment of Economics > vox: 217-333-4558 University

Re: [R] Lattice Histogram Scaling

2017-08-14 Thread Richard M. Heiberger
Your example is not easily reproducible. The REBayes requires Rmosek which requires a system command MOSEK. Please try again with an example using data in base R. Meanwhile, my guess is that you will need to do something like explicitly specifying xlim and ylim so all panels have the same limits.

Re: [R] Help creating the IBM Randu function

2017-08-14 Thread Richard M. Heiberger
Please look at ?datasets::randu for David Donoho's translation of RANDU into R. On Mon, Aug 14, 2017 at 12:49 PM, Martin Møller Skarbiniks Pedersen wrote: > Dear all, > > I am trying to learn functions in R and 3D plotting so I decided to try > to plot > the famous bad PRNG Randu from IBM(1).

Re: [R] Creating/Reading a complex string in R

2017-07-18 Thread Richard M. Heiberger
your string opens with single quote ', and has a single quote ' in the middle. R sees that as the end of the string. You will need to escape the interior ' with \' See ?Quotes for details. On Tue, Jul 18, 2017 at 12:48 PM, Christofer Bogaso wrote: > Hi again, > > Let say I have below string (ar

Re: [R] Hunting a histogram variant

2017-06-21 Thread Richard M. Heiberger
Two things to look at are ?monthplot which shows seasonal subseries plotted on an overall plot. The parallel to your example is small histograms plotted on an overall plot. That goes back (through the reference in the Blue Book (Becker, Chambers, and Wilks)) to Bill Cleveland and Irma Terpenning i

Re: [R] Tukey tests in two-way ANOVA

2017-05-15 Thread Richard M. Heiberger
you have only one df for site and one df for year. most likely you skipped the step of telling R those are factors. On Mon, May 15, 2017 at 1:40 PM, Lucy McMahon wrote: > R-help: > > I'm looking into the abundance of an algal species over site and years using > a two-way ANOVA: > >> summary (ao

Re: [R] I cannot run R.EXE or RSCRIPT.EXE

2017-05-05 Thread Richard M. Heiberger
Try the 8.3 version of the path name. dir /w if I remember correctly. "Program files" will become progra~1 On Fri, May 5, 2017 at 06:46 Michael Dewey wrote: > Dear Dominik > > Try this > Open a command window > Type PATH > Does the path to where R has stored its executables appear on the P

Re: [R] Interesting quirk with fractions and rounding / using == for floating point

2017-04-23 Thread Richard M. Heiberger
the link from the FAQ A discussion with many easily followed examples is in Appendix G "Computational Precision and Floating Point Arithmetic", pages 753-771 of _Statistical Analysis and Data Display: An Intermediate Course with Examples in R_, Richard M. Heiberger and Bu

Re: [R] Unknown anomaly

2017-04-18 Thread Richard M. Heiberger
This is the standard behavior of floating point arithmetic on a digital computer. Computers use 53-bit finite precision arithmetic. They do not use infinite precision real numbers. Please see FAQ 7.31 for details. The FAQ is in the R documentation on your computer in file system.file("../../do

Re: [R] Strip height in latticeExtra:::useOuterStrips

2017-04-17 Thread Richard M. Heiberger
You had a typo. library(latticeExtra) Try this. I am solving what I think is a problem related to yours. I set it up as a three-way plot instead of pasting two of the measures together. ## install.packages("HH") ## if necessary library(HH) tmp <- xyplot(x ~ d | a*b*c, data = df2, par.se

Re: [R] problems in vectors of dates_times

2017-04-07 Thread Richard M. Heiberger
Don asks a good question. Here is the analogy from the grid package. > library(grid) > unit(12, "in") [1] 12in > unit(12, "cm") [1] 12cm > unit.c(unit(12, "in"), unit(12, "cm")) [1] 12in 12cm > c(unit(12, "in"), unit(12, "cm")) [1] 12 12 > ?unit > convertUnit(c(unit(12, "in"), unit(12, "cm")), "i

Re: [R] customize labels useOuterStrips lattice

2017-03-30 Thread Richard M. Heiberger
## I find it easiest to change the "trellis" object. ## assign the result of your useOuterStrips() call to an object name, for example myplot <- useOuterStrips( ... ) ## then names(myplot) myplot$condlevels myplot$condlevels$target <- c("much","more","interesting","names","here") myplot$con

Re: [R] Way to Plot Multiple Variables and Change Color

2017-03-28 Thread Richard M. Heiberger
> default values. How can this be done? > > Kind regards > > Georg > > > > > Von:"Richard M. Heiberger" > An: g.maub...@weinwolf.de, > Kopie: r-help > Datum: 28.03.2017 17:40 > Betreff:Re: [R] Way to Plot Multiple Variables and Chan

Re: [R] Way to Plot Multiple Variables and Change Color

2017-03-28 Thread Richard M. Heiberger
I think you are looking for the likert function in the HH package. >From ?likert Diverging stacked barcharts for Likert, semantic differential, rating scale data, and population pyramids. This will get you started. Much more fine control is available. See the examples and demo. ## install.pa

Re: [R] Presentation Quality Tables, e.g., Ten rows, Five columns, with nice headers

2017-03-26 Thread Richard M. Heiberger
I will assume that a "quality table" is a LaTeX tabular environment, possibly with some nested row or column structures. For that I recommend the latex function in the Hmisc package. The examples in ?latex are simple. Quite complex structures, for example, with nested sets of labled rows and col

Re: [R] nested structure for Ancova

2017-03-12 Thread Richard M. Heiberger
I think you need either mod4 <- lm( y ~ -1 + area / (month*group), data=two) mod5 <- lm( y ~ area / (month*group), data=two) With either of those, area:month and area:group and Residuals add up. On Sun, Mar 12, 2017 at 10:39 li li wrote: > Hi All, > I have a dataset which contains 4 varia

Re: [R] Matrix

2017-03-06 Thread Richard M. Heiberger
## 1. ## This could be captured into a function tmp <- matrix(0, 7, 4) tmp diag(tmp) <- 1 diag(tmp[-1,]) <- 2 diag(tmp[-(1:2),]) <- 3 diag(tmp[-(1:3),]) <- 4 tmp ## 2. v <- 1:4 v2 <- c(v, rep(0, length(v))) ## this generates a warning that can safely be ignored (or turned off) matrix(v2, length(

Re: [R] Problems outputting ggplot2 graphics to pdf

2017-03-02 Thread Richard M. Heiberger
You need the print() statement. See FAQ 7.22 in file system.file("../../doc/FAQ") 7.22 Why do lattice/trellis graphics not work? == The most likely reason is that you forgot to tell R to display the graph. Lattice functions such as 'xyplot()' create

Re: [R] Reading S-plus data in R

2017-02-26 Thread Richard M. Heiberger
Bill, this looks good. Can you add it to the splus2R package? Rich On Sun, Feb 26, 2017 at 11:57 AM, William Dunlap via R-help wrote: > You should be looking for foreign::data.restore, not data.dump nor read.S. > > In any case, I think that foreign::data.restore does not recognize S-version4

Re: [R] Vertical boxplot with a continuous X axis

2017-02-23 Thread Richard M. Heiberger
Yes, this is exactly what the panel function panel.bwplot.intermediate.hh along with the position() function in the HH package was designed for. Continuing with the example in the linked stackoverflow df <- structure(list(X1 = c(67.0785968921204, 45.5968692796599, 36.9528452430474, 59.016

Re: [R] Is a list an atomic object? (or is there an issue with the help page of ?tapply ?)

2017-02-14 Thread Richard M. Heiberger
The problem with Bert's second example is that sum doesn't work on a list. The tapply worked correctly. > unlist(l[1:5]) [1] 1 2 3 4 5 > sum(l[1:5]) Error in sum(l[1:5]) : invalid 'type' (list) of argument On Tue, Feb 14, 2017 at 8:28 PM, Bert Gunter wrote: > Hervé: > > Kindly explain this, t

Re: [R] graphical behavior of a table of numbers

2017-01-30 Thread Richard M. Heiberger
labels, and I think it therefore not a good example. I recommend revising it, perhaps to old.oma <- par(oma=c(6,1,0,1)); plot(table(state.division), las=2, mgp=c(.5,2,0)) par(old.oma) I agree the code for the legible labels is difficult to read. Rich On Mon, Jan 30, 2017 at 10

Re: [R] graphical behavior of a table of numbers

2017-01-30 Thread Richard M. Heiberger
terminant", ylab="Frequency") > >>> > >>> However, I'm no less puzzled by the "strange" behavior than you. > >>> > >>> In addition, it's probably worth noting that xyplot in lattice (and no > >>

[R] graphical behavior of a table of numbers

2017-01-28 Thread Richard M. Heiberger
## This example is from R-intro.pdf page 21 (R-3.3.2) d <- outer(0:9, 0:9) fr <- table(outer(d, d, "-")) plot(as.numeric(names(fr)), fr, type="h", xlab="Determinant", ylab="Frequency") ## The y-axis tick marks are at c(-21,24,65). ## This seems to be because class(fr) == "table" ## Sw

Re: [R] selecting colors to be used in a plot

2017-01-25 Thread Richard M. Heiberger
This package uses a nonstandard name colorset. This is based on the help example for ?charts.PerformanceSummary > data(edhec) > charts.PerformanceSummary(edhec[,c(1,13)]) > charts.PerformanceSummary(edhec[,c(1,13)], colorset=c("red","blue")) > On Wed, Jan 25, 2017 at 12:44 PM, Bos,

Re: [R] non-numeric argument to binary operator

2017-01-20 Thread Richard M. Heiberger
It looks like you are attempting to divide a number by a formula. > 5 / (a ~ b) Error in 5/(a ~ b) : non-numeric argument to binary operator On Fri, Jan 20, 2017 at 12:18 PM, Zeki ÇATAV wrote: > Hi, > I'm working on following dataset. > > > > dput(uu5) > structure(list(grup = structure(c(1L, 1

Re: [R] Superscript in graph text

2017-01-18 Thread Richard M. Heiberger
x <- 10 plot(1:10, main=bquote(R^2 * "=" * .(x))) On Wed, Jan 18, 2017 at 8:00 PM, Richard M. Heiberger wrote: > ?plotmath > > > plot(1:10, main=expression(R^2)) > > plot(1:10, main=bquote(R^2 * "=" * .(x))) > > On Wed, Jan 18, 2017 at

Re: [R] Superscript in graph text

2017-01-18 Thread Richard M. Heiberger
?plotmath plot(1:10, main=expression(R^2)) plot(1:10, main=bquote(R^2 * "=" * .(x))) On Wed, Jan 18, 2017 at 7:44 PM, Jake William Andrae wrote: > Hello, > > > I've added some statistical information as text to some graphs, but I'm > having a really hard time making the 2 in the R2 label supe

Re: [R] what is f_eval? It has broken the HH package

2017-01-13 Thread Richard M. Heiberger
That solved it. Thank you. On Fri, Jan 13, 2017 at 6:27 AM, Duncan Murdoch wrote: > On 13/01/2017 12:46 AM, Richard M. Heiberger wrote: >> >> I am preparing for the new semester and have downloaded and installed >> R-3.3.2 for Macintosh and Windows, and then t

[R] what is f_eval? It has broken the HH package

2017-01-12 Thread Richard M. Heiberger
I am preparing for the new semester and have downloaded and installed R-3.3.2 for Macintosh and Windows, and then the HH package and its dependencies for both. Everything fresh off CRAN. All works correctly on the Macintosh. On the Windows 10 I am getting an error > library(HH) Loading required p

Re: [R] About populating a dataframe in a loop

2017-01-06 Thread Richard M. Heiberger
Incrementally increasing the size of an array is not efficient in R. The recommended technique is to allocate as much space as you will need, and then fill it. > system.time({tmp <- 1:5 ; for (i in 1:1000) tmp <- rbind(tmp, 1:5)}) user system elapsed 0.011 0.000 0.011 > dim(tmp) [1] 1001

Re: [R] Generating a Special Histogram

2017-01-05 Thread Richard M. Heiberger
I recommend the stem function. > stem(wt) The decimal point is 1 digit(s) to the right of the | 12 | 57 14 | 4902479 16 | 1233444349 18 | 002507 > stem(wt, 2) The decimal point is 1 digit(s) to the right of the | 13 | 57 14 | 49 15 | 02479 16 | 1233444 17 | 349 18 | 00

Re: [R] stacked and dodged bar graph ggplot

2016-12-30 Thread Richard M. Heiberger
I reproduced your graphs, but I don't understand what you want instead. There are several problems. one group is spelled "Lantinx". your factor statements mostly lead to NA values. The two panels of the plot do not use the same number of inches of the plotting window, due to different widths

Re: [R] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Richard M. Heiberger
I think the intended appearance is closer to this xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width, iris, type = c("p", "r"), jitter.x = TRUE, jitter.y = TRUE, factor = 5, key = list(between=c(-4.5), column=4, text=list(lab=paste0(" ", letters[1:4], "

Re: [R] How to overlay lines and rectangles in lattice plot key

2016-12-28 Thread Richard M. Heiberger
Yes, but it will probably require work. I think you will need to write a grob that does what you want and then use the grob in a legend statement in the xyplot. Start with the 'legend' argument to xyplot (about line 940 in ?xyplot). You will probably need to work directly with grid functions and

Re: [R] Why Does R Print out strange record?

2016-12-19 Thread Richard M. Heiberger
You have read your Date variable in as a character variable, which was coerced to a factor. You probably wanted the values to be interpreted as dates. example of what to do is below. Note that the date-factor levels are sorted alphabetically, which is almost certainly not what you want. In additi

Re: [R] LaTeX errors when creating PDF version.

2016-12-06 Thread Richard M. Heiberger
The specific error message you are getting says that there are non-ASCII characters in one of your .Rd files. You can locate them with the tools::showNonASCII function. library(tools) ?showNonASCII Replace them with ASCII characters and the packaging should work. If you really need the non-ASCI

Re: [R] Interpreting summary.lm for a 2 factor anova

2016-12-04 Thread Richard M. Heiberger
As Petr Pikal mentioned, the difficulty in interpretation is entirely due to the set of contrasts you chose.The default treatment contrasts are not orthogonal and are therefore the most difficult to interpret. The note in ?aov warns of this difficulty. sum contrasts will give you numbers that are

Re: [R] i am trying to teach myself R

2016-12-02 Thread RICHARD M. HEIBERGER
I will recommend my book. http://www.springer.com/us/book/9781493921218 Sent from my iPhone > On Dec 2, 2016, at 11:07, peter dalgaard wrote: > > Also notice that there are relatively inexpensive books. Mine and Bob > Muenchen's for instance, which tackle your situation from somewhat differen

Re: [R] confidence intervals for orthogonal contrasts

2016-12-01 Thread Richard M. Heiberger
James, Please look at the maiz example, the last example in ?MMC help("MMC", package="HH") where I show how to construct and calculate a set of orthogonal contrasts for a factor in an analysis of variance setting. mmc and mmcplot use glht in the multcomp package for the underlying calculations.

Re: [R] Command for simple effects following 2 way anova with interaction

2016-11-30 Thread Richard M. Heiberger
## Use the split argument to summary.aov ## This tests the levels of tension within each level of wool using a common ## Residuals sum of squares. sapply(warpbreaks, levels) model2 <- aov(breaks ~ wool/tension, data = warpbreaks) colnames(model.matrix(model2)) ## [1] "(Intercept)""woolB"

Re: [R] Vectorization in a random order

2016-11-10 Thread Richard M. Heiberger
nBuyMat <- data.frame(matrix(rnorm(28), 7, 4)) nBuyMat nBuy <- nrow(nBuyMat) sample(1:nBuy, nBuy, replace=FALSE) sample(1:nBuy) sample(nBuy) ?sample apply(nBuyMat[sample(1:nBuy,nBuy, replace=FALSE),], 1, function(x) sum(x)) apply(nBuyMat[sample(nBuy),], 1, function(x) sum(x)) The defaults for sa

Re: [R] a book recommendation, please [O/T]

2016-11-08 Thread Richard M. Heiberger
It depends what "Data Analytics" means. Is it more or less, or just a synonym, for "Statistics"? My book, "Statistical Analysis and Data Display: An Intermediate Course with Examples in R" 2nd edition, Springer 2015 could support about half of a Design of Experiments course for MS in Statistics.

Re: [R] [FORGED] lattice: control panel extent on device

2016-10-25 Thread Richard M. Heiberger
I think this is simpler. vol_p2 <- vol_p vol_p2$legend <- NULL print(update(vol_p2, scales=list(y=list(labels=FALSE))), split = c(1, 2, 1, 2), more = TRUE) draw.colorkey(vol_p$legend$right$args$key, draw=TRUE, vp=viewport(y=.27, height=.26, x=.75)) print(update(xy_p, scales=list(y=list(labels=FALS

Re: [R] How to use predict() so that one retains the rows that they're associated with?

2016-10-20 Thread Richard M. Heiberger
I believe you have missing values and therefore you need to use the argument glm(formula, data, na.action=na.exclude, ...) ?na.exclude The relevant line is when 'na.exclude' is used the residuals and predictions are padded to the correct length by inserting 'NA's for cases omitted

<    1   2   3   4   5   6   7   8   9   >