Displaying 20 results from an estimated 7000 matches similar to: "Monte Carlo Simulation"
2011 Apr 12
2
Converting a categorical variable to multiple dichotemous variables
I have a categorical variable in a dataframe similar to the following...
cat
1
1
3
2
4
I need to convert it to 4 dichotemous variables for each observations like...
cat1 cat2 cat3 cat4
1 0 0 0
1 0 0 0
0 0 1 0
0 1 0 0
0 0 0 1
Thanks in advance!
Shane
2011 Apr 11
1
Help on calculating a variable using random numbers
I'm new to R, but I'm trying to write a program for a dissertation that generates a dataset as follows...
subject=1:1000
treat=rbinom(1*1000,1,.13)
gender=rbinom(1*1000,1,.5)
eth=runif(1*1000, min=1, max=4)
cogat=rnorm(1*1000, 100, 16)
map=rnorm(1*1000, 200, 9)
simtest=data.frame (subject=subject, treat=treat, gender=gender, eth=round(eth,digits=0),
2012 Mar 29
1
Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame
Hello,
Let's say I've drawn a random sample (sample1.df) from a large data frame
(main.df), and I want to create a second random sample (sample2.df) where
the values in its ID column *are not* in the equivalent ID column in the
first sample (sample1.df). How would I go about doing this?
In other words:
The values in sample2.df$ID *are not found* in sample1.df$ID, and both
samples are
2012 Dec 04
2
computing marginal values based on multiple columns?
Hello all,
I have what feels like a simple problem, but I can't find an simple
answer. Consider this data frame:
> x <- data.frame(sample1=c(35,176,182,193,124),
sample2=c(198,176,190,23,15), sample3=c(12,154,21,191,156),
class=c('a','a','c','b','c'))
> x
sample1 sample2 sample3 class
1 35 198 12 a
2 176 176
2011 Sep 26
1
How to Store the executed values in a dataframe & rle function
Hi group,
This is how my test file looks like:
Chr start end sample1 sample2
chr2 9896633 9896683 0 0
chr2 9896639 9896690 0 0
chr2 14314039 14314098 0 -0.35
chr2 14404467 14404502 0 -0.35
chr2 14421718 14421777 -0.43 -0.35
chr2 16031710 16031769 -0.43 -0.35
chr2 16036178 16036237 -0.43 -0.35
chr2 16048665 16048724 -0.43 -0.35
chr2 37491676 37491735 0 0
chr2 37702947 37703009 0 0
2011 Aug 14
2
conditional filter resulting in 2 new dataframes
This is what I am starting with:
initial<- matrix(c(1,5,4,8,4,4,8,6,4,2,7,5,4,5,3,2,4,6), nrow=6,
ncol=3,dimnames=list(c("1900","1901","1902","1903","1904","1905"),
c("sample1","sample2","sample3")))
And I need to apply a filter (in this case, any value <5) to give me one
dataframe with only the
2009 Feb 02
1
A question regarding bootstrap
Dear List Members,
I have two small samples (n=20), the distributions are highly skewed. Does
it make any sense to do a boostrap test to check for difference in means?
And if so, could this be done like this:
x <- numeric(10000)
for(i in 1:10000) {
x[i] <- mean(sample(sample1,replace=TRUE)) -
mean(sample(sample2,replace=TRUE))
}
(mean(sample1)-mean(sample2))/sd(x)
Regards,
Erika
2010 Sep 07
1
average columns of data frame corresponding to replicates
Hi Group,
I have a data frame below. Within this data frame there are samples
(columns) that are measured more than once. Samples are indicated by
"idx". So "id1" is present in columns 1, 3, and 5. Not every id is
repeated. I would like to create a new data frame so that the repeated
ids are averaged. For example, in the new data frame, columns 1, 3,
and 5 of the original
2012 Jul 31
2
phantom NA/NaN/Inf in foreign function call (or something altogether different?)
Dear experts,
Please forgive the puzzled title and the length of this message - I
thought it would be best to be as complete as possible and to show the
avenues I have explored.
I'm trying to fit a linear model to data with a binary dependent
variable (i.e. Target.ACC: accuracy of response) using lrm, and
thought I would start from the most complex model (of which
"sample1.lrm1" is
2007 May 10
1
how to pass "arguments" to a function within a function?
I have searched the r-help files but have not been able to find an answer to this question. I apologize if this questions has been asked previously.
(Please excuse the ludicrousness of this example, as I have simplified my task for the purposes of this help inquiry. Please trust me that something like this will in fact be useful what I am trying to accomplish. I am using R 2.4.1 in Windows XP.)
2010 Nov 04
2
Converting Strings to Variable names
Hi all,
I am processing 24 samples data and combine them in single table called
CombinedSamples using following:
CombinedSamples<-rbind(Sample1,Sample2,Sample3)
Now variables Sample1, Sample2 and Sample3 have many different columns.
To make it more flexible for other samples I'm replacing above code with a
for loop:
#Sample is a string vector containing all 24 sample names
for (k in
2008 Oct 16
1
apply, t-test and p-values
R 2.7.2
Windows XP
I am using apply to compute a series of Student's t-test from two matrices, sample1 and sample2.
boo<-apply(sample1,1,t.test,sample2)
I want to pick of the p-values from the tests, but can't seem to get it to work. I have tried several methods to get the values including:
boo<-apply(sample1,1,t.test$t.test,sample2)
boo<-apply(sample1,1,t.test,sample2)$t.test
2012 Jul 13
4
Side by side strip charts
Hi,
I'm looking for some ideas on how to reproduce the attached image in R.
There are three samples, each of size n = 10. The first is drawn from a
normal distribution with mean 60 and standard deviation 3. The second is
drawn from a normal distribution with mean 65 and standard deviation 3. The
third is drawn from a normal distribution with mean 70 and standard
deviation 3.
2005 Apr 07
2
MailScanner SPAM Forward & Postfix Problem
First, thanks to the CentOS folks for creating such as awesome distro!
Second, thanks to all for contributing to such an great mailling
list!
I installed MailScanner/SpamAssassin/ClamAV last week based on the
excellent threads that have recently discussed the subject. For folks
who missed it, I used Johnny's wonderful guide at
http://www.hughesjr.com/content/category/1/14/30/Guides (see
2009 Sep 16
2
T-test to check equality, unable to interpret the results.
Hi,
I have the precision values of a system on two different data sets.
The snippets of these results are as shown:
sample1: (total 194 samples)
0.6000000238
0.8000000119
0.6000000238
0.2000000030
0.6000000238
...
...
sample2: (total 188 samples)
0.80000001
0.20000000
0.80000001
0.00000000
0.80000001
0.40000001
...
...
I want to check if these results are statistically significant? Intuitively,
2008 May 21
2
Problem in converting natural numbers to bits and others
Hi,
I just started using R for about one week and I have few problems.
i)I have a problem in finding right function to convert a table of natural
numbers to bitwise. For a simple example;
I have the below table:-
Column Col1 Col2 Col3
Sample1 5 7 10
Sample2 0 2 1
Sample3 4 0 0
Supposedly i wanted to convert to :-
Column Col1 Col2 Col3
2011 Mar 26
2
simple if question
Hi everyone,
I have just got different samples from a dataframe (independent and
exclusive, there aren't common elements among them). I want to create a
variable that indicate the sampling selection of the elements in the
original dataframe (for example, 0 = no selected, 1= sample 1, 2=sample
2, etc.).
I have tried to do it with ifelse command, but the problem is that the
second line
2006 Jun 29
1
kmeans clustering
Hello R list members,
I'm a bio informatics student from the Leiden university
(netherlands). We were asked to make a program with different
clustering methods. The problem we are experiencing is the following.
we have a matrix with data like the following
research1 research2 research3 enz
sample1 0.5 0.2 0.4
sample2 0.4
2010 Nov 02
2
One question on heatmap
Dear R-helper:
Suppose we have a matrix:
Gene sample1 sample2
Gcnt1 12.0000 52.80000
Max 8.8000 39.10000
Tmem176b 67.9000 304.70000
Shmt2 8.6000 42.40000
Rtn4 11.5000 57.70000
Il17re 7.6000 38.80000
Bclp2 6.2000 32.10000
Mobkl3 4.4000 32.20000
Akr1b10 3.4000 30.10000
2009 Sep 20
4
correlation help
Dear group,
I have a matrix like the following:
Name Sample1 sample2 sample3 sample4 ..... sample(n)
nm1 10.5 13.5 30 31
nm2 8 11 34 29
nm3 9 10.3 27.8 35
nm(j)
I want to be able to calculate correlation between all pairs of names.
For example (nm1,nm2),