Displaying 20 results from an estimated 1000 matches similar to: "DOE and interaction plot general question"
2007 Aug 10
1
[Fwd: Re: How to apply functions over rows of multiple matrices]
[Apologies to Gabor, who I sent a personal copy of the reply
erroneously instead of posting to List directly]
[...]
> Perhaps what you really intend is to
> take the average over those elements in each row of the first matrix
which correspond to 1's in the second in the corresponding
> row of the second. In that case its just:
>
> rowSums(newtest * goldstandard) /
2006 May 17
1
Example Syntax for if - then- and - else Statements
Hello R users,
I am a fairly new R user, however, one of the problems I am having is
the use of applying if-, and-, then-, else- statements in R against
datasets & dataframe. Rtips mentions it, but without simple examples I
am not quite sure what my syntax should look like. I am particularly
interested in syntax that can be used with the transform function. for
example
if foo[,1] ==
2006 Aug 01
4
Overlay Boxplot with scatter plot
I am trying to make a box plot and overlay it with a scatter plot from
another data.frame. I was able to successfully create the boxplot, but
when i tried using points(x~y...) the dots did not show up.
example code
aa<-(300,300,300,300,600,600,600,600,900,900,900,900)
bb<-(13,12,14,11,56,44,34,75,22.,34,22,98,59,55,56)
cc<-(13,12,14,11,56,44,34,75,22.,34,22,98,59,55,56)
2007 Aug 10
7
Help wit matrices
Hello all,
I am working with a 1000x1000 matrix, and I would like to return a
1000x1000 matrix that tells me which value in the matrix is greater
than a theshold value (1 or 0 indicator).
i have tried
mat2<-as.matrix(as.numeric(mat1>0.25))
but that returns a 1:100000 matrix.
I have also tried for loops, but they are grossly inefficient.
THanks for all your help in advance.
Lanre
2009 Apr 28
1
Mathematical label in a plot with a percent sign
Hi,
I am trying to produce a plot with an xlabel that reads (x >= 5%) with
the >= turned into the correct epression. I can do this up to the
percentage sign by specifiing xlab=expression(x>=5). Whatever I do to
include the % sign as well doesn't seem to work.
xlab=bquote(x>=5.("%")) almost works but includes brackets.
Anyonw know how to solve this one
Dan
PS I am
2009 Dec 02
1
Extract html tables to data.frames
Hello,
I would like to scrape some html tables from a web page and convert them
to a data.frame so I can perform further analysis. Could anyone tell me
the best way to do this? Would it be more appropriate to use an
external tool first?
Thanks
Dan
--
**************************************************************
Daniel Brewer, Ph.D.
Institute of Cancer Research
Molecular Carcinogenesis
2010 Nov 19
1
expand comma separated field vertically in data.frame
Hello,
I have a data.frame like this:
a 1,2,3,4 b1
b 6,7 b3
And I would like to transform it to this:
a 1 b1
a 2 b1
a 3 b1
a 4 b1
b 6 b3
b 7 b3
I have been looking at ddply but can't seem to work it out. ANy help
would be gratefully received.
Dan
--
**************************************************************
Daniel Brewer, Ph.D.
Institute of Cancer Research
Molecular Carcinogenesis
2009 Apr 06
2
Collapse data matrix with extra info separated by commas
Hello,
I would like to reshape my data for presentation purposes from something
like this:
> test <-
data.frame(a=c("A","A","A","A","B","B","B"),b=c(1,1,2,2,1,1,1),c=1:7)
> test
a b c
1 A 1 1
2 A 1 2
3 A 2 3
4 A 2 4
5 B 1 5
6 B 1 6
7 B 1 7
to something like this:
a b c
1 A 1 1,2
3 A 2 3,4
5 B 1 5,6,7
This seems
2009 Jun 24
1
order by decerasing 1st variable and increasing 2nd variable
Hello,
I have a data.frame which I would like to sort with the primary key
decreasing while the secondry key is increasing e.g.
x <- data.frame(One=c(1,1,1,2,2,3,4,5),Two=c(2,3,1,2,3,3,3,3))
I would like to order it so it looks like this:
One Two
8 5 3
7 4 3
6 3 3
4 2 2
5 2 3
3 1 1
1 1 2
2 1 3
i.e. primarily decreasing in the 1st column but if there is a
2008 Mar 26
1
Adding name labels to x-axis of matplot
Hello,
I have a gene expression matrix with columns being samples and rows
being genes. I would like to display the expression values for each
gene. I have two groups which I colour differently. The aim is to see
if there is any difference between the two groups consistently across genes.
So the following works well:
2007 Sep 24
2
Calculate difference between dates in years
Hello,
I would like to be able to calculate the age of someone at a particular
date. Both dates are date objects. Here is what I have come up with:
floor(as.numeric(sampleInfo$Date.of.DIAGNOSIS-sampleInfo$Date.of.birth)/365.25)
Is this the best approach? or is there an inbuilt function? I have
looked at difftime but that does not seem to allow output in years.
Many thanks
Dan
--
2009 Jan 20
2
Stacked barplot with two stacked bars besides each other
Hi,
I have a particular barplot I would like to generate, but I am having
trouble getting it to work. What I would like is in effect two barplots
with stacked bars merged into one. For example, I have two samples
(yoda1,yoda2) on which I measure whether two variables (var1,var2) are
present or absent for a number of measurements on that sample.
> var1 <- data.frame(yoda1=c(3,7),
2010 Dec 10
2
Remove 100 years from a date object
Hello,
I have some data that has dates in the form 27.02.37. I convert them to
a date object as follows:
as.Date(data$date,format="%d.%m.%y")
But this gives me years such as 2037 when I would like them to be 1937.
I thought of trying to take off some time i.e.
as.Date(camCD$DoB,format="%d.%m.%y") - 100*365
But that doesn't seem to work out correctly. Any ideas how to
2010 Dec 10
1
melt causes errors when characters and values are used
Hello,
I am finding that the melt function from the reshape library causes
errors when applied to a data.frame that contains numeric and character
columns. For example,
melt(id.vars="ID",data.frame(ID=1:3,date=c("a","b","c"),value=c(1,4,5)))
ID variable value
1 1 date a
2 2 date b
3 3 date c
4 1 value <NA>
5 2
2008 Jun 17
3
Capturing coxph warnings and errors
Hi,
I have a script that takes a subset of genes on a microarray and tries
to fit a coxph model to the expression values for each gene. This seems
to work fine but in some cases it produces warnings and/or errors.
For example:
Error in fitter(X, Y, strats, offset, init, control, weights = weights, :
NA/NaN/Inf in foreign function call (arg 6)
In addition: Warning message:
In fitter(X, Y,
2010 Aug 26
7
Find classes for each column of a data.frame
Hello,
Is there a simple way to get the class type for each column of a
data.frame? I am in the situation where I would like to get all the
columns of a data.frame that are factors.
I have tried:
apply(df,2,class)
but all the columns come back as class "character".
Thanks
Dan
--
**************************************************************
Daniel Brewer, Ph.D.
Institute of
2009 Dec 23
2
COnfidence intervals for estimates of linear model
Hello,
I would like to calculate the 95% confidence intervals for the estimates
of a linear model and I just wanted to check that I am doing it correct.
Is it just:
Estimate + 1.95996*Std.Error to Estimate - 1.95996*Std.Error
or is there another approach that doesn't assume a normal distrbution?
Thanks. Apologies for my naiivity
Dan
--
2010 Dec 02
1
Suitable test for ordinal variable vs continuous variable trend
Dear all,
For a population of about 200 I have a continuous variable and an ordinal variable. The question I would like to ask is whether the continuously increases (or decreases) as the rank of the ordinal variable increases. I was thinking that a Spearmen's rank correlation or or a chi squared trend might be appropriate. I don't have any experience dealing with ordinal variables so I
2007 Aug 10
0
Row name of empty string issue
I have a data.frame with rownames taken from a database. Unfortunately, one
of the rownames (automatically obtained from the DB) is an empty string. I
often do computations on the DB s.t. the answers (rows) are indexed with
respect to the rownames so a computation on a DB record might necessitate
the indexing into the data.frame by the emtpy row name. Unfortunately, that
doesn't seem to
2008 Jan 31
3
Log rank test power calculations
Does anyone have any ideas how I could do a power calculation for a log
rank test. I would like to know what the suggested sample sizes would
be to pick a difference when the control to active are in a ratio of 80%
to 20%.
Thanks
Dan
--
**************************************************************
Daniel Brewer, Ph.D.
Institute of Cancer Research
Email: daniel.brewer at icr.ac.uk