Interesting. Check this out:
u - sample(c(TRUE, FALSE), 10, replace = TRUE)
u
[1] FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE FALSE
class(u)
[1] logical
u + 0
[1] 0 0 1 0 0 1 0 0 0 0
0 + u
[1] 0 0 1 0 0 1 0 0 0 0
v - rpois(10, 3)
!duplicated(v)
[1] TRUE FALSE TRUE TRUE
Hi:
Here are some possibilities using ggplot2:
library(ggplot2)
# Create ordered factors
bar$area2 - ordered(bar$area)
bar$year2 - ordered(bar$year)
# Side-by-side, aka dodged, bar charts
ggplot(bar, aes(x = area2, y = disc, fill = year2)) +
geom_bar(aes(group = year2), position =
Hi:
Here's an example (never mind the model fit...or lack of it thereof...)
str(AirPassengers) # a built-in R data set
# Series is seasonal with increasing trend and increasing variance
plot(AirPassengers, type = 'l')
# STL decomposition
plot(stl(AirPassengers, 'periodic'))
# ACF and PACF
Hi:
The MASS package has a function dose.p() to produce a CI for ED50, ED90 or
EDp in general (0 p 100). It takes a model object (presumably from a
suitable logistic regression) as input. You could always take the code
already available and adapt it to your situation or you could investigate
' not found
Calls: print ... lapply - is.vector - lapply - FUN - eval - eval
--
*From:* Dennis Murphy djmu...@gmail.com
*To:* Alaios ala...@yahoo.com
*Cc:* Rhelp r-help@r-project.org
*Sent:* Sat, November 20, 2010 4:24:15 PM
*Subject:* Re: [R] Merge two ggplots
Hi:
Perhaps a plus sign at the end of the line before geom_tile() would help.
Dennis
On Sat, Nov 20, 2010 at 6:30 AM, Alaios ala...@yahoo.com wrote:
Hello everyone.
I am using ggplot and I need some help to merge these two plots into one.
plot_CR-function(x,y,agentid,CRagent){
Hi:
Here's an example stolen out of the scatterplot3d package vignette (p. 9):
library(scatterplot3d)
z - seq(-10, 10, 0.01)
x - cos(z)
y - sin(z)
scatterplot3d(x, y, z, highlight.3d = TRUE, col.axis = 'blue',
col.grid = 'lightblue', main = 'Helix', pch = 20)
HTH,
Dennis
On Sat,
Hi:
2010/11/19 Niccolò Bassani biostatist...@gmail.com
Dear R-users,
from Douglas Bates lme4 book I'm trying to run profile() on a quite large
dataset, in order to have some confidence intervals on random effects
parameter in mixed models. When I run it in lme4 however I'm faced with the
Hi:
On Fri, Nov 19, 2010 at 2:57 AM, Robert Ruser robert.ru...@gmail.comwrote:
Hello R Users,
I have vectors
x - c(a2,b7,c8)
y1 - c(1,2,3,2)
y2 - c(4,2,7,5,4,3,8)
y3 - c(1:10)
and I want to assign values form vector y1 to a new variable which
name comes from the 1st value of the vector
Hi:
Look into melt() from package reshape2. Assuming m is your matrix,
library(reshape2)
meltm - melt(m, id = rownames(m))
str(meltm)
head(meltm)
## Toy example:
m - matrix(1:30, nrow = 3)
rownames(m) - paste('Gene', 1:nrow(m), sep = '')
colnames(m) - paste('T', 1:ncol(m), sep = '')
m
Hi:
d$r - with(d, ave(x, f, FUN = function(u) u - mean(u)))
d
f x r
1 1 2 1
2 1 0 -1
3 2 0 -2
4 2 4 2
5 2 2 0
HTH,
Dennis
On Thu, Nov 18, 2010 at 6:02 AM, Lancaster, Anthony
anthony_lancas...@brown.edu wrote:
Hi,
I'd appreciate help with this. I have a data matrix with one column,
Hi:
Try this:
pf - function(p) {
plot(c(p:(p+10)),c(1:11))
plot(c(p:(p+10)),c(2:12))
plot(c(p:(p+10)),c(3:13))
}
par(mfrow = c(3, 3))
for(i in 1:3) pf(i)
par(mfrow = c(1, 1))
HTH,
Dennis
On Wed, Nov 17, 2010 at 8:56 AM, Soyeon Kim yunni0...@gmail.com wrote:
Dear All,
I made a
Hi:
Since Deducer was mentioned, I'll add that Ian Fellows has recently released
an 'all-in-one' installer for R, JGR and Deducer at
http://ifellows.ucsd.edu/pmwiki/pmwiki.php?n=Main.WindowsInstallation
Look for the Download Installer link (it's kinda hard to miss :)
On my system (64-bit Win
Try adding pch = 16 to your plot call.
HTH,
Dennis
On Tue, Nov 16, 2010 at 4:28 AM, DrCJones matthias.godd...@gmail.comwrote:
for a simple scatterplot:
plot(X ~ Y, type = 'p', col = 'red')
this produces red-edged circles, but I want to fill in the circles.
can this be done? I checked
Hi:
Try this:
# Function to generate one sample from the data frame
sampler - function(df) {
s1 - sample(nrow(df), 1, replace = FALSE)
s2 - sample(setdiff(1:nrow(df), s1), 2, replace = FALSE)
list(sample1 = df[s1, grep('^C', names(df))],
sample2 = df[s2, grep('^W',
Hi:
The input to jarque.bera.test() is a numeric vector or time series. Try
running the function str() on your input object to see if it is of the
correct type. If you have a vector that is not numeric or a time series
object, you need to convert it to one with something like as.numeric(myvec).
Hi:
Perhaps this post from earlier today will be useful:
http://r.789695.n4.nabble.com/Re-interpretation-of-coefficients-in-survreg-AND-obtaining-the-hazard-function-td3043160.html#a3043160
HTH,
Dennis
2010/11/15 Lorena Avendaño mlorena.avend...@gmail.com
Dear R-users,
I would like to fit a
Hi:
See inline.
On Mon, Nov 15, 2010 at 4:26 PM, Nate Miller natemille...@gmail.com wrote:
Hi All!
I have some experience with R, but less experience writing scripts using
R and have run into a challenge that I hope someone can help me with.
I have multiple .csv files of data each with
Hi:
Look into the ave() function - here's a small demonstration:
d - data.frame(g = factor(rep(LETTERS[1:5], each = 5)),
x = rpois(25, 10))
d$mean - with(d, ave(x, g, FUN = mean))
head(d, 10)
head(d, 10)
g x mean
1 A 5 8.4
2 A 14 8.4
3 A 10 8.4
4 A 2 8.4
5 A 11
Hi:
This is kind of kludgy, but if the matrix and parallel vector are both
numeric, you could try something like
A - matrix(rnorm(12), nrow = 3)
v - 1:3
f - function(x) c(sum(x[-length(x)]^2), x[length(x)])
t(apply(cbind(A, v), 1, f))
v
[1,] 8.196513 1
[2,] 1.414914 2
[3,] 2.436660
Hi:
A good place to start would be package vcd and its suite of demos and
vignettes, as well as the vcdExtra package, which adds a few more goodies
and a very nice introductory vignette by Michael Friendly. You can't fault
the package for a lack of documentation :)
You might also find the
Hi:
Another alternative is
crossprod(A)
which is meant to produce an optimized A'A (not the vector cross-product
from intro physics :)
Example:
A - matrix(rpois(9, 10), ncol = 3)
A
[,1] [,2] [,3]
[1,]6 10 14
[2,]75 16
[3,] 12 16 10
t(A) %*% A
[,1] [,2]
Hi:
Do you mean to leave the x-axis as is and redo the y? If so, use graphical
parameter yaxt:
x - y - 1:10
plot(x, y, yaxt = 'n')
axis(2, at = ..., lab = ..., ...)# fill in the blanks
In case it matters, xaxt = 'n' suppresses the x-axis labels but not the y
labels.
HTH,
Dennis
On Thu,
Hi:
A perusal of the splom() help page indicates the following:
...If you are trying to fine-tune your splom plot, definitely look at the
panel.pairs http://127.0.0.1:26915/library/lattice/help/panel.pairs help
page. The scales argument is usually not very useful in splom, and trying to
change
Hi:
This sounds like a 'doubly repeated measures problem'. Are any treatments
assigned to individuals or is this a purely observational study?
Is the time horizon of the between-visit factor (much?) longer than that of
the within-visit factor? You could try to assess the strength of correlation
Hi:
Did you mean
panel.text(x,y/2,label = round(y,3),cex=1)
??
HTH,
Dennis
On Tue, Nov 9, 2010 at 1:11 AM, Ashraf Yassen ashraf.yas...@gmail.comwrote:
Dear All,
Now with data. Any suggestion how to center the text in the filling would
be
appreciated.
Kind regards,
Ashraf
Hi:
library(sos)
findFn('truncated Pareto')
On my system, it scared up 17 matches. It looks like the VGAM package would
be a reasonable place to start looking.
HTH,
Dennis
On Tue, Nov 9, 2010 at 8:50 AM, cassie jones cassiejone...@gmail.comwrote:
Dear all,
I am trying to simulate from
Hi:
Is this what you're looking for?
x - 1:10
1 + sum((1/x)^(1:10))
[1] 2.291286
1 + sum(x^(-(1:10)))
[1] 2.291286
Since this may be a homework question, I'll let you figure out how to turn
it into a function - it only needs one change.
On Tue, Nov 9, 2010 at 7:16 PM, vicho vi...@ucla.edu
Hi:
?Recall
HTH,
Dennis
On Mon, Nov 8, 2010 at 1:25 AM, PLucas plucasplucasplu...@yopmail.comwrote:
Hi, I would like to create a list recursively and eliminate my for loop :
a-c()
a[1] - 1; # initial value
for(i in 2:N) {
a[i]-a[i-1]*b - c[i-1] # b is a value, c is another vector
Hi:
If you want the literal character strings, this works:
x-c(1, 2, 3)
y-c(4,5,6)
outer(x, y, function(x, y) paste('(', x, ',', y, ')', sep = '') )
[,1][,2][,3]
[1,] (1,4) (1,5) (1,6)
[2,] (2,4) (2,5) (2,6)
[3,] (3,4) (3,5) (3,6)
However, I have the sense you want to use the
Hi:
Is this what you had in mind?
library(reshape2)
df - df[, -10] # last variable is superfluous
dm - melt(df, id = 'day')
head(dm)
day variable value
1 1 var1 1
2 2 var1 2
3 3 var1 3
4 4 var1 4
5 1 var2 100
6 2 var2 200
Hi:
Look into the zoo package and its rollapply() function. The package is
designed to handle irregular and multiple series.
HTH,
Dennis
On Mon, Nov 8, 2010 at 12:16 PM, Richard Vlasimsky
richard.vlasim...@imidex.com wrote:
Does anyone recommend a more efficient way to roll values in a time
Hi:
If I get your meaning, the cut() function would appear to be your friend in
this problem.
hDatPretty$liking - cut(hDatPretty$rating, breaks = c(-11, -4, 4, 11),
labels = c('dislike', 'neutral',
'like'))
HTH,
Dennis
On Sat, Nov 6, 2010 at 11:15 PM, hind
Hi:
On Sat, Nov 6, 2010 at 11:22 PM, evt ethu...@gmail.com wrote:
I am guessing this is a very simple question, but this is only my second
day
with R so it is all still a bit imposing.
I am trying to run an autocorrelation.
I imported a CSV file, which has one column labeled logistic.
Hi:
Check out the expm package, particularly function expm().
HTH,
Dennis
On Sun, Nov 7, 2010 at 6:21 PM, zhiji19 zhij...@gmail.com wrote:
Dear R experts,
I really have difficulty when I try to deal with this question.
suppose X is a square symmetric matrix. The exponent of X is defined
Hi:
Look at the structure of the experiment.
The six blocks represent different replications of the experiment.
No treatment is assigned at the block level.
Within a particular block, there are three plots, to which each
variety is randomly assigned to one of them. Ideally, separate
Hi:
This isn't very difficult if you use a little imagination. We want three
separate plots of monthly means by variable with attached error bars. This
requires faceting, so we need to create a factor whose levels are the
variable names. We also need to generate enough data to summarize by mean
Hi:
To mimic Sarah Goslee's reply within base R, either of these work:
crossprod(t(as.matrix(xtabs( ~ a + b
crossprod(t(as.matrix(table(a, b
HTH,
Dennis
On Thu, Nov 4, 2010 at 12:42 PM, cory n corynis...@gmail.com wrote:
Let's suppose I have userids and associated attributes...
Hi:
Try this:
Trat - c(2:30) # number of treatments
gl - c(2:30, 40, 60, 120)
# Write a one-line 2D function to get the Tukey distribution quantile:
f - function(x,y) qtukey(0.95, x, y)
outer(Trat, gl, f)
It's slow (takes a few seconds) but it seems to work.
HTH,
Dennis
Hi:
On Tue, Nov 2, 2010 at 8:06 AM, McCarthy, Ian
ian.mccar...@fticonsulting.com wrote:
I'm trying to generate 50+ graphs using the UScensus2000tract data. I
need to access the data for just about all of the states, so I was
hoping to create a simple loop that will take the relevant state
Hi:
I don't know why, but it seems that in
bwplot(voice.part ~ height, data = singer,
main = NOT THE RIGHT ORDER OF COLOURS\n'yellow' 'blue' 'green' 'red'
'pink' 'violet' 'brown' 'gold',
fill=c(yellow,blue,green,red,pink,violet,brown,gold))
the assignment of colors is offset by 3:
Levels: Bass
Hi:
xtabs() also works in this case:
dat - read.table(textConnection('Subject Item Score
+ Subject 1 Item 1 1
+ Subject 1 Item 2 0
+ Subject 1 Item 3 1
+ Subject 2 Item 1 1
+ Subject 2 Item 2 1
+ Subject 2 Item 3 0'), header=TRUE)
closeAllConnections()
acast(dat,
Hi:
Here's another version of the plot using ggplot2:
g - ggplot(sleepstudy, aes(x = Days, y = Reaction, group = Subject, colour
= Subject))
g + geom_line(size = 1) + geom_smooth(aes(group = 1), size = 2) + theme_bw()
To get rid of the legend, if you so desire, use
g + geom_line(size = 1) +
Hi:
On Mon, Nov 1, 2010 at 3:59 PM, Chi Yuan cy...@email.arizona.edu wrote:
Hello:
I need some help about using mixed for model for unbalanced data. I
have an two factorial random block design. It's a ecology
experiment. My two factors are, guild removal and enfa removal. Both
are two
Hi:
If your objective is to make 15 plots, one for each level of razred, then
you don't need to make 15 individual data frames first. The lattice and
ggplot2 packages allow conditioning plots. You haven't mentioned what types
of plots you're interested in getting, but if it's something simple
Hi:
x - matrix(20:35, ncol = 1)
u - c(1, 4, 5, 6, 11) # 'x values'
m - c(1, 3, 1, 1, 0.5)
# Function to compute the inner product of the multipliers with the
extracted
# elements of x determined by u
f - function(mat, inputs, mults) crossprod(mat[inputs], mults)
f(x, u, mults = c(1, 3, 1,
Hi:
Is something like this what you were after?
x - data.frame(A = sample(LETTERS[1:5], 1000, replace = TRUE),
B = rpois(1000, 50),
C = rnorm(1000))
x[unique(x$A), ]
A B C
4 E 49 1.18424176
5 B 51 0.51911271
1 D 71 0.06266016
2 E 61 0.59862609
3 A 45
Hi:
There are a few things wrong, I believe; hopefully my suggested fix is what
you're after...
On Thu, Oct 28, 2010 at 3:35 PM, Duncan Mackay mac...@northnet.com.auwrote:
Hi All
I have regression coefficients from an experiment and I want to plot them
in lattice using panel curve but I
Hi:
Make grade an ordered factor:
grade - factor(grade, levels = c('G', 'VG', 'MVG'))
as.numeric(as.character(grade)) will convert to numeric scores 1, 2 and 3,
respectively, corresponding to the numerical codes of the ordered levels.
HTH,
Dennis
On Thu, Oct 28, 2010 at 8:37 PM, Par
Hi:
Since the series is obviously nonstationary and periodic, it would seem that
one should embrace a wider window over which to evaluate the DF test. I did
the following:
y - ts(Y, frequency = 12) # looked like an annual series to me
plot(stl(y, 'periodic')) # very informative!!
Hi:
I'm going to take a different tack from Gabor and Ivan and be strictly
qualitative on the distinctions among vectors, matrices, arrays, data frames
and lists.
As Ivan mentioned, a vector has a single (atomic) mode - i.e., all elements
of a vector must be of the same type. A numeric vector
Hi:
Here's another take with ggplot2:
library(ggplot2)
# Define the basic plot elements. First argument is the data frame.
# aes() refers to the plot's aesthetics, which refer to the variables
# mapped to specific 'roles' in the plot 'geoms'
g - ggplot(x, aes(x = Age, y = Trait))
g +
Hi:
This topic came up a couple of days ago:
http://r.789695.n4.nabble.com/R-file-td3009812.html#a3009812
HTH,
Dennis
On Wed, Oct 27, 2010 at 4:01 AM, Santosh Srinivas
santosh.srini...@gmail.com wrote:
Dear R-Group,
I am looking for suggestions for the best IDE for R. Best is obviously
Hi:
As David originally noted, your dates are going to be read in as factors
with data.frame() unless you explicitly define them as Date objects first.
Here's one way to get the plot using a toy example (since you didn't provide
any data):
library(ggplot2)
dd
[1] 21/2/10 30/3/10 30/4/10 30/5/10
Hi:
Is this what you need?
l_one - data.frame(key = c(2, 1, 2))
l_two - data.frame(ndx = 1:4, descr = c('this', 'that', 'other', 'finis'))
merge(l_one, l_two, by.x = 'key', by.y = 'ndx')
key descr
1 1 this
2 2 that
3 2 that
HTH,
Dennis
On Wed, Oct 27, 2010 at 10:53 AM, Jim Burke
Hi:
When it comes to split, apply, combine, think plyr.
library(plyr)
ldply(split(afvtprelvefs, afvtprelvefs$basestudy),
function(x) coef(lm (ef ~ quartile, data=x, weights=1/ef_std)))
.id (Intercept) quartile
1 CBP090802020.92140 3.38546887
2 CBP090802129.31632
Hi:
I'm pretty sure that newton.method in the animation package is meant to
illustrate the technique rather than to be used as an optimizer in practice.
Look at ?optim; it that doesn't meet your needs, consult the Optimization
Task View at CRAN, where you will find several packages, in addition
Hi :
It's not clear whether you want to save your code, your R object or both.
Tal has already directed you to help for saving objects created in your
workspace. As for saving the code, many people write their code in an editor
and either copy/paste it into the workspace or, with certain editors,
Hi:
Check out this post on R-help from February, and look carefully at the
solution of Walmes Zeviani - I believe it's close to what you're requesting:
http://r.789695.n4.nabble.com/Triangular-filled-contour-plot-td1557386.html
HTH,
Dennis
On Fri, Oct 22, 2010 at 6:15 PM, Yunting Sun
Hi:
On Thu, Oct 21, 2010 at 4:13 PM, mirick miri...@yahoo.com wrote:
Hello all,
Can any of you R gurus help me out? Im not all that great at stats to
begin with, and Im also learning the R ropes (former SAS user).
Sounds like you need a support group :)
Heres what I need help with
Hi:
Try
X - rnorm(100)
hist(X, main = bquote('[Ca'^'2+'*']i'~'onsets'), xlab = 'sec')
or
hist(X, main = bquote('[Ca*]'*i^'2+' ~'onsets'), xlab = 'sec')
I'm not sure which one you want, though.
HTH,
Dennis
On Fri, Oct 22, 2010 at 4:01 AM, DrCJones matthias.godd...@gmail.comwrote:
Hi,
How
Hi:
Does this work?
mdat - function(nt, n0, n1) {
l - nt - n0 - 1
k - seq(l) # same as 1:l
n - n0 - 1 + k
lam - n/nt
Q - seq(n1)[n]
data.frame(k = k, n = n, lam = lam, Q = Q)
}
mdat(20, 5, 20)
k n lam Q
1 1 5 0.25 5
2 2 6 0.30 6
3 3 7 0.35 7
4
Hi:
scale_manual() is a little tricky when you build the legend from within the
plot. I used shorter labels than you, but this worked for me:
ggplot(mydata, aes(y=score2, x=score1)) +
geom_point() +
stat_quantile(quantiles=c(0.50), aes(colour='red'), size = 1) +
Hi Dieter:
I think the OP wanted both lines and shading; from your code I could get the
shading but not the lines. This is what it took for me to get the lines
(note the type and col.line changes in xyplot() ):
panel.bands - function(x, y, upper, lower,
subscripts, ..., font,
Works for me! Thanks, Dieter!
Regards,
Dennis
On Wed, Oct 20, 2010 at 2:07 AM, Dieter Menne
dieter.me...@menne-biomed.dewrote:
djmuseR wrote:
Hi Dieter:
I think the OP wanted both lines and shading; from your code I could get
the
shading but not the lines. This is what it took
Hi:
Here's one way, although it can be improved a bit.
d1 - aggregate(C ~ A, data = subset(DF0, B == 1), FUN = sum)
d2 - subset(DF0, B != 1)
# B not in d1, so need to replace it
d1
A C
1 52 124
2 57 64
3 89 192
d1$B - rep(1, nrow(d1))
d1 - d1[, c(1, 3, 2)] # reorder columns to permit
(), summaryBy() in the doBy package and several
more functions/packages can do this quite easily.
Dennis
On Wed, Oct 20, 2010 at 3:21 AM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
Here's one way, although it can be improved a bit.
d1 - aggregate(C ~ A, data = subset(DF0, B == 1), FUN = sum)
d2
options :)
Dennis
On Wed, Oct 20, 2010 at 3:24 AM, Dennis Murphy djmu...@gmail.com wrote:
Or even better (doh!)...
library(plyr)
ddply(DF0, .(A, B), summarise, C = sum(C))
A B C
1 52 1 124
2 52 59 38
3 52 97 75
4 57 1 64
5 57 6 26
6 57 114 12
7 89 1 192
8
Hi:
Your confidence intervals are so short that the size of the point in the
graphics region covers the endpoints! You also have a wide range of
simulated means (0 - 52) and actual values (0 - 54). Here are some measures
of your CIs:
with(simvsact, max(simCI.upper - simCI.lower))# maximum
Hi:
Even more fun with Deducer in 2.12.0:
I downloaded the JGR 64-bit executable from R-forge and installed the latest
binary of the package from there a half hour ago. When I try the JGR
executable, I get the same error that Rob and Kat reported. When I try to
call Deducer from within R-2.12.0
mydata[c(1:5, 10:15), ]
HTH,
Dennis
On Wed, Oct 20, 2010 at 6:25 AM, skan juanp...@gmail.com wrote:
Hello
How can I select several not continuous rows ?
If I wanted to select rows 1 to 7 I'll write
mydata[,1:7]
But what if I need to select rows 1 to 5 and 10 to 15?
--
View this
Hi:
On Mon, Oct 18, 2010 at 11:32 PM, Cristina Ramalho
cristina.rama...@grs.uwa.edu.au wrote:
Hi all,
I suppose this is a very simple question, but as I've lost already a bit of
time with it, without being able to get what I wanted, I'm addressing the
question to the group in the hope
Hi:
One answer comes from the pwr.r.test() function in package pwr (read its
code to see how it calculates power):
pwr.r.test(n = 100, r = 0.2, sig.level = 0.05, alternative = 'two.sided')
approximate correlation power calculation (arctangh transformation)
n = 100
lines(1:5, means.cl)
HTH,
Dennis
On Tue, Oct 19, 2010 at 7:13 AM, ashz a...@walla.co.il wrote:
Hi,
Thanks for the tip.
I run this script:
means.cl - c(82, 79, 110, 136,103)
stderr.cl - c(8.1,9.2,7.4,1.6,7.6)
plotCI(x = means.cl , uiw = stderr.cl, pch=24)
But how can I connect the
Hi:
This is how you could do the same in ggplot2; geom_ribbon() does the
shading. For your example, it seemed reasonable to put in reference lines,
especially since the upper limits of one confidence band abutted the lower
limits of the other in group a, so I averaged the upper and lower limits
Hi:
I agree with Ista's point that you shouldn't be doing loess with these data
(x and y both need to be continuous for loess, but your x is discrete), but
you shouldn't be computing boxplots at each YMRS_Sum value either because
you don't have enough resid observations at Sum = 3 and 4. A
Hi:
Following up on Ben's suggestion re ggplot2, here's a manufactured example:
# Fake data:
mortrate - round(runif(100), 3)
dd - data.frame(rate = mortrate, moe = 1.96 * sqrt(mortrate * (1 -
mortrate))/10,
hosp = factor(paste('H', 1:100, sep = '')))
dim(dd)
[1] 100 3
# Set
Hi:
One way to permute your sample 1000 times is to use the r*ply() function
from the plyr package. Let s denote your original vector, randomly generated
as follows:
s - rbinom(800, 0.6) # simulates your Yes/No vector
library(plyr)
u - raply(1000, sample(s))# generates a 1000 x
Always fun to follow up your own posts
The replicate() line should be
v - replicate(1000, sample(s)) # generates an 800 x 1000 matrix
Sorry for the bandwidth waste...
Dennis
On Mon, Oct 18, 2010 at 6:55 PM, Dennis Murphy djmu...@gmail.com wrote:
Hi:
One way to permute your sample
Hi:
On Sun, Oct 17, 2010 at 8:46 AM, Federico Bonofiglio bonori...@gmail.comwrote:
Dear Masters,
I have a question to submit
consider the following script
m-4.95
obs-rpois(36,m) # i generate 36 realization from a poisson(m)
hist(obs,freq=F)
curve(dpois(x,m),add=T,col=red) #i wish to
Hi:
I don't believe you've provided quite enough information just yet...
On Fri, Oct 15, 2010 at 2:22 AM, John Haart anothe...@me.com wrote:
Dear List,
I am doing some simulation in R and need basic help!
I have a list of animal families for which i know the number of species in
each
Hi:
You need to give a function for rollapply() to apply :)
Here's my toy example:
d - as.data.frame(matrix(rpois(30, 5), nrow = 10))
library(zoo)
d1 - zoo(d) # uses row numbers as index
# rolling means of 3 in each subseries (columns)
rollmean(d1, 3)
V1 V2 V3
2
about a half hour to rearrange the Theoph
data frame from nlme into shape so that I could get a plot that remotely
resembled what you were looking for. Alas, I don't have the time today to
do the same for this request.
HTH,
Dennis
On Fri, Oct 15, 2010 at 2:32 AM, Dennis Murphy djmu...@gmail.com
Hi Rob:
Are you thinking of the digitize package?
HTH,
Dennis
On Fri, Oct 15, 2010 at 1:46 PM, Rob James aetiolo...@gmail.com wrote:
Do I recall correctly that there is an R package that can take an image,
and help one estimate the x/y coordinates? I can't find the package,
thought it was
Hi:
Look into the rollmean() function in package zoo.
HTH,
Dennis
On Fri, Oct 15, 2010 at 12:34 AM, David A. dasol...@hotmail.com wrote:
Hi list,
I have a 1710x244 matrix of numerical values and I would like to calculate
the mean of every group of three consecutive values per column to
512 4 2
...
ect
I don't care if it's ggplot or something else as long as it looks like how
I envisioned.
On Fri, Oct 15, 2010 at 12:22 AM, Dennis Murphy djmu...@gmail.com wrote:
I don't recall that you submitted a reproducible example to use
Hi:
The essential problem is that after you append items, the result is a list
with possibly unequal lengths. Trying to convert that into a data frame by
the 'usual' methods (do.call(rbind, ...) or ldply() in plyr) didn't work (as
anticipated). One approach is to initialize a maximum size matrix
Hi:
On Thu, Oct 14, 2010 at 3:58 PM, Eugenio Larios
elari...@email.arizona.eduwrote:
Hi Everyone,
I am trying to analyze a split plot experiment in the field that was
arranged like this:
I am trying to measure the fitness consequences of seed size.
Factors (X):
*Seed size*: a continuous
Hi:
Here's a toy example: the first part is to create files and write them out
to the current directory.
# Create a dummy file and run it five times, creating five new .csv files
file - data.frame(x = rnorm(5), y = rnorm(5))
fnames - paste('file', 1:5, '.csv', sep = '')
# last column is an
Hi:
David was on the right track...
library(reshape) # for the melt() function below
rnorm(100,5,3) - A
rnorm(100,7,3) - B
rnorm(100,4,1) - C
df - melt(data.frame(A, B, C))
names(df)[1] - 'gp'
histogram(~ value | gp, data=df, layout=c(3,1), nint=50,
panel=function(x, ..., groups){
Hi:
This recent thread revealed that a package on R-forge for calculating earth
movers distance is available:
http://r.789695.n4.nabble.com/Measure-Difference-Between-Two-Distributions-td2712281.html#a2713505
HTH,
Dennis
On Tue, Oct 12, 2010 at 7:39 PM, Michael Bedward
Hi:
Perhaps
?append
for simple insertions...
HTH,
Dennis
On Wed, Oct 13, 2010 at 1:24 AM, dpender d.pen...@civil.gla.ac.uk wrote:
R community,
I am trying to write a code that fills in data gaps in a time series. I
have no R or statistics background at all but the use of R is proving
Hi:
On Tue, Oct 12, 2010 at 8:59 PM, Laura Halderman lk...@pitt.edu wrote:
Hello. I am new to R and new to linear mixed effects modeling. I am
trying to model some data which has two factors. Each factor has three
levels rather than continuous data. Specifically, we measured speech at
Hi:
On Wed, Oct 13, 2010 at 5:31 AM, dpender d.pen...@civil.gla.ac.uk wrote:
Dennis,
Thanks for that. The problem now is that I am trying to use it in a for
loop. Based on the example before, 2 entries are required after H[3] as
specified by O. The problem is that when inserting values
Hi:
This isn't particularly elegant, but I think it works:
# The function to be applied:
f - function(x, idx) {
n - length(x)
if(idx[1] idx[2]) {idx - seq(idx[1], idx[2])
} else { idx - c(seq(idx[1], n), seq(1, idx[2])) }
mean(x[idx])
}
# tests
month.data =
Hi:
Try
str(u.ts)
class(u.ts)
That should give you more information about the type of object being input
to stl.
I tried the following, which worked on my system:
u - rnorm(100)
u.ts - ts(u, start = c(2001, 1), frequency = 12)
u.stl - stl(u.ts, 'per')
plot(u.stl)
sessionInfo()
R version
Hi:
An alternative approach with a few less keystrokes, using the plyr package:
library(plyr)
# Create some example data files, populate them and write them out using
write.csv:
fnames - c(paste('file0', 1:9, '.csv', sep = ''))
for(i in seq_along(fnames)) {
d - data.frame(x = rnorm(3), y =
Hi:
Perhaps
dd - read.table(textConnection(
+ Vehicle Start End Time
+1A B5
+2A C4
+3A C3
+4B A6
+5B C4
+6B C6
+7C B2
+8C B
Hi:
On Thu, Oct 7, 2010 at 8:08 AM, Vangani, Ruchi rvang...@bcbsm.com wrote:
I am trying to use auto.arima to fit a univariate time series and do
forecast.
This is an imaginary data on monthly outcomes of 2 years and I want to
forecast the outcome for next 12 months of next year.
data
Hi:
Is this what you were looking for?
plate.id well.id Group HYB rlt1
P1 A1 control1SKOV3hyb0.19
P1 A2 disease1SKOV3hyb0.21
P1 A3 control1SKOV3hyb0.205
P1 A4 disease1SKOV3hyb0.206
P1
701 - 800 of 1170 matches
Mail list logo