Displaying 20 results from an estimated 700 matches similar to: "How to plot multiple graphs in one go?"
2011 Dec 04
1
Complex multiple t tests in a data frame with several id factors
I have assayed the concentrations of various metal elements in
different anatomic regions of two strains of mice. Now, for each
element, in each region, I want to do a t test to find whether there
is any difference between the two strains.
Here is what I did (using simulated data as an example):
# create the data frame
> elemconc = data.frame(expand.grid(id=1:3, geno=c('exp',
2011 Dec 23
2
cast in reshape and reshape2
> library(reshape2)
> x = melt(airquality, id=c('month', 'day'))
With reshape I can cast with multiple functions:
> library(reshape)
> cast(x, month+variable~., c(mean,sd))
month variable mean sd
1 5 ozone 23.615385 22.224449
2 5 solar.r 181.296296 115.075499
3 5 wind 11.622581 3.531450
4 5 temp 65.548387
2013 Apr 18
1
parSapply can't find function
Here is the code, assuming 8 cores in the cpu.
library('modeest')
library('snow')
cl = makeCluster(rep('localhost', 8), 'SOCK')
x = vector(length=50)
x = sapply(x, function(i) i=sample(c(1,0), 1))
pastK = function(n, x, k) {
if (n>k) { return(x[(n-k):(n-1)]) }
else {return(NA)}
}
predR = function(x, k) {
pastList = lapply(1:length(x), function(n)
2013 Apr 18
1
snow: cluster initialization
Dear all,
I found a strange thing with the snow package.
This will work:
y = matrix(1:4, 2)
cl = makeCluster(rep('localhost', 8), type='SOCK')
parMM(cl, y, y)
This will not:
y = matrix(1:4, 2)
ncore = system('nproc')
parMM(cl, y, y)
Error in cut.default(i, breaks) : invalid number of intervals
I also tried:
cl = makeCluster(rep('localhost', ncore),
2011 Nov 23
2
Is there an easier way to iterate over multiple data frames in R?
> for (d in paste('df', 1:3, sep='')) {
+ assign(d, as.data.frame(replicate(3, rnorm(4))))
+ }
> dats = list(df1,df2,df3)
> for (i in 1:length(dats)) {
+ names(dats[[i]]) = c('w', 'l', 'h')
+ }
> dats
[[1]]
w l h
1 1.24319239 -0.05543649 0.05409178
2 0.05124331 -1.89346950 0.33896273
3 -1.69686777 -0.35963008
2014 Nov 10
1
Cursor not behaving properly
I found a strange bug in R recently (version 3.1.2):
As you can see from the screenshots attached, when the cursor passes the
right edge of the console, instead of start on a new line, it goes back to
the beginning of the same line, and overwrites everything after it.
This happens every time the size of the terminal is changed, for example,
if you fit the terminal to the right half of the
2011 Nov 03
1
Why can't this function be used with the 'by' command?
Why can't this function be used with the 'by' command?
> x = array(runif(16), dim=c(8,2))
> x = data.frame(x)
> x$group = rep(c('wt', 'app'), each=4)
> shapiro.p = function(x) shapiro.test(x)[[2]]
> apply(x[,1:2], 2, shapiro.p)
X1 X2
0.4126345 0.2208781
> by(x[,1:2], x$group, shapiro.p)
Error in `[.data.frame`(x, complete.cases(x)) :
2013 Aug 25
0
"block incomplete" error when compiling R
Dear list,
I am trying to compile R on a 64-bit Ubuntu 13.04 machine and get the
following error:
make[2]: Entering directory
`/home/kaiyin/opt/R-2.15.0/src/library/Recommended'
begin installing recommended package MASS
Error in untar2(tarfile, files, list, exdir) : incomplete block on file
make[2]: *** [MASS.ts] Error 1
make[2]: Leaving directory
2011 Nov 05
1
Correlation between matrices
> regions = c('cortex', 'hippocampus', 'brain_stem', 'mid_brain',
'cerebellum')
> mice = paste('mouse', 1:5, sep='')
> for (n in c('Cu', 'Fe', 'Zn', 'Ca', 'Enzyme')) {
+ assign(n, as.data.frame(replicate(5, rnorm(5))))
+ }
> names(Cu) = names(Zn) = names(Fe) = names(Ca) = names(Enzyme) =
2010 May 20
1
Geneland error on unix: Error in MCMC(........ :, unused argument(s) (ploidy = 2, genotypes = geno)
I am receiving the above error ( full r session output below) the
script runs OK in windows. and "genotypes" and "ploidy" are both
correct arguments
any suggestions would be most welcome
Nevil Amos
MERG/ACB
Monash University School of Biological Sciences
> library(Geneland)
Loading required package: RandomFields
Loading required package: fields
Loading required
2011 Aug 30
2
Error in evalauating a function
Hi,
? I am very new to R. So, pardon my dumb question. I was trying to write my own function to run a different model (perform an ordered logistic regression) using the example in website http://pngu.mgh.harvard.edu/~purcell/plink/rfunc.shtml
But R returns a error `R Error in eval(expr, envir, enclos) : object 's' not found' when I run it. What am I doing wrong here? Here's
2017 Oct 24
2
as.data.frame doesn't set col.names
Why doesn't this work?
> samples$geno <- as.data.frame(sapply(yo, toupper), col.names="geno")
> samples
quant_samples age sapply(yo, toupper)
E11.5 F20het BA40 E11.5 F20het BA40 E11.5 F20HET
E11.5 F20het BA45 E11.5 F20het BA45 E11.5 F20HET
2017 Oct 24
0
as.data.frame doesn't set col.names
Wait. Now I'm really confused.
>
> head(samples)
quant_samples age sapply(yo, toupper)
E11.5 F20het BA40 E11.5 F20het BA40 E11.5 F20HET
E11.5 F20het BA45 E11.5 F20het BA45 E11.5 F20HET
E11.5 F20het BB84 E11.5 F20het BB84 E11.5 F20HET
E11.5 F9.20DKO KTr3 E11.5 F9.20DKO KTr3 E11.5 F9.20DKO
E11.5
2005 Jun 24
5
Memory limits using read.table on Windows XP Pro
Hello,
When I try:
geno
<-read.table("2500.geno.tab",header=TRUE,sep="\t",na.strings=".",quote="
",comment.char="",colClasses=c("factor"),nrows=2501)
I get, after hour(s) of work:
Error: cannot allocate vector of size 9 Kb
I have:
Rgui.exe --max-mem-size=3Gb
and
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft
2011 Jun 30
1
Analysing insecticide biossays using lmer
Hi all,
Here is my problem: I performed bioassays using a unique insecticide on 9
different genotypes and got their mortality depending on the dose of
insecticide used.
Now, I want to see wether some genotypes are different or not in their
responses to insecticide.
My problem is that I have up to four replicates for some genotypes, but only
one for other... Due to this unbalanced design, I
2006 Jun 05
3
Fastest way to do HWE.exact test on 100K SNP data?
Hi everyone,
I'm using the function 'HWE.exact' of 'genetics' package to compute p-values of
the HWE test. My data set consists of ~600 subjects (cases and controls) typed
at ~ 10K SNP markers; the test is applied separately to cases and controls. The
genotypes are stored in a list of 'genotype' objects, all.geno, and p-values are
calculated inside the loop over all
2012 Oct 05
1
Error in lmer: asMethod(object) : matrix is not symmetric [1, 2]
Dear R Users,
I am having trouble with lmer. I am looking at recombinant versus non
recombinant individuals. In the response variable recombinant
individuals are coded as 1's and non-recombinant as 0's. I built a model
with 2 fixed factors and 1 random effect. Sex (males/females) is the
first fixed effect and sexual genotype (XY, YY, WX and WY) the second
one. Sexual Genotype is
2010 Feb 12
1
"drop if missing" command?
This will probably seem very simple to experienced R programmers:
I am doing a snp association analysis and am at the model-fitting stage. I
am using the Stats package's "drop1" with the following code:
##geno is the dataset
## the dependent variable (casectrln) is dichotomous and coded 0,1
## rs743572_2 is one of the snps (which is coded 0,1,2 for the 3 genotypes)
2017 Sep 28
0
Boxplot, formula interface, and labels.
mybp <- boxplot(count ~ geno * tissue, data = mydata, plot = FALSE)
mybp$names <- gsub("\\.", "\n", mybp$names)
bxp(mybp)
See ?boxplot for details.
Best,
Ista
On Thu, Sep 28, 2017 at 12:40 PM, Ed Siefker <ebs15242 at gmail.com> wrote:
> I have data I'd like to plot using the formula interface to boxplot.
> I call boxplot like so:
>
> with(mydata,
2017 Sep 28
3
Boxplot, formula interface, and labels.
I have data I'd like to plot using the formula interface to boxplot.
I call boxplot like so:
with(mydata, boxplot(count ~ geno * tissue))
I get a boxplot with x axis labels like "wt.kidney". I would like
to change the '.' to a newline. Where is this separator configured?
Thanks,
-Ed