Displaying 20 results from an estimated 10000 matches similar to: "Inconsistent handling of data frames in min(), max(), and mean()"
2009 Jul 13
1
Add grand mean to every entry in a matrix
Hi,
I have a matrix:
mymat <- matrix(runif(10*4), ncol=4)
I wish to subtract the column means, down the colums, subtract the row means from the rows and add back the grand mean - all the means should be the means of mymat rather than of the new matrix.
How can I do this?
Any help much appreciated.
Thanks
Tom
_________________________________________________________________
2007 Nov 26
1
mvr error in PLS package
All,
I have been using a data set to build pls models for three different soil properties. Two of the three models run fine; however I receive the following error for the final model.
> libs.IC.cal <- mvr(libs.IC.fmla, data = libsdata.cond.cal, ncomp=20,validation = "LOO", method = "oscorespls")
Error in colMeans(x, n, prod(dn), na.rm) :
'x' must
2005 Jan 11
1
Please use colMeans()! was: Re: Calculate Mean of Column Vectors?
There are indeed speed advantages in using colSums etc. However the disadvantage is that the newbie doesn't always find the power inherent in the apply, sapply, tapply and mapply. For many things that I do, the speed is the least of my worries; although I take the point that using apply for means or sums in packages that are distibuted to others is not the way to go.
As many of us have found
2011 Apr 05
1
Inconsistency between rowMeans documentation and reality?
Dear List,
I'm not even sure this is an issue or not, but ?rowMeans has:
Value:
A numeric or complex array of suitable size, or a vector if the
result is one-dimensional. The ?dimnames? (or ?names? for a
vector result) are taken from the original array.
If there are no values in a range to be summed over (after
removing missing values with ?na.rm = TRUE?), that
2007 Jan 25
3
?mean
The help page for mean does not say what happens when one
applies mean to a matrix.
mean and sd work in an inconsistent way on a matrix
so that should at least be documented.
Also there should be a See Also to colMeans since that
provides the missing column-wise analog to sd.
2009 Mar 20
1
Mean-replacing NAs in a 3d array
Hi all
I have a 3d array containing missing values.
> Xa
, , 1
[,1] [,2]
[1,] 1 3
[2,] NA 4
, , 2
[,1] [,2]
[1,] 5 7
[2,] NA NA
, , 3
[,1] [,2]
[1,] 9 11
[2,] 10 12
I want to replace the missing values with the mean, but the mean of each
'page' in the array (wrong terminology I'm sure). So - for the array
above - [2,1,2] and
2018 Jan 30
1
Simulation based on runif to get mean
Hello,
Another way would be to use ?replicate and ?colMeans.
set.seed(2511) # Make the results reproducible
fun <- function(n){
f <- function(){
a <- runif(5, 1, 10)
b <- runif(5, 10, 20)
colMeans(cbind(a, b))
}
replicate(n, f())
}
fun(10)
Hope this helps,
Rui Barradas
On 1/30/2018 8:58 AM, Daniel Nordlund wrote:
> On 1/29/2018
2008 Mar 16
1
stats/debugging question hotelling t-sq
Hi
I spent hours looking over my formula. Somehow I cant find the reason
why it gives me different answer.
help appreciated.
x = as.matrix(read.table("http://www.niehs.nih.gov/research/atniehs/core/microarrays/docs/heinloth.txt",1))
x = t(x) #now rows are subjects, cols are genes
x = x[order(rownames(x)),] #order by treatment group oxygen,
ultra-violet, gamma radiation
y =
2004 Jun 07
3
error during make of R-patched on Fedora core 2
Dear list,
I've just upgraded to Fedora Core 2 and seeing as there wasn't an rpm
for this OS on CRAN yet I thought it was about time I had a go at
compiling R myself. Having run into the X11 problem I switched to trying
to install R-patched. I followed the instructions in the R Installation
& Admin manual to download the sources of the Recommended packages and
place the files in
2023 Apr 21
1
Generalised piping into operators
On 21/04/2023 4:35 a.m., Michael Milton wrote:
> I just checked out R-devel and noticed that the new "pipe extractor"
> capability coming in 4.3 only works for the 4 extractor operators, but no
> other standard operators like +, *, %*% etc, meaning that e.g. mtcars |>
> as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are
> still subject to
2012 Dec 08
3
Mean-Centering Question
Hello,
I'm trying to create a custom function that "mean-centers" data and can be
applied across many columns.
Here is an example dataset, which is similar to my dataset:
*Location,TimePeriod,Units,AveragePrice*
Los Angeles,5/1/11,61,5.42
Los Angeles,5/8/11,49,4.69
Los Angeles,5/15/11,40,5.05
New York,5/1/11,259,6.4
New York,5/8/11,187,5.3
New York,5/15/11,177,5.7
2005 Apr 01
2
Error in colMeans ... what's wrong with my data?
Having searched and searched I still haven't found what's the problem with my data (I've attached the relevant file).
Every time I tried to use the CANCOR-Function I got error messages.
So I turned to check my two sets of variables separately by using the "colMeans"-Function. With one set no problem .. but with the other.
My input :
> struktur <-
2012 May 09
5
Dotchart showing mean and median by group
Given this example
mean.values<-colMeans(VADeaths)
mean.values<-apply(VADeaths, 2, mean)
median.values<-apply(VADeaths, 2, median)
dotchart(VADeaths, gdata=mean.values)
dotchart(VADeaths, gdata=median.values)
is it possible to ?combine? a single dotchart showing both the mean and the
median for each single group (with different plotting symbols)?
?is it that possible with the use of
2005 Apr 06
2
make error in R devel
Dear list,
I just hit an error that stopped my make && make check-devel operation
on my linux box (FC3, i686 P4 2GB RAM). Just to note that I've been
building the development branch(?) for some time and this is the first
hint of a problem.
1) updated the src tree using svn update
2) ran ../configure --with-recommended-package=no from my build directory
3) got:
R is now configured
2013 Jan 16
1
Trouble building package using R in development
Dear List,
I'm having considerable trouble setting up my environment (Linux, Fedora
16, Bash) to build and check packages under R Under Development
(r61660). I'm doing this to better get a handle on difference in the
output from running checks on examples in one of my packages. Note I
compiled R Under Development myself
The problem I am now having is whenever I try to build my analogue
2023 Apr 21
1
Generalised piping into operators
I just checked out R-devel and noticed that the new "pipe extractor"
capability coming in 4.3 only works for the 4 extractor operators, but no
other standard operators like +, *, %*% etc, meaning that e.g. mtcars |>
as.matrix() |> _ + 1 |> colMeans() is a syntax error. In addition, we are
still subject to the restriction that the functions on the RHS of a pipe
can't have
2011 Mar 27
1
Bug in tools::compactPDF() in 2.13-0-alpha
Dear List,
There seems to be an bug in compactPDF() or at least an inconsistency
with the documented behaviour.
The documentations states:
Details:
This by default makes use of ?qpdf?, available from <URL:
http://qpdf.sourceforge.net/>, including a Windows binary. If
?gs_cmd? is non-empty, GhostScript is used.
I don't have qpdf on my system so planned to use
2013 Jan 16
1
R CMD check not reading R_LIBS from ~/.R/check.Renviron
Dear List,
Further to my earlier email, I note that, for me at least, R CMD check
is *not* reading R_LIBS from ~/.R/check.Renviron on R 2.15.2 patched
(r61228) and R Under Development (r61660). The only way I can get R CMD
check to look for packages in a user-supplied library is by explicitly
exporting R_LIBS set to the relevant directory.
R CMD build *does* read R_LIBS from ~/.R/build.Renviron
2008 Mar 27
2
colMeans in a data.frame with numeric and character data
Hi all,
I would like to know if it is posible by, someway, to get colMeans from
a data.frame with numeric as well as character data, dispersed all over
the object. Note that I would like to get colMeans neglecting character
data.
I am really in need of some function proceeding in that way…
All the best
Diogo André Alagador
[[alternative HTML version deleted]]
2005 May 04
1
Plotting means and confidence intervals by group factor using lattice graphics?
Dear R graphics gurus,
Another question about lattice graphics. This time I would like to plot
means and confidence intervals by group factor in a lattice graph. I can
not find any working lattice examples. Maybe a custom panel function is
the answer, but that is a bit beyond me for now.
The individual plots within the lattice graph could look like this:
# Example with confidence intervals