Hello.
I've just started using R and am trying to figure out if the two codes
snippets below have the same output
gBest-floor(runif(popsize,min=1,max=top))
velocity[i,j]-.4* velocity[i,j] + 1 * runif(1) * (pbestsVar[i,j] -
popVar[i,j]) + 1 * runif(1) * (archiveVar[gBest,j] - popVar[i,j])
and
Ravi Varadhan rvaradhan at jhmi.edu writes:
Interesting!
Now, if I change the cost matrix, D, in the LSAP formulation slightly
such that it is quadratic, it finds the best solution to your example:
Dear Ravi,
I thought your solution is ingenious, but after the discussion with
Erwin
On 01/17/2010 04:05 AM, alessia matano wrote:
Dear all,
I am trying to apply the sapply function on a list, which comes out
from a matrix of 25 rows and two columns, so that each element of the
list, is a two column element. In my function within sapply, say f, I
would like each element of the
On Sat, Jan 16, 2010 at 11:56 PM, Peter Ehlers ehl...@ucalgary.ca wrote:
Marius Hofert wrote:
Dear ExpeRts,
I have the scatter plot matrix as given below. I would like the different
sub-plots in the scatter plot matrix to be colored differently. How do I
get all points shown in the
Dear list
I am trying to count the no of occurances in a column of a data frame and there
is missing data identifed by NA.
I am able to melt and cast the data correctly as well as sum the occurances
using margins and sum.
Here are the melt and cast commands
bw = melt(res, id=c(lab,r),
Sorry to repeat the meassage, not sure if the HTML version has been
received - Apologies for duplication
Dear list
I am trying to count the no of occurances in a column of a data frame and
there is missing data identifed by NA.
I am able to melt and cast the data correctly as well as sum
Hello,
I am a newbie.
I can run the following code stored in test.txt without error using my
XP machine:
x - scan(C:\\Rwork\\A.txt)
x10 = filter(x, rep(1/10,10), sides=1)
x
x10
for(i in 10:length(x)){
if (x[i] x10[i]) diff[i]=b else diff[i]=s
}
However, if I run it in another PC that
Dear list,
is there a command that selects every second value from a given vector?
For instance,
a - c(1,2,3,4,5,6)
should yield
1,3,5
and
2,4,6
which i intend to place into two seperate vectors.
best
Alex
__
R-help@r-project.org mailing list
try this:
a - c(1,2,3,4,5,6)
n - length(a)
a[seq(1, n, 2)]
a[seq(2, n, 2)]
I hope it helps.
Best,
Dimitris
Walther, Alexander wrote:
Dear list,
is there a command that selects every second value from a given vector?
For instance,
a - c(1,2,3,4,5,6)
should yield
1,3,5
and
2,4,6
Instead of making two vectors, you
might want to just have one matrix
with two rows:
amat - matrix(a, nrow=2)
Then you can do:
amat[1,]
amat[2,]
Patrick Burns
patr...@burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of The R Inferno and A Guide for the Unwilling S User)
Its likely that in one of your sessions you do have a diff and in the
other you don't and this has nothing to do with XP vs. Windows 7. In
the session with no diff, the only diff around is the function, diff,
and you can't subscript a function.
Try this to see what variables are in your
Dear Erwin, Ravi and Hans Werner,
thanks a lot for your replies. I don't think I have access to Cplex and
therefore probably cannot try that out but will read about MIQP.
I played a bit then around with Ravi's suggestions and made also the
observation that the linear cost function often found
On Jan 17, 2010, at 5:31 AM, Steve Sidney wrote:
Sorry to repeat the meassage, not sure if the HTML version has been
received - Apologies for duplication
Dear list
I am trying to count the no of occurances in a column of a data
frame and there is missing data identifed by NA.
I am able
Dear Hans,
I agree with your comments. My intuition was that the quadratic form would be
better behaved than the radical form (less nonlinear!?). So, I was hoping
to see a change in behavior when the cost function was altered from a radical
(i.e. sqrt) form to quadratic, but I was still
Dear R-users,
i have a simple problem maybe, but i don't see the solution. i want to
find the entry-wise closest element of an vector compared with another.
ind1-c(1,4,10)
ind2-c(3,5,11)
for (i in length(ind2):1)
{
print(which.min(abs(ind1-ind2[i])))
}
for ind2[3] it should be ind1[3] 10,
Deepayan Sarkar wrote:
On Sat, Jan 16, 2010 at 11:56 PM, Peter Ehlers ehl...@ucalgary.ca wrote:
Marius Hofert wrote:
Dear ExpeRts,
I have the scatter plot matrix as given below. I would like the different
sub-plots in the scatter plot matrix to be colored differently. How do I
get all points
Hey all,
I read in a paper about the zipf distribution, which seems different from
what i learned here. It says: we can generate a random dataset of pairs of
the form (x,y). By modifying some variable Z during data generation, we can
generate dataset where x and y can be closely correlated or
Klaus,
I am happy to know that the quadratic cost LSAP seems to work well for you.
The Hungarian algorithm is a classic for solving linear sum assignment problem,
which is closely related to matching in bipartite graphs. You can google or
wiki these terms to get papers and books on this
On Jan 17, 2010, at 11:00 AM, Andreas Wittmann wrote:
Dear R-users,
i have a simple problem maybe, but i don't see the solution. i want
to find the entry-wise closest element of an vector compared with
another.
ind1-c(1,4,10)
ind2-c(3,5,11)
for (i in length(ind2):1)
{
Is it not giving you the location of the minimum value not the value?
See
ind1-c(1,4,10)
ind2-c(3,5,11)
i=3
(ind1-ind2[i])
(aa - abs(ind1-ind2[i]))
which.min(aa)
--- On Sun, 1/17/10, Andreas Wittmann andreas_wittm...@gmx.de wrote:
From: Andreas Wittmann andreas_wittm...@gmx.de
Subject: [R]
David
Thanks, I'll try that..but no what I need is the total (1's) for each of
the rows, labelled 1-6 at the top of each col in the table provided.
What I guess I am not sure of is how to identify the col after the melt and
cast.
Steve
- Original Message -
From: David
Hi Steve,
It's still not clear to me what you want. Please give a minimal
example so I can understand what you're trying to do.
-Ista
On Sun, Jan 17, 2010 at 11:56 AM, Steve Sidney sbsid...@mweb.co.za wrote:
David
Thanks, I'll try that..but no what I need is the total (1's) for each of
Thank you very much for your quick answers.
Sorry, but i forgot to explain i want to find the closest and smaller
element for each entry, so ind1[3] is smaller as 11 and close to 11,
ind1[2] is smaller as 5 and close to 5 and ind1[1] is smaller than 3 and
close to 3.
best regards
Andreas
On Jan 17, 2010, at 11:56 AM, Steve Sidney wrote:
David
Thanks, I'll try that..but no what I need is the total (1's) for
each of the rows, labelled 1-6 at the top of each col in the table
provided.
Part of my confusion with your request (which remains unaddressed) is
what you mean
I don't think it is that simple because it is not a one-to-one match. In
the arr data frame, there are many arrivals in a quarter hour with good
weather on a given day. So I need to match the date and the quarter hour.
And all of the rows in the weather data frame are times with good
On Jan 17, 2010, at 12:30 PM, Andreas Wittmann wrote:
Thank you very much for your quick answers.
Sorry, but i forgot to explain i want to find the closest and
smaller element for each entry, so ind1[3] is smaller as 11 and
close to 11, ind1[2] is smaller as 5 and close to 5 and ind1[1]
Hallo together,
I want to write a formula of the type
http://n4.nabble.com/file/n1016112/expression.gif
into my plot, where the values 1.234 and -0.567 should origin from variables
in the program. The threads in this forum gave me some ideas that the
functions expression(), paste(), and
On 17.01.2010 18:47, rrookie1982 wrote:
text(0,7.5,substitute(expression(paste(symbol(t),(A) = ,c1 +
lg(A^c2),sep=)),list(c1=0,456,c2=-0.123)),pos=4)
It is much easier, just write the formula down in R syntax and
substitute the relevant variables as in:
text(0, 7.5, substitute(tau(A) ==
On Jan 17, 2010, at 12:37 PM, James Rome wrote:
I don't think it is that simple because it is not a one-to-one
match. In
the arr data frame, there are many arrivals in a quarter hour with
good
weather on a given day. So I need to match the date and the quarter
hour.
And all of the rows
Try bquote:
a - 0.1; b - 0.2
plot(0, main = bquote(tau(A) == .(a)*lg(A^.(b
On Sun, Jan 17, 2010 at 12:47 PM, rrookie1982 dess...@uni-bonn.de wrote:
Hallo together,
I want to write a formula of the type
http://n4.nabble.com/file/n1016112/expression.gif
into my plot, where the
Bingo,
I knew it was something simple and that I wasn't seeing the wood for the
trees.
David, Ista
Apologies for the vague description, which I thought was clear enough, but
yes I now think that I understand that I need to count the 1's and be able
to sum the total of 1' and 0's by
On 1/17/10 1:06 PM, David Winsemius wrote:
On Jan 17, 2010, at 12:37 PM, James Rome wrote:
I don't think it is that simple because it is not a one-to-one match. In
the arr data frame, there are many arrivals in a quarter hour with good
weather on a given day. So I need to match the date
SInce you provided no data, it is hard to determine how to compare. If you
also want the date, then the following will work:
arr$GoodWeather - arr$quarter %in% gw$quarter arr$date %in% gw$date
If your quarter is just the minutes of arrival, you may have to convert
that to the appropriate
Hello - I'm trying to construct a coplot to check the residuals conditioned
on a factor using the following formula, however I keep getting an error
message. I've used the same formula for another data set and it worked fine
- the only difference is that now I have missing values for each level
I thought it would be possible to make rep() work for functions
by writing a method for the function class. I tried:
rep.function - function(x,...) {
times - as.list(...)[[1]]
rslt - vector(list,times)
rslt[1:times] - list(x)
rslt
}
But then doing
rep(sin,2)
still gave an error
Hello Alan,
Following up on Gabor's suggestion, if you have different packages
loaded, one of those packages could have a function 'diff' that would
not show up with a call to ls() so you could also try
search()
which will show you what packages are loaded.
HTH,
Joshua
On Sun, Jan 17, 2010
On 18/01/2010, at 9:02 AM, Joshua Wiley wrote:
Hello Alan,
Following up on Gabor's suggestion, if you have different packages
loaded, one of those packages could have a function
Object?
'diff' that would not show up with a call to ls() so you could also
try
search()
which will
On Sun, 17 Jan 2010, Andreas Wittmann wrote:
Thank you very much for your quick answers.
Sorry, but i forgot to explain i want to find the closest and smaller element
for each entry, so ind1[3] is smaller as 11 and close to 11, ind1[2] is
smaller as 5 and close to 5 and ind1[1] is smaller
No, I cannot find counterexamples, so that actually seems to give identical
solutions! That is fantastic.
I guess my homework is now convince myself we can go from this quadratic
objective
sum_i,j [ sum_k P[i,k]*G[k,j] - I[i,j] ]^2
to a linear one:
sum_i,j c[i,j]*P[i,j]
Thanks !
Erwin
2010/1/16 Thomas Lumley tlum...@u.washington.edu:
On Sat, 16 Jan 2010, Vera wrote:
Thanks for your help so far, everyone.
Thomas: I haven't looked very deep into the survey package yet, so I
don't know if what I'm looking for is actually missing or if I just
haven't found it yet.
What is
Well now I am totally baffled !!
Using
sum( !is.na(b[,3])) I get the total of all col 3 except those that are NA -
Great solves the first problem
What I can't seem to do is use the same logic to count all the 1's in that
col, which are there before I use the cast with margins.
So it
Thank you Dennis.
arr$gw - as.numeric(weather$Date == arr$Date arr$quarter %in%
weather$quarter)
seems to be what I want to do, but in fact, with the full data set, it
misidentifies the rows, so I think the error message must mean something.
arrr$Date -
Hello,
This turned out to be surprisingly hard for me:
Let's say I have
mm = matrix(as.character(seq(1,30, 1)), nrow=3); mm
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 4 7 10 13 16 19 22 25 28
[2,] 2 5 8 11 14 17 20 23 26 29
[3,] 3 6 9 12 15 18 21 24 27
Ravi Varadhan rvaradhan at jhmi.edu writes:
Dear Hans,
I agree with your comments. My intuition was that the quadratic
form would be better behaved than the radical form (less
nonlinear!?). So, I was hoping to see a change in behavior when
the cost function was altered from a radical
Try this:
class(mm) - numeric
On Sun, Jan 17, 2010 at 5:17 PM, ivan popivanov
ivan.popiva...@hotmail.com wrote:
Hello,
This turned out to be surprisingly hard for me:
Let's say I have
mm = matrix(as.character(seq(1,30, 1)), nrow=3); mm
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
Dear list-members,
I am moving some of my heavy processing to a new machine (running SuSE
Enterprise Linux 10 SP2)
and I need packages 'extRemes' and 'ismev'loaded within a BATCH process (to
calculate a confidence
interval in a GPD model using the profile likelihood method).
My problem is that
Hi,
I find the following works in R 2.10.1 on Mac OSX.
m = matrix(rep(3, 30), 5,6)
m
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 3 3 3 3 3 3
[2,] 3 3 3 3 3 3
[3,] 3 3 3 3 3 3
[4,] 3 3 3 3 3 3
[5,] 3 3 3 3 3 3
apply(m, 1,as.numeric)
[,1] [,2] [,3] [,4] [,5]
[1,]3
In respect of your matrix problem:
(1) mode(mm) - numeric
OR:
(2) mm - apply(mm,2,as.numeric)
In respect of your data frame problem:
as.data.frame(lapply(X,as.numeric))
(where X is your data frame) should work. This will of course
convert every column of your data frame to numeric
On Jan 17, 2010, at 4:37 PM, Steve Sidney wrote:
Well now I am totally baffled !!
Using
sum( !is.na(b[,3])) I get the total of all col 3 except those that
are NA -
Great solves the first problem
What I can't seem to do is use the same logic to count all the 1's
in that
col,
My guess (since we still have no data on which to test these ideas)
is that you need either to merge() or to use a matrix created from the
dates and qtr-hours entries in gw, since matching on dates and hours
separately will not uniquely classify the good qtr-hours within their
proper
Hello again,
On Jan 17, 2010, at 5:42 PM, Rolf Turner wrote:
Notice that your output is 6 x 5 whereas your input is 5 x 6.
Now *what* did you do wrong?
Whoa! Let's try that again, but with a better example.
X = matrix(as.character(1:6),2,3)
X
[,1] [,2] [,3]
[1,] 1 3 5
[2,] 2
On Sun, 17 Jan 2010, Vera wrote:
2010/1/16 Thomas Lumley tlum...@u.washington.edu:
On Sat, 16 Jan 2010, Vera wrote:
Thanks for your help so far, everyone.
Thomas: I haven't looked very deep into the survey package yet, so I
don't know if what I'm looking for is actually missing or if I just
Here are some sample data sets.
I also tried making a combined field in each set such as
adq=paste(as.character(arr$Date), as.character(arr$quarter))
and similarly for the weather set, so I have unique single things to
compare, but that did not seem to help much.
Thanks,
Jim
On 1/17/10 5:50 PM,
Hi Steve,
These might help.
#generate some example data similar to your original email, with one extra
line containing all NAs (first col included to provide similarity with your
data)
labs - c('4er66', '4gcyi', '5d3hh', '5d3wt', 'v3st5', 'a22g5', 'b5dd3',
'g44d2', 'z')
dat - scan()
1 NA 1
I want to learn content-type of a file. what should I do?
In my code I want to do:
I give an url to download.
the function learns the content-type and
if it is a text file downloads it.
else will raise an error.
[[alternative HTML version deleted]]
Never used coplot, but why not try removing the rows with missing variables?
Perhaps with:
dat - cbind(E2=resid(baea.ancova6, type = normalized), year, population)
coplot(E2~year|population, data=dat[apply(dat, 1, function(x) !any(is.na
(x))),])
Regards,
Simon Knapp
On Mon, Jan 18, 2010 at 6:54
But, but, but there is no weather goodness variable in
weather?!?!?!
str(weather)
'data.frame': 155 obs. of 4 variables:
$ Date :Class 'Date' num [1:155] 14245 14245 14245 14245 14245 ...
$ minute : int 5 15 30 45 0 15 30 45 0 15 ...
$ hour : int 15 15 15 15 17 17 17 17 18
Any entry in the weather data is a good day. That is the point. And
please ignore my mistake about the quarters getting too large in
weather. I am being swamped with versions, and it does not matter for
this purpose.. so, the bad weather days are not in the weather data set.
I am trying to get
Hello,
I'm am in the process of trying to port a RATS functions to R and have
the problem, that RATS allows for the creation of submatrixes that are
linked to their basematrix.
Basically it should work like this:
a = matrix(1:(4*3),4,3)
a
# [,1] [,2] [,3]
# [1,]159
# [2,]2
There must be a very basic thing I am not getting...
I'm working with some entropy functions and the convention is to use
log(0)=0.
So I wrote a function:
llog-function(x){
if (x ==0) 0 else log(x)
}
which seems to work fine for individual numbers e.g.
llog(0/2)
[1] 0
but if I try whole
Are you telling us the whole story? Or did you also
get a warning message which should have twigged the
answer for you?
Try ifelse() instead of if().
-Peter Ehlers
maiya wrote:
There must be a very basic thing I am not getting...
I'm working with some entropy functions and the convention is
On Jan 17, 2010, at 8:17 PM, maiya wrote:
There must be a very basic thing I am not getting...
I'm working with some entropy functions and the convention is to use
log(0)=0.
I suppose the outcome of that effort may depend on whether you have
assumed the needed godlike capacities to
David Winsemius dwinsemius at comcast.net writes:
On Jan 17, 2010, at 8:17 PM, maiya wrote:
There must be a very basic thing I am not getting...
I'm working with some entropy functions and the convention is to use
log(0)=0.
I suppose the outcome of that effort may depend on
Gabor,
about problem 1. , now I understand.
But in problem 2. , I do as your recommandation. and it still doesn't work.
I wonder is there any detail introduction about the form of the 'FUN' in the
'rollapply'?
Can you help me again?
Thank you very much!
Best regard
Saji
There is no quantile
sorry for bothering you again,
the problem solved. the command should be :
uprange=rollapply(zoo(x),width=10,FUN=function(x)quantile(x,0.8),align='right')
Gabor Grothendieck wrote:
There is no quantile method defined for zoo objects so it falls
through to the default method but that method
rrookie1982 wrote:
I want to write a formula of the type
http://n4.nabble.com/file/n1016112/expression.gif
into my plot, where the values 1.234 and -0.567 should origin from
variables in the program.
Uwe Ligges-3 wrote:
It is much easier, just write the formula down in R
Hello all:
I've read the document named A Brief Introduction to R, the multilevel package
and the nlme package.
At p68, one can transform the dataset to the required format by using
make.univ.
I wanna know,how the new variable MULTDV is calculated(can you show me the
formula if possible
67 matches
Mail list logo