Displaying 20 results from an estimated 6000 matches similar to: "kmeans: number of cluster centres must lie between 1 and nrow(x)"
2011 Jan 29
1
Spare matrix multiplication
Dear R,
I have a simple question concerning with a special case of spare matrix
multiplications. Say A is a 200-by-10000 dense matrix. B is a 10000-by-10000
block- diagonal matrix, and each diagonal block B_i is 100-by-100. The usual
way I did A%*%B will take about 30 seconds which is to time consuming
because I have to do this thousands of times. I also tried to partition A
into 100 small blocks
2013 Jan 14
2
The three-dot question
Dear all,
Why does not the three-dot accept arguments from the parent environment?
I am just confused with this error, can someone give me a hint?
> rm(list=ls())
> testFun <- function(a, ...)
+ {
+ if(a){
+ print(a)
+ }else
+ {
+ print(b)
+ }
+ }
>
> myTask <- function(a)
+ {
+ b <- 3
+ testFun(a, b = b)
+ }
>
2011 Jan 12
2
How to disable using "enter" key to exit the browser in debugging mode
Dear R,
How can I disable using "enter" key to exit the browser() in debug mode? I
would love to have this option because it is so annoying to jump out of the
debugging mode unexpectedly when I don't want to. I guess some of us have
encouraged at least one of these situations,
1, Accidentally pressed the enter key within the browser.
2, Copy and paste a piece of debugging code
2011 Jan 18
2
Convert a matrix's columns to list
Dear R,
Is there an efficient way to make a list that each element is from the
corresponding column of a matrix. For example, if I have a matrix "a"
> a <- matrix(1:10, 5, 2)
> a
[,1] [,2]
[1,] 1 6
[2,] 2 7
[3,] 3 8
[4,] 4 9
[5,] 5 10
I would like to have a list "b" like this
> b <- list(a[, 1], a[, 2])
> b
[[1]]
[1] 1 2 3
2010 Oct 12
1
lapply to subsets
Dear R,
I have a silly question concerns with *apply. Say I have a list called A,
A <- list(a = array(1:20, c(2, 2, 5)), b = array(1:30, c(2, 3, 5)))
I wish to calculate the mean of A$a, and A$b w.r.t. their third dimension so
I did
lapply(A,apply,c(1,2),mean)
Now if I still wish to do the above task but take away some burn-in, e.g. do
not take A$a[,,1:2],and A$b[,,1:2] into account.
2009 Nov 05
2
rm(list<-ls()) error
Dear R,
Why rm(list<-ls()) gives an error but rm(list=ls()) not?. I remember the
operator ‘<-’ can be used anywhere...
Thanks!
Feng
--
Feng Li
Department of Statistics
Stockholm University
106 91 Stockholm, Sweden
http://feng.li/
[[alternative HTML version deleted]]
2010 Jan 05
1
R-package related to the topic of INARMA models
Dear R,
I am looking for R-package related to INARMA (Integer-valued ARMA). Can
anyone give me some information? I did not get information from task view.
Many thanks.
Feng
--
Feng Li
Department of Statistics
Stockholm University
106 91 Stockholm, Sweden
http://feng.li/
[[alternative HTML version deleted]]
2010 Sep 24
3
boundary check
Dear R,
I have a covariates matrix with 10 observations, e.g.
> X <- matrix(rnorm(50), 10, 5)
> X
[,1] [,2] [,3] [,4] [,5]
[1,] 0.24857135 0.30880745 -1.44118657 1.10229027 1.0526010
[2,] 1.24316806 0.36275370 -0.40096866 -0.24387888 -1.5324384
[3,] -0.33504014 0.42996246 0.03902479 -0.84778875 -2.4754644
[4,] 0.06710229 1.01950917
2011 Mar 23
1
R gui problem for windows
Dear R,
I rare use the standard R-gui on Windows. Yesterday I tried the latest
stable release on Windows 7 and XP and found one thing interesting. Assume
currently I am running R code, say
> example(plot)
Then I click the "close window" button on the R main window. R asks me to
save workspace image or not. Then I click "cancel". I suspect that my
program
2009 Feb 11
5
How to handle large numbers?
Dear R,
I have two questions:
1, Why both R and Matlab give 0*Inf==NaN? To my knowledge, it should be zero
mathematically. Am I right?
2, I need to calculate e.g. exp(a)/(exp(b)+c), where both a and b are very
large numbers (>>1000, e.g a=1000, b=1007, and c=5). R gives me NaN when I
use the following command:
> exp(1000)/(exp(1007)+5)
[1] NaN
I am pretty sure this should be close to
2005 Mar 31
2
Using kmeans given cluster centroids and data with NAs
Hello,
I have used the functions agnes and cutree to cluster my data (4977
objects x 22 variables) into 8 clusters. I would like to refine the
solution using a k-means or similar algorithm, setting the initial
cluster centres as the group means from agnes. However my data matrix
has NA's in it and the function kmeans does not appear to accept this?
> dim(centres)
[1] 8 22
> dim(data)
2011 Mar 16
2
Singularity problem
Dear R,
If I have remembered correctly, a square matrix is singular if and only if
its determinant is zero. I am a bit confused by the following code error.
Can someone give me a hint?
> a <- matrix(c(1e20,1e2,1e3,1e3),2)
> det(a)
[1] 1e+23
> solve(a)
Error in solve.default(a) :
system is computationally singular: reciprocal condition number = 1e-17
Thanks in advance!
Feng
--
2010 Sep 13
2
How to generate a particular sequence ?
Dear R,
I have a vector, say a = c(1,2,4,5,6,8). Can I generate a vector or array
(2-by-3-by-3) of this form c(1,2,1,2,1,2,4,5,4,5,4,5,6,8,6,8,6,8), in which
every two elements in "a" have been repeated twice?
I am to stupid today and could not figure this simple question out... Many
many thanks!
Feng
--
Feng Li
Department of Statistics
Stockholm University
106 91 Stockholm,
2010 Sep 07
4
a^c(1:3)
Dear R,
I have two small questions confused me recently. Now assume I have a matrix
"a", like this,
> a <- matrix(1:6, 2, 3)
> a
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2 4 6
I sometimes need each row of "a" raised to a different exponent. So I do a
trick like this,
> a^c(2, 3)
[,1] [,2] [,3]
[1,] 1 9 25
[2,] 8 64 216
My first
2011 Feb 26
1
Wired behavior of a 2-by-2 matrix indicies
Dear R,
I found a very wired behavior for a 2-by-2 matrix, see this example
> A <- matrix(1:4, 2)
> idx4A <- matrix(1:4, 2)
> A[idx4A]
Error in A[idx4A] : subscript out of bounds
But other matrices are fine,
> B <- matrix(1:9, 3)
> idx4B <- matrix(1:9, 3)
> B[idx4B]
[1] 1 2 3 4 5 6 7 8 9
I can reproduce this for both 32bit windows and 64bit linux with R 2.12.1
2000 Dec 29
1
Cisco
I''m sorry to posting this message in this list, but it''s the only
way iI found.
Who known a mailing list telling about the cisco''s router?
--
____________________________________________________________
PIII 500MHz - 96MB RAM - HD 8.2GB - Diamond Stealth III s540
USR Sportster 56K Int Voice - SoundBlaster AWE 64 -- CL 6
//LinuxMan by Friends - The power of a GNU
2004 May 28
6
distance in the function kmeans
Hi,
I want to know which distance is using in the function kmeans
and if we can change this distance.
Indeed, in the function pam, we can put a distance matrix in
parameter (by the line "pam<-pam(dist(matrixdata),k=7)" ) but
we can't do it in the function kmeans, we have to put the
matrix of data directly ...
Thanks in advance,
Nicolas BOUGET
2009 Feb 04
3
Passing data among multiple instances
Dear R,
I have two R instances running at the same time, say instance A and instance
B. Is there a simpler way to pass the data in A to B?
More precise, I have a stupid example:
In instance A, I am running a function "test1"
test1 <- function (x1)
{
x2 <- sin(x1)
return(x2)
}
In instance B, another function "test2"
test2 <- function (x2)
{
x3 <-
2006 Jul 09
2
distance in kmeans algorithm?
Hello.
Is it possible to choose the distance in the kmeans algorithm?
I have m vectors of n components and I want to cluster them using kmeans
algorithm but I want to use the Mahalanobis distance or another distance.
How can I do it in R?
If I use kmeans, I have no option to choose the distance.
Thanks in advance,
Arnau.
2013 Mar 13
1
Empty cluster / segfault using vanilla kmeans with version 2.15.2
Hello,
here is a working reproducible example which crashes R using kmeans or
gives empty clusters using the nstart option with R 15.2.
library(cluster)
kmeans(ruspini,4)
kmeans(ruspini,4,nstart=2)
kmeans(ruspini,4,nstart=4)
kmeans(ruspini,4,nstart=10)
?kmeans
either we got empty always clusters and or, after some further commands
an segfault.
regards,
Detlef Groth
------------
[R] Empty