Displaying 20 results from an estimated 38 matches for "stanleyngkl".
2008 Feb 13
3
indices of rows containing one or more elements >0
Hi,
Given test <- matrix(c(0,2,0,1,3,5), 3,2)
> test[test>0]
[1] 2 1 3 5
These are values >0
> which(test>0)
[1] 2 4 5 6
These are array indices of those values >0
> which(apply(test>0, 1, all))
[1] 2
This gives the row whose elements are all >0
I can't seem to get indices of rows containing one or more elements >0
[[alternative HTML version deleted]]
2008 Mar 13
2
How to cbind or rbind different lengths vectors/arrays without repeating the elements of the shorter vectors/arrays ?
Hi,
How to cbind or rbind different lengths vectors/arrays without repeating the
elements of the shorter vectors/arrays ?
> cbind(1:2, 1:10)
[,1] [,2]
[1,] 1 1
[2,] 2 2
[3,] 1 3
[4,] 2 4
[5,] 1 5
[6,] 2 6
[7,] 1 7
[8,] 2 8
[9,] 1 9
[10,] 2 10
[[alternative HTML version deleted]]
2008 Apr 14
2
how to write a table to pdf
Hi,
Is there a way to write a table to pdf ? I have checked write.table, it only
writes to text file.
[[alternative HTML version deleted]]
2008 Apr 26
2
3 questions: debug R script, multi-level sorts, and multi-gsub
Hi,
1) I ran a script say test.R. It ran and terminated with an error. However,
I am not sure where the error occur.
> source("test.R")
Loading required package: tools
Welcome to Bioconductor
Vignettes contain introductory material. To view, type
'openVignette()'. To cite Bioconductor, see
'citation("Biobase")' and for packages
2008 Feb 01
1
Cannot save histogram picture when run from script
Hi,
I am faced with a strange problem. My picture file is empty when the
following statements were run from R script. But the picture file shows up
correctly, when the commands are individually run from Rgui.
png(file="histogram_correlation.png", bg = "white")
require(stats)
histogram( ~ height | voice.part, data = singer, nint = 17,
endpoints = c(59.5, 76.5),
2008 Feb 01
1
problem getting multiple densityplots on one page
Hi,
I used the following statements to generate unsuccessfully a 5 by 5 multiple
densityplots on a single page. If I use plot, the whole thing works.
> data <- matrix(rnorm(25), 5, 5)
> op <- par(mfrow = c(5, 5))
> for (x in 1:5) {densityplot(data[,x])}
> par(op)
Thanks
Stanley
[[alternative HTML version deleted]]
2008 Feb 06
1
error message from apply()
Hi,
I keep getting the error message. Please help.
Error in colMeans(x, na.rm = TRUE) : 'x' must be an array of at least two
dimensions
The codes are:
data2_1 <- matrix(c(0.9584190, 0.2710325, -0.9495618, -0.1301772, -0.7539687,
0.5344464, -0.8205933, 0.1581723, -0.5351588, 0.04448065, 0.9936430,
0.2278786, -0.8160700, -0.3314779, -0.4047975, 0.1168152, -0.7458182, -
0.2231588,
2008 Feb 14
1
How to check cy5 and cy3 values were lowess normalized
Hi,
I have some microarray data, cy5 and cy3 values are in log2. Is there a
way to check they have undergone lowess normalization ?
Thanks
Stanley
[[alternative HTML version deleted]]
2008 Mar 08
1
how to compute uncentered (pearson correlation) correlation efficiently
Hi,
Seeking suggestions to compute uncentered (pearson correlation) correlation
efficiently.
corr from stats library works on x and y columns. dist from amap library
works on x and y rows.
My data layout is slightly different such that row(i) of matrix x is
compared to row(i) of matrix y.
Thanks
[[alternative HTML version deleted]]
2008 Mar 11
1
How to generate column names for pairwise comparison
Hi,
Given names <- c("a", "b", "c", "d"). I would like to generate "a vs. b", "a
vs. c", "a vs. d", "b vs. c", "b vs. d", "c vs. d"
Thanks
[[alternative HTML version deleted]]
2008 Mar 11
1
How to generate a vector of counts i.e. the number of rows that are contiguous
Hi,
I have a 3 columns data and need to generate a vector of counts. These
counts are the number of rows that are contiguous. It looks easy for manual
counting, but to turn it algorithmic really split my head.
For example, 11 (i.e. 18004 to 180014), 1 (i.e., 18017), 7 (i.e., 18060 to
18064)
18004 10314568 0.5205757
18005 10333837 0.5135572
18006 10566333 0.5111271
18007 10566624 0.8196611
2008 Mar 13
2
How to manipulate data according to groups ?
Hi,
I have a two columns data, the first column are values, and second column
are the groups. For this example, there are 3 groups 1,2,3.
How can I manipulate the values in the first column according to groups, say
I would like to find mean, sum, and standard deviation for the different
groups ? How do I plot data according to groups ?
> t <- matrix(c(rnorm(10), 1,1,2,2,1,3,3,3,3,2),
2008 Mar 20
1
conditional matching of rows of tables
Hi,
Given matrix A of 4 cols.
1 a 0 4
1 b 5 8
2 a 0 3
2 b 4 7
I have another matrix B of 3 cols. How to assign (a or b) to the rows such
that in each row its 1st value must match the 1st col. of A, 2nd and 3rd
values must lie between 3rd and 4rd cols (inclusive) of A
1 2 3 -> a
2 4 5 -> b
2 0 3 -> a
1 7 8 -> b
[[alternative HTML version deleted]]
2008 Apr 16
1
What objects will save.image saves ? And how to specify objects to be saved..
Hi,
I have a R script that loads an image R.data, does some operations, then
save to the R.data again. Suppose I have done some computation before
loading the R script, will all the objects before the R script execution be
saved to R.data ? If yes, how can I specify save.image to save only those
objects created in the R script ?
Thanks
Stanley
[[alternative HTML version deleted]]
2008 Jan 31
1
Bug with hist() ?
Hi,
Is this a bug from hist() ? The total density is greater than 1.
> test
[1] 0.05077802 -0.50585520 -0.98053648 -0.35513059 0.86767129 0.61736097
[7] 0.14264062 0.26243841 -0.41477782 0.64172618 0.87230953 -0.62570629
[13] 0.43596467 -0.93214106 -0.26781599
> h <- hist(test, freq = FALSE, main="Histogram of correlation", ylab =
"Frequency", xlab =
2008 Jan 29
2
add/subtract matrices, ignoring NA or missing values
Hi,
For example, given two 2x2 matrices m1 and m2. I would like to add/subtract
element by element
> m1
[,1] [,2]
[1,] NA NA
[2,] 1 2
> m2
[,1] [,2]
[1,] 1 NA
[2,] NA 2
> m1 + m2
[,1] [,2]
[1,] NA NA
[2,] NA 4
How can I ignore the NA, and get this ? Hope the solution can be extended to
subtract and modulo also.
[,1] [,2]
2008 Feb 05
2
How to generate table output of t-test
Hi,
Given
test <- matrix(c(1, 1,2,2), 2,2)
t <- apply(test, 1, t.test)
How can I obtain a table of p-values, confidence interval etc, instead of
[[1]]
One Sample t-test
data: newX[, i]
t = 3, df = 1, p-value = 0.2048
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
-4.853102 7.853102
sample estimates:
mean of x
1.5
[[2]]
2008 Feb 11
4
Conditional rows
Hi,
Given a simple example, test <- matrix(c(0.1, 0.2, 0.1, 0.2, 0.1, 0.1, 0.3,
0.1, 0.1), 3, 3)
How to generate row indexes for which their corresponding row values are
less than or equal to 0.2 ? For this example, row 2 and 3 are the correct
ones.
Thanks
[[alternative HTML version deleted]]
2008 Feb 04
3
counts of each column that are not NA, and/or greater than column means
Hi,
Given a test matrix, test <- matrix(c(1,2,3,NA,2,3,NA,NA,2), 3,3)
A) How to compute the counts of each column (excluding the NA) i.e., 3, 2, 1
B) How to compute the counts of each column (excluding the NA) that are
greater than the column means ? i.e., 1, 1, 0
I could write a for loop, but hope to use better alternative.
[[alternative HTML version deleted]]
2008 Feb 11
0
Testing for differecnes between groups, need help to find the right test in R. (Kes Knave)
...would like to
> use the computed result as an input for R to just draw the dendrogram.
>
> As I'm new to R any help is appreciated.
>
> Thanks,
> Risto
>
------------------------------
Message: 60
Date: Mon, 11 Feb 2008 18:22:09 +0800
From: "Ng Stanley" <stanleyngkl at gmail.com>
Subject: [R] Conditional rows
To: r-help <r-help at r-project.org>
Message-ID:
<462b7fdd0802110222x65accc33v1dbe43cb69227743 at mail.gmail.com>
Content-Type: text/plain
Hi,
Given a simple example, test <- matrix(c(0.1, 0.2, 0.1, 0.2, 0.1, 0.1,
0.3,
0.1, 0.1), 3,...