Displaying 20 results from an estimated 600 matches similar to: "plotting average effects."
2011 Feb 02
0
How column names/row names are preserved in matrix calculation?
Can somebody tell me that, if I do some arithmetic calculation over 2
matrices then how the column names and row names are preserved? It seems
that, for multiplication, column names and row names of the 2nd matrix are
preserved and for additional, there seems not having any explicit rule:
> set.seed(1)
> dat1 <- matrix(rnorm(25), 5); colnames(dat1) = rownames(dat1) =
2013 Sep 10
0
Looping an lapply linear regression function
Hi,
Try:
dat2<- read.csv("BOlValues.csv",header=TRUE,sep="\t",row.names=1)
dim(dat2)
#[1] 20 28
indx2<-expand.grid(names(dat2),names(dat2),stringsAsFactors=FALSE)
nrow(indx2)
#[1] 784
indx2New<- indx2[indx2[,1]!=indx2[,2],]
nrow(indx2New)
#[1] 756
res2<-sapply(seq_len(nrow(indx2New)),function(i) {x1<- indx2New[i,];
2010 Jul 14
1
Write value to PHP webpage
I have a series of animals that are being radio-tracked. I have written
some code that goes through each animal and calculates the total distance
that each animal is traveling. I will need to run these data on a regular
basis and want to write the result to a .php webpage file so that the page
updates automatically when I re-run the code. I thought I'd be able to use
the
2013 Sep 27
0
Best and Worst values
Ira,
obj_name<- load("arun.RData")
Pred1<- get(obj_name[1])
Actual1<- get(obj_name[2])
dat2<- data.frame(S1=rep(Pred1[,1],ncol(Pred1)-1),variable=rep(colnames(Pred1)[-1],each=nrow(Pred1)),Predict=unlist(Pred1[,-1],use.names=FALSE),Actual=unlist(Actual1[,-1],use.names=FALSE),stringsAsFactors=FALSE)
dat2New<- dat2[!(is.na(dat2$Predict)|is.na(dat2$Actual)),]
?dat3<-
2011 Feb 28
0
Gamma mixture models with flexmix
I've been trying with no success to model mixtures of Gamma distributions using
the package flexmix (see examples below). Can anyone help me get it to model
better? Thanks very much.
-Ben
##
## Please help me get flexmix to correctly model mixtures of
## Gamma distributions. See examples below.
##
library('flexmix')
##
## Plot a histogram of dat and the Gamma mixture model given
2013 Apr 12
1
Removing rows that are duplicates but column values are in reversed order
Hi,
From your example data,
dat1<- read.table(text="
id1?? id2?? value
a????? b?????? 10
c????? d??????? 11
b???? a???????? 10
c????? e???????? 12
",sep="",header=TRUE,stringsAsFactors=FALSE)
#it is easier to get the output you wanted
dat1[!duplicated(dat1$value),]
#? id1 id2 value
#1?? a?? b??? 10
#2?? c?? d??? 11
#4?? c?? e??? 12
But, if you have cases like the one
2012 Nov 13
4
for loop
HI,
You can do this in many ways:
dat1<-read.table(text="
med1,med2,med3????
?1,0,1??????
0,1,1???
2,0,0
",sep=",",header=TRUE)??
#1st method
library(reshape)
dat2<-melt(dat1)
dat3<-aggregate(dat2$value,by=list(dat2$variable),sum)
?colnames(dat3)<-c("name","sum(n11)")
?dat3
#? name sum(n11)
#1 med1??????? 3
#2 med2??????? 1
#3 med3??????? 2
2013 Sep 09
0
Duplicated genes
Hi,
May be you can try this:
dat1New<-? dat1[!(duplicated(dat1$gene)|duplicated(dat1$gene,fromLast=TRUE)),]
dat2<-dat1[duplicated(dat1$gene)|duplicated(dat1$gene,fromLast=TRUE),]
?lst1<-split(dat2,dat2$gene)
dat3<-unsplit(lapply(lst1,function(x) {x1<- sum(apply(x[,6:32],2,function(y) y[1]>=y[2]));x2<- sum(apply(x[,6:32],2, function(y) y[1]<=y[2])); if(x1>x2) x[1,] else
2012 Mar 10
3
function input as variable name (deparse/quote/paste) ??
Hi all
Say I have a function:
myname=function(dat,x=5,y=6){
res<<-x+y-dat
}
for various input such as
myname(dat1)
myname(dat2)
myname(dat3)
myname(dat4)
myname(dat5)
how should I modify the 'res' line, to have new informative variable name
correspondingly, such as
dat1.res
dat2.res
dat3.res
dat4.res
dat5.res
stored in the workspace.
This is only an example of a complex
2017 Oct 05
0
Adding non-data line to legend ggplot2 Maximum Contaminant Level
Well, here is one way but it seems a bit clumsy.
In words, I created a new data.frame with "250" in the Chloride vector and "SMCL" in the Detections vector and supplessed one legend.
Warning: For my convenience I am using different data.frame names .
library(ggplot2)
MyData <-read.csv("http://doylesdartden.com/Stats/TimeSeriesExample.csv", sep=",")
2009 Dec 17
4
Fishers exact test at < 2.2e-16
In an effort to select the most appropriate number of clusters in a
mixture analysis I am comparing the expected and actual membership of
individuals in various clusters using the Fisher?s exact test. I aim
for the model with the lowest possible p-value, but I frequently get
p-values below 2.2e-16 and therefore does not get exact p-values with
standard Fisher?s exact tests in R.
Does anybody know
2004 Nov 21
3
Help with ooplot(gplots) and error bars
Dear All
I am trying to graph a proportion and CI95% by a factor with ooplot (any
other better solution ?)
It works well until I try to add the confidence interval.
this is the error message and and a description of the data:
> dat1
PointEst
TT1 1 3.6
TT2 2 5.0
TT3 3 5.8
TT4 4 11.5
TT5 5 7.5
TT5 6 8.7
TT7 7 17.4
> dat2
2012 Jun 06
1
error calling Winbugs using R2WinBugs to run a multi-level model
Dear all,
I'm calling Winbugs (1.4.3) through R2WinBugs (2.1-18 coda_0.14-7) to
fit a switching random walk model, but come up with an instant trap
with the log only displaying 'check('.
I will paste the trap with session info below; I'd be very grateful
for any ideas.
Couple of leads:
1. I presume the problem relates to the r package itself or the way I
call bugs(), because I
2010 May 28
1
Comparing and Interpreting GAMMs
Dear R users
I have a question related to the interpretation of results based on GAMMs using Simon Woods package gamm4.
I have repeated measurements (hours24) of subjects (vpnr) and one factor with three levels (pred). The outcome (dv) is binary.
In the first model I'd like to test for differences among factor levels (main effects only):
gamm.11<-gamm4(dv ~ pred +s(hours24), random = ~
2005 Mar 03
3
creating a formula on-the-fly inside a function
I have a function that, among other things, runs a linear model and
returns r2. But, the number of predictor variables passed to the
function changes from 1 to 3. How can I change the formula inside the
function depending on the number of variables passed in?
An example:
get.model.fit <- function(response.dat, pred1.dat, pred2.dat = NULL,
pred3.dat = NULL)
{
res <- lm(response.dat ~
2024 Jun 26
1
Ayuda para hacer una lista
Hola Leticia
Acomodar datos para analizar suele llevar más trabajo que el análisis.
Yo prefiero en un data.frame colocar todos los datos, porque siempre es más fácil filtrar que agregar. Cuándo tengo el data.frame con todo, realizo un plot (datos), y muchas veces en la gráfica veo cosas que me llaman la atención, de esta forma busco algo de antemano no sospechaba.
No es necesario que conozcas
2011 Jul 02
5
How many times occurs
Hi all,
I have a data matrix likein "input.txt"
8 9 2 5 4 5 8 5 6 6
8 9 2 8 9 2 8 9 2 1
8 9 2 5 4 5 8 5 6 4
8 9 2 5 4 5 8 5 6 6
8 9 2 8 9 2 8 9 2 1
8 9 2 5 4 5 8 9 2 2
In this example will be an 6x10 matrix (or data frame)
I want to detect how many times in a row appears this combination 8 follewd
by 9 followed by 2, and create a new matrix with only this number of occurs
then
2018 Jun 01
0
Time-series moving average question
Good morning, I hope someone can help with these questions, or perhaps suggest one of the other R-lists?
I have two questions:
1. Why am I getting this warning?
2. Why is the second example "Point Forecast" the same value, I do not see that in previous attempts with similar but different data sets as in example 1?
Example1:
dat3 <- structure(c(3539122.86, 3081383.87,
2024 Jun 26
2
Ayuda para hacer una lista
Hola
Soy Leticia, quería hacer una consulta al grupo a ver si me podéis ayudar.
Tengo unos datos de proteínas, el data frame es: 5 columnas iniciales que
tienen información sobre las proteínas y después las columnas con las
intensidades, de las cuales no se cuantas condiciones tienen ni cuántas
réplicas por condición.
Estoy intentando hacer un cálculo del coeficiente de variación por grupo y
2011 Nov 27
1
Simplifying my code
Hi,
I have a pretty simple problem. Here is the code:
dat1=complete(dat.mice,1)
dat2=complete(dat.mice,2)
dat3=complete(dat.mice,3)
dat4=complete(dat.mice,4)
dat5=complete(dat.mice,5)
dat6=complete(dat.mice,6)
dat7=complete(dat.mice,7)
dat8=complete(dat.mice,8)
dat9=complete(dat.mice,9)
dat10=complete(dat.mice,10)
dat11=complete(dat.mice,11)
dat12=complete(dat.mice,12)