Displaying 20 results from an estimated 10000 matches similar to: "How to create a random matrix with conditions"
2011 Feb 24
3
problem in for loop
Hi all.
I was having some trouble with a for loop and I found the problem is the
following.
Does anyone have some idea why I got the following R result? Since mone
is equal to 3, why
mu1 only have 2 components?
library(MASS)
> p0 <- seq(0.1, 0.9,by=0.1)
> m <- 10
>
>
> p0 <- p0[7]
>
> ## data generation
>
> mzero <- p0*m
> mone <- m-mzero
>
2011 Nov 25
3
counting values with some conditions in a simulation
Dear R users,
I am running simulations (1000), and in my simulation I am looking at
specific sums. For example, if the sum is >=4 then count this, if say <3,
then don't count, if the sum=3, then generate a random number from uniform
distribution, if this number is say less than 0.5, then count this sum, if
greater than 0.5, then don't count. I am having trouble with introducing
this
2008 Jul 05
5
help about random generation of a Normal distribution of several variables
Hello.
Somebody knows how can I generate a set of n random vectors of a
normal distribution of several variables?
For example, I want to generate n=100 random vectors of two dimensions
for a normal with mean c(0,1) and variance matrix:
matrix(c(2,1,1,3),2,2).
Thanks in advance,
Arnau.
2013 Mar 08
2
Select rows from Data Frame with conditions
Hi all,
I have two dataframes. The first (A) contains all the stock prices for
today including today. So the first column is the stock Symbol and the
second column is the stock price. The second (B) is the symbol list in the
top 100 stocks.
I want to pick out from dataframe A only the rows containing the symbols
from B. i.e. something like:
prices <- A[A[,1]==B,2]
is there any
2007 Mar 16
1
ideas to speed up code: converting a matrix of integers to a matrix of normally distributed values
Hi all,
[this is a bit hard to describe, so if my initial description is
confusing, please try running my code below]
#WHAT I'M TRYING TO DO
I'd appreciate any help in trying to speed up some code. I've written
a script that converts a matrix of integers (usually between 1-10,000
- these represent allele names) into two new matrices of normally
distributed values (representing
2018 Mar 11
0
Empirical density estimation
On 3/11/2018 3:35 PM, Christofer Bogaso wrote:
> But for my reporting purpose, I need to generate a bell curve like
> plot based on empirical PDF, that also contains original points.
>
> Any idea would be helpful. Thanks,
>
Christofer,
something like the following may get you what you want:
## get the kernel density estimate
dens <- density(Dat)
## estimate the density at
2008 Aug 20
2
Random sequence of days?
Dear list,
I tried to find a solution for this problem from the archives but
couldn't find any. I would like sample sequence of ten days from
vector d
d <- seq(as.Date("2007-02-12"), as.Date("2008-08-18"), by="days")
so that the days follow each other (sample(d, 10) is not the
appropriate solution). Any ideas?
Best regards,
Lauri
2018 Mar 11
2
Empirical density estimation
But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.
Any idea would be helpful. Thanks,
On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote:
> You need to re-read ?density and perhaps think again -- or do some study --
> about how a (kernel) density estimate works. The points at
2012 Aug 23
1
Why was my R process killed spontaneously?
I tried to use gpuCor function in the gputools package of R to calcuate the
pairwise correlations of a matrix of 40,000 columns.
Becuase there would be memory issues if I use the whole matrix at a time, I
splitted the matrix into submatrix of 10,000 columns and then calculate the
pairwise correlation of different submatrices. There are altogether 4
submatrices, so I need to calculate the pearson
2012 May 06
3
correlation between XY coordinates
Hello r world,
Does anyone know a function or package that can compute correlations between sets of XY coordinates?
Thanks in advance for your help,
Chris
2011 May 07
1
generate multiple mvrnorm samples using apply-like
I want to generate multiple multivariate normal samples with different
mean vectors
and common covariance matrix.
I can do this with a loop, but can't quite figure out how to do it with
apply and friends.
In the example below, I want values to have 3 columns: group, x, y
# number of groups, and group means
x <- jitter(seq(2,10,by=2))
y <- x + rnorm(length(x), 0, .5)
means <-
2011 Jan 11
3
Generation of Normal Random Numbers
Dear R helpers
I have a data frame as given below
df = data.frame(A = c(776,827,836,995,855,1026,1203,1363,965,1195),
B = c(806,953,1049,1056,1243,764,1148,1162,948,1154),
C = c(959,1155,1193,1163,863,1070,1087,877,1132,944),
D = c(906,760,978,1170,1009,883,1007,960,828,113))
# Actually the real data has number of vectors and
2012 Apr 23
2
.rda vs. .RData
Are they the same with .RData being the newer format?? Thanks,
...Tao
2012 May 29
2
a question about "by" and "ddply"
Hi all,
I have a data set (df, n=10 for the sake of simplicity here) where I have two continuous variables (age and weight) and I also have a grouping variable (group, with two levels). I want to run correlations for each group separately (kind of similar to "split file" in SPSS). I've been experimenting with different functions, and I was able to do this correctly using ddply
2007 Dec 17
2
regression towards the mean, AS paper November 2007
Dear friends, regression towards the mean is interesting in medical
circles, and a very recent paper (The American Statistician November
2007;61:302-307 by Krause and Pinheiro) treats it at length. An initial
example specifies (p 303):
"Consider the following example: we draw 100 samples from a bivariate
Normal distribution with X0~N(0,1), X1~N(0,1) and cov(X0,X1)=0.7, We
then calculate
2007 Jun 12
4
Generating artificial datasets with a specific correlation coefficient.
I need to create artificial datasets with specific correlation
coefficients (i.e. a dataset that returns r = 0.30, etc.) as examples
for a lab I am teaching this summer. Is there a way to do that in R?
Thanks.
Jim Milks
Graduate Student
Environmental Sciences Ph.D. Program
136 Biological Sciences
Wright State University
3640 Colonel Glenn Hwy
Dayton, OH 45435
[[alternative HTML version
2013 Oct 10
1
Rcpp and mclapply
Dear all,
I have an R script that uses Rcpp, and I have been trying to parallelize
it using mclapply (I tried with the multicore and the parallel library)
Sometimes (not always, interestingly), the CPU use for each core drops,
usually so that the total over all cores reaches 100%, i.e., as fast as if
using just one single core fully. I tried my code directly from within
emacs, and also using a
2013 Oct 12
1
lmerTest
Hi,
I'm trying to user lmer function from lmerTest package because, if I
understood correectly, it allows to make better inference than lmer method
from lme4 package. However, whatever I do I keep getting this error:
Error in lme4::lFormula(formula = mark ~ ssCount + sTime+ : rank of X =
1660 < ncol(X) = 1895
any ideas what could be a problem?
thanks,
Srecko
[[alternative HTML
2012 Nov 11
2
Cropping a matrix by rows
Hello r-help,
I've been banging my head against the computer in an attempt to learn how
to divide my matrix into segments by rows. I want to be able to return each
segment as a newly named object. I've tried looking at the apply functions
and creating a for loop but brain no work. Here's the basic starting
objects that I believe would be needed to separate the matrix.
mat <-
2012 Jan 11
3
64bit R under 32bit winxp
Hi all:
My OS is 32bit winxp,but I wanna install 64bit R2.14.1.
>From the following website,it says "You can also go back and add 64-bit components to a 32-bit install, or vice versa"
http://cran.r-project.org/bin/windows/rw-FAQ.html#Can-both-32_002d-and-64_002dbit-R-be-installed-on-the-same-machine_003f
Does it mean that I can install and run 64bit R2.14.1 under 32bit