For small matrix you could use a for-loop.
for (i in 1:nrow(randomized)){
randomized[i,randomized[i,]!=0] - sample(original[i,original[i,]!=0])
}
randomized
If you have a larger matrix sapply is probably faster
randomized - t(sapply(1:nrow(randomized), function(i) {
Are you sure, you want to calculate 68% confidence intervals?
Use the add-argument in ?errorbar to add to the previous plot.
errbar(x2,y2,y2+1.96*SD2, y2-1.96*SD2, col=green,pch=19, add=TRUE)
Best,
Nello
-Original Message-
From: r-help-boun...@r-project.org
reshape(dta, idvar=id, timevar=name, direction=wide)
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Nico Met
Sent: Mittwoch, 26. Juni 2013 13:38
To: R help
Subject: [R] Transpose of the rows
Dear R users,
I am using a big data
The formula in plotmeans compares vectors. This should work:
data - unlist(data)
times - rep(1:15, 100)
plotmeans(data~times)
Best,
Nello
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Simone Gabbriellini
Sent: Mittwoch, 26.
You have to define a function. For instance:
Afct - function(delta){
D - c(-1, -2/3, -1/3, 0, 1/3, 2/3, 1)
Dmat - matrix(D, nrow=7, ncol=7)
Smat - Dmat-t(Dmat)
A - exp(-(Smat/delta)^2)
return(A)
}
Afct(2)
Also try to avoid loops...
Best,
Nello
If you want the size to depend on the data, then size needs to be inside
aes(...). For instance:
stat_bin(aes(label = sprintf(%.01f, (..count../288)*100),
size=ifelse(..count..0, 2.5, 0)) ,color=red, vjust=-0.5, angle=0,
geom=text)
A better approach would be not to plot the unnecessary things at
Here's a possible solution to avoid the loop
k - as.matrix(expand.grid(1:ncol(x),1:ncol(x)))
a1 - as.data.frame(matrix(sapply(1:nrow(k), function(n)
agree(x[,k[n,]])$value), nrow=ncol(x)))
colnames(a1) - colnames(x)
rownames(a1) - colnames(x)
identical(a, a1)
[1] TRUE
Or if you want to avoid
diff(test$Y)/(test$Y)[-1] calculates (Y(t)-Y(t-1))/Y(t).
To get (Y(t)-Y(t-1))/Y(t-1) instead, use
diff(test$Y)/(test$Y)[-length(test$Y)]
or better
diff(test[,Y])/test[-nrow(test), Y]
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf
In line with what you are doing now, but saving the intermediate results
you could use something like this.
a3 - a0
for( i in 1:3)
{
a1 - a0$initial_size+a0$grow
a2- cbind(sp=a0$sp,initial_size=a1+i,yr=i)
a3 - cbind(a3, a2)
}
a3
However, I would suggest one of the following solutions
Check out the CRAN task view on time series analysis
http://cran.r-project.org/web/views/TimeSeries.html. There is a topic
Multivariate Time Series Models.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Aakanksha Dahiya01
Sent:
There are two separate issues that seem to be unclear.
Concerning the class assignment: You cannot assign a class to a
character string. You can assign a class to an object that contains a
character string:
a - b
# ok
class(a) - AONmode
# not ok
class(b) - AONmode
Error in class(b) - AONmode
abline(lm(Response1~Predictor,data=Site),col=colours[as.numeric(Site[1,1
])])
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Tom Wilding
Sent: Montag, 27. Mai 2013 12:40
To: r-help@r-project.org
Subject: [R] Indexing within by
Merge should do the trick. How to best use it will depend on what you
want to do with the data after.
The following is an example of what you could do. This will perform
best, if the rows are missing at random and do not cluster.
DF1 - data.frame(X.DATE=rep(01052007, 7), X.TIME=c(2:5,7:9)*100,
If you want to use the character string:
attach(dftest)
aggregate(cbind(sapply(x_test, get))~z, data=dftest, FUN=mean)
# or
with(dftest,aggregate(cbind(sapply(x_test, get)),list(z),FUN=mean))
detach(dftest)
Cheers,
Nello
-Original Message-
From: r-help-boun...@r-project.org
It looks like you should use by instead of tapply.
Anyway, if you use dput(data) for sharing your data, it is much easier
to get help.
Best,
Nello
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Simonas Kecorius
Sent:
Here are two possible ways to do it:
This would simplify your code a bit. But it changes the names of x_cs to
cs.x.
for (df in nls) {
assign(df, cbind(get(df), cs=apply(get(df), 2, cumsum)))
}
This is closer to what you have done.
for (df in nls) {
print(df)
for (var in names(get(df)))
You could use bquote. Something like this:
a-c(1,2,3,4)
b-c(1,2,3,4)
nTrials - length(a)
for (trial in 1:nTrials) {
plot(x=a[1:trial], y=b[1:trial],
ylab=expression(paste(Apple[P])),
xlab=expression(paste(Banana^th)),
main=bquote(italic(i-)~.(trial)^th~choice))
Not sure this fixes your problem, but as far as I can know (and can tell from
the manual: http://cran.r-project.org/doc/manuals/r-release/R-exts.pdf),
importFrom needs to know what functions you are importing [e.g.
importFrom(Hmisc, latex) importFrom(stats, anova)].
-Original
Perhaps write.dta(..., convert.factors=string) might help.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of chong shiauyun
Sent: Mittwoch, 10. April 2013 10:01
To: r-help@r-project.org
Subject: [R] Levels and labels in factor
Hi R
I would suggest to try different starting values. The following works
for instance:
n2-nls(proc~f(cls,a,b,c,d),data=bline,start=list(a=1000,b=-1,c=4,d=1),t
race=TRUE)
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Jorge I Velez
Here's a possible solution.
dd - structure(list(a = c(TRUE, FALSE, FALSE),
b = c(TRUE, FALSE, TRUE),
c = c(TRUE, FALSE, FALSE),
d = c(TRUE, TRUE, FALSE)),
.Names = c(a, b, c, d),
row.names = c(NA,
Try ?View()
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Ted Harding
Sent: Dienstag, 26. März 2013 11:09
To: r-help@r-project.org
Subject: [R] edit.data() read-only?
Greetings All.
The function edit.data() allows a convenient
Only positive values of n are allowed into the loop...
More importantly, is n ever larger than 52??? Because that results in nk20
(for k=1) and undefined gamma(nk2). Same goes for sn, if n100.
Next time you may also want to write a reproducible example!
-Original Message-
From:
You can use the par function instead.
require('vioplot')
data1-rnorm(100)
data2-rnorm(10)
data3-rnorm(1000)
par(cex.lab=2, cex.axis=2)
vioplot(data1,data2,data3)
Best,
Nello
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Alaios
Matrix Multiplication ?%*%
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Shane Carey
Sent: Montag, 25. März 2013 13:31
To: r-help@r-project.org
Subject: [R] %*% what does this mean
Hi
I was working with a script and I came
The two confidence intervals should be different. In the first model you have 3
failures and the second one you have 300. More failures results in narrower
confidence intervals.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of
Why do you first say min(Datos$x) and then give the numeric value of this
minimum? Just delete all numerical values:
danta=ppp(Datos$x, Datos$y, c(min(Datos$x), max(Datos$x)),
c(min(Datos$y), max(Datos$y)))
or if you really want to type the numeric constants (probably a bad idea)
Instead of NaN's, I get the error message: Error in eval(expr, envir, enclos) :
object 'z' not found. The reason you get the NaN's is, because you defined z in
your global environment. The deltaMethod doesn't find the z defined in your
function. I don't know why or how to fix this. Somebody
It isn't entirely clear to me if you want to remove duplicates or expand your
matrix. Check ?unique or ?expand.grid. Here are some guesses of what you may
want to do.
unique(TimeIndex)
expand.grid(as.data.frame(TimeIndex))
expand.grid(as.data.frame(unique(TimeIndex)))
TimeIndex2 -
The plot shows the variation for each component and mypc$sdev gives you the
standard deviation.
If you want to know the variation, use mypc$sdev^2.
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Dimitri Liakhovitski
Sent:
Under ?adaptIntegrate, you will find the link to
http://ab-initio.mit.edu/wiki/index.php/Cubature#Infinite_intervals, where it
says that Integrals over infinite or semi-infinite intervals is possible by a
change of variables.
-Original Message-
From: r-help-boun...@r-project.org
It seems like this is what you want to do, although there is probably a better
way to do it.
A.DT - data.table(a1 = A.DT[,a1],
a2=sort(ifelse(B.DT[,b2] = N/2 B.DT[,b1]
A.DT[nrow(A.DT):1,a1],
B.DT[nrow(A.DT):1,b1],
with(price.lookup, list(Price_Line)) is a list! Use
unique(unlist(with(price.lookup, list(Price_Line
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Barry King
Sent: Freitag, 15. März 2013 09:34
To: r-help@r-project.org
Is this what you want to do?
D2 - expand.grid(Class=unique(D$Class), X=unique(D$X))
D2 - merge(D2, D, all=TRUE)
D2$Count[is.na(D2$Count)] - 0
W - aggregate(D2$Count, list(D2$Class, D2$X), sum)
W
Best,
Nello
-Original Message-
From: r-help-boun...@r-project.org
One way is to use the do.call function. For example:
ret2 - lapply(X=mylist2,
FUN=do.call,
what=function(...) f2(y=Y, ...))
Best,
Nello
-Original Message-
Date: Tue, 12 Mar 2013 22:37:52 -0400
From: Benjamin Tyner bty...@gmail.com
To: r-help@r-project.org
Subject: Re:
Does it just not work or does it not do the right thing? The reason it doesn't
work is that you are writing 'T = length(returns) x_foc = vector(length=n) N =
T-(n+1)' on one line instead of using three lines. However, your description of
what you want to do also doesn't seem to correspond to
36 matches
Mail list logo