Displaying 20 results from an estimated 4000 matches similar to: "matrix and a function - apply function"
2011 Jan 01
3
How to make this script ask again
Hi,
as an example I have made this script to give the user the answer if a
number is odd or even:
{
cat("Please, enter a number (Zero ends)")
n<-scan(n=1)
if(n==0)break
i<-("The number is odd")
p<-("The number is even")
if (n%%2==0)
p else i
}
If you run this script it will only work once, I mean, after it gives you
the answer is won't ask for
2011 Jan 06
4
Creating a Matrix from a vector with some conditions
Hi
Suppose we have an object with strings:
A<-c("a","b","c","d")
Now I do:
B<-matrix(A,4,4, byrow=F)
and I get
a a a a
b b b b
c c c c
d d d d
But what I really want is:
a b c d
b c d a
c d a b
d a b c
How can I do this?
thank you
A. Dias
--
View this message in context:
2011 Jan 04
5
Help with "For" instruction
Hi,
I am having a problem in doing something similar to this example:
Suppose I have this vector a, and from it I wish to create 5 other vector
each one with less one value than what object a has
So I have "a"
a<-c(1,2,3,4,5)
and I want
a1 that shoud have (2,3,4,5)
a2 that should have (1,3,4,5)
a3 that should have (1,2,4,5)
a4 that should have (1,2,3,5)
a5 that should have
2011 Apr 25
2
[LLVMdev] inserting a fucntion call at the end of basic bloc
hi all,
i would like insert a fucntion call at the end of each basic bloc
the fucntion i have defined and declared at the begining of the module
ie i have written a pass derived from a module pass
virtual bool runOnModule(Module & M){
// i declared the fucntion and defined it
for (Module::iterator a = M.begin(), b = M.end(); a != b;
for (Function::iterator i = a->begin(), e =
2011 Jan 18
4
Relative frequency on a character vector
Hi,
I have this character vector:
A<-c("Tell me how many different letter this vector has?")
Is there a way with R that it can let me know how many different letters I
have on this vector?
If I use nchar(A) que gives me the number 50. With this function he is
counting all the letters present and also spaces between the words. Can we
also not count the spaces between words?
Then
2011 Feb 01
3
sum the values in a vector as a complete number
Hi
I am trying to create a function that is able to calculate this sum:
a<-c(2,3,5)
b<-(8,7)
with "a" meaning 235 and "b" 87. So the result of this sum would be 235 + 87
= 322.
I've searched a function like strsplit but that worked for integers and in
reverse - not spliting but combining.
Can you give me a hand on this please?
thanks
AD
--
View this message in
2011 Apr 25
2
[LLVMdev] inserting a fucntion call at the end of basic bloc
2011/4/25 Duncan Sands <baldrick at free.fr>
> Hi Nabila,
>
> > i would like insert a fucntion call at the end of each basic bloc
>
> you can't, because only terminators are allowed at the end of a basic
> block.
> However you can try to insert the call before the terminator.
>
Yes, i mean before the termininator,
My problem is how to call a method
suppose
2008 Jan 26
1
Loosing IAX/SIP user's registration with asterisk as no-root
Hello list, hope some one could help me find the answer.
Asterisk 1.4.16.2 installd as no-root user
The main issue is that every now and then, cd * box seems to loose the
user's registrations, there is nothing in the console, absolutely no
messages, only when another friend trys to dial an extension I can see this
on messages logs
[Jan 26 10:35:46] WARNING[23015] app_dial.c: Unable to
2010 Nov 17
3
Parameterising apply To Compute Rolling Average of Columns in a matrix
I sent a post to find a clever way to compute a Rolling Average of columns
in a matrix and I was given the solution below which I am very pleased
with.
RollingAverage <- function(x, RollingObs) {
cx <- cumsum(x);
N <- length(x);
Temp <- (cx[RollingObs:N] - c(0, cx[1:(N-RollingObs)]))/RollingObs
Output <- array(NA, N)
Output[RollingObs:N] <- Temp;
Output
}
The only
2011 Jan 06
2
Help with IF operator
Hi,
I am with a problem on how to do a comparison of values. My script is as
follows:
repeat{
cat("How many teams to use? (to end write 0) ")
nro<-scan(n=1)
if(nro==0)break
cat("write the", nro, "teams names \n")
teams<-readLines(n=nro)
if (teams[1]==teams[2)next
else print(teams)
}
On this example I only compare teams 1 name with teams 2 name, and if they
2011 Apr 25
0
[LLVMdev] inserting a fucntion call at the end of basic bloc
Hi Nabila,
> My problem is how to call a method
> suppose this fucntion
> void A(int x)
> {
> x=x+1;
>
> }
>
> should i define this function and declare it at the beginig of the module and
> create for it a basic bloc?
you can just declare the function (i.e. no need to give it a body), and call it.
You can then link with an object file that defines it. This is
2011 Apr 26
2
[LLVMdev] inserting a fucntion call at the end of basic bloc
I have defined the fucntion in another object file and linked it to the
in fact the fucntion is :
void consume(int , int * );
std::vector<Value*> int32_16_params;
int32_16_params.push_back(inValue);//inValue is ConstantInt* inValue
int32_16_params.push_back(gvar_int32_y);
CallInst* int32_16 = CallInst::Create(func_consume, int32_16_params.begin(),
int32_16_params.end(), "",
2011 Apr 25
0
[LLVMdev] inserting a fucntion call at the end of basic bloc
Hi Nabila,
> i would like insert a fucntion call at the end of each basic bloc
you can't, because only terminators are allowed at the end of a basic block.
However you can try to insert the call before the terminator.
...
> i tried to see an example with the demo, i saw that it instead of calling the
> function, it repeats all the instruction that are existing in the function
>
2011 Apr 26
2
[LLVMdev] inserting a fucntion call at the end of basic bloc
2011/4/26 Duncan Sands <baldrick at free.fr>
> Hi Nabila,
>
>
> Now when i tried this pass an error says:
>> Wrong type for attribute noalias
>> tail call void @consume(i32 noalias 3, i32* @y) nounwind
>>
>
> noalias is only for arguments of pointer type. You probably meant it to
> be on the second argument rather than the first. I suggest you
2011 Sep 03
3
question with uniroot function
Dear all,
I have the following problem with the uniroot function. I want to find
roots for the fucntion "Fp2" which is defined as below.
Fz <- function(z){0.8*pnorm(z)+p1*pnorm(z-u1)+(0.2-p1)*pnorm(z-u2)}
Fp <- function(t){(1-Fz(abs(qnorm(1-(t/2)))))+(Fz(-abs(qnorm(1-(t/2)))))}
Fp2 <- function(t) {Fp(t)-0.8*t/alpha}
th <- uniroot(Fp2, lower =0, upper =1,
2009 Jan 08
2
VaR-Monte carlo Simulation, Historic simulation, Variance-Covariance Simulation
Dear R helpers
Suppose I have a portfolio of securities with exposure to Equity, Bonds and Forex (say $ 1000000 each).
Is there any fucntion in R that will help me calculate Value at Risk (VaR) using Monte carlo Simulation , Historic simulation and Variance - Covariance Simulation.
With regards
Maithili
2005 Jun 27
2
Reconstructing LD function
Dear all,
in an LDA analysis with n groups n-1 LD functions result. Implicitly this
defines an LD fucntion for the last group. Does there exist code already
to explictly construct this LD function?
Thanks, Stefan
2005 Nov 16
2
Newton-Raphson
Dear all,
I want to solve a score function by using Newton-Raphson algorithm. Is there such a fucntion in R? I know there's one called optim, but it seems only doing minimizing or maximizing.
Thanks,
Jimmy
2013 Aug 27
1
return the name of source.
Is there a fuction that will allow me to retrun the filename for a script
from within that script.
fir instance
If I have a script "myscript.r":
FileName<-unknown.fucntion()
print(FileName)
and run it
source("myscript.r")
will return
"myscript.r"
Thanks
Nevil Amos
[[alternative HTML version deleted]]
2004 Mar 11
5
fft question
Hi!
I am using the fft() function the base package to transform some 1d signal.
If I use this standar fucntion I get a very huge first fourier coeficient.
I think this dues to the handling of the borders of the signal.
Usually in fft especially in image processing the signal is simulated to be continuous by adding the signal several times periodically. My question is, is there some function