Displaying 20 results from an estimated 500 matches similar to: "Help me please to code...."
2008 May 21
2
Problem in converting natural numbers to bits and others
Hi,
I just started using R for about one week and I have few problems.
i)I have a problem in finding right function to convert a table of natural
numbers to bitwise. For a simple example;
I have the below table:-
Column Col1 Col2 Col3
Sample1 5 7 10
Sample2 0 2 1
Sample3 4 0 0
Supposedly i wanted to convert to :-
Column Col1 Col2 Col3
2012 Oct 22
5
Help plz to fix it
I have an array of probabilities....it is p. So if user types x=1 then
probability is p1=1/10.
If user types x=2 it means that p2= p1+p2
if user types x=3 it means that p3=p1+p2+p3....and so on.
So i created a code..... but it doesnt work properly. Help me plz to fix it)
Thank u in advance.
psidp=function(x){
p<-(1/10 2/5 2/5 2/5 2/5 1/10 1/10 1/10 1/10 1/10)
i==0;
if (x!=0){
for
2012 Oct 25
3
How generate random numbers from given vector???
I wanna generate random numbers from a vector...
for example number<-c(0,1,3,4,5,6,8)
so
rsidp<-function(x){
i=0
for (i in seq(1:x))
{y<-sample(number,x, replace=T)}
return(y)
}
so all random numbers have to be from vector "number";
so if I type rsidp(5)..... it has to give me 5 random numbers except 2,7,9
(because they are not in the vector "numbers"). help
2012 Nov 08
5
map two names into one
Thanks.
Yes. Your approach can identify:
Glaxy ace S 5830 and
S 5830 Glaxy ace
But you can not identify using same program:
Iphone 4S 16 G
Iphone 4S 16G
How should I solve both in same time.
Kind regards,Tammy
[[alternative HTML version deleted]]
2011 Apr 07
2
Two functions as parametrs of a function.
Hi R users:
I'm trying to make a function where two of the parameters are
functions, but I don't know how to put each set of parameters for
each function.
What am I missing?
I try this code:
f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){
force(fun1)
force(fun2)
force(n)
p1<-unlist(par1)
p2<-unlist(par2)
force(p1)
force(p2)
2002 Sep 17
3
[LLVMdev] questions
Sorry I got really overwhelmed by so many classes and member
functions in LLVM. So would you please clarify some problems
I have?
1. If I see this instruction in the function.
%S.i = alloca %struct.SimpleStruct
Suppose SimpleStruct is as following:
struct.SimpleStruct = type { int, double }
When I read the instruction, how can I know the type of
simplstruct, should I use 'getType'
2012 Aug 30
1
How to modify the values of the parameters passing via ...
Dear Friends,
Let's assume there are three parameters that were passed into fun1. In
fun1, we need to modify one para but the remains need to be untouched. And
then all parameters were passed into fun2. However, I have failed to
achieve it.
Please see the following code.
##########################################
fun1 <-function(x, y, z=10) {x+y+z;}
fun2 <-function(aa, ...) {
2006 Aug 09
3
objects and environments
Dear list,
I have two functions created in the same environment, fun1 and fun2.
fun2 is called by fun1, but fun2 should use an object which is created in fun1
fun1 <- function(x) {
ifelse(somecondition, bb <- "o", bb <- "*")
## mymatrix is created, then
myresult <- apply(mymatrix, 1, fun2)
}
fun2 <- function(idx) {
if (bb == "o) {
#
2012 Nov 20
2
correct function formation in R
Dear list!
?
I have question of?'correct function formation'. Which function (fun1 or fun2; see below) is written more correctly? Using ''structure'' as output or creating empty ''data.frame'' and then transform it as output? (fun1 and fun1 is just for illustration).
?
Thanks a lot, OV
?
code:
input <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 =
2004 Mar 25
1
mlocal/mtrace inside a loop
Hello
I need some help in figuring Bravington’s debugger
out.
Ok
I have 2 functions, fun1 and fun2 saved in a ASCII
file say filename is funs.
Fun1 has a loop which calls fun2, fun2 has a loop
which fails and I need to find out the value of the
variables of the fun2 and fun1 loops at the specific
iteration that fails. Both fun1 and fun2 loops will
iterate thousands of times so line by line debug
2013 Jul 02
2
cache most-recent dispatch
Hi,
S4 method dispatch can be very slow. Would it be reasonable to cache the
most
recent dispatch, anticipating the next invocation will be on the same
type? This
would be very helpful in loops.
fun0 <- function(x)
sapply(x, paste, collapse="+")
fun1 <- function(x) {
paste <- selectMethod(paste, class(x[[1]]))
sapply(x, paste,
2017 Apr 30
1
`match.call` and dots substitution
I'm noticing some interesting behavior in `match.call` in some corner-ish cases that arise when you try to use `match.call` to match a "grandparent" function and there are dots involved:
fun0 <- function(a, ...) fun1(...)
fun1 <- function(b, ...) fun2()
fun2 <- function()
match.call(
fun1, sys.call(sys.parent()), expand.dots=FALSE,
2009 Oct 01
1
pass "..." to multiple sub-functions
Dear list,
I know I have seen this discussed before but I haven't been successful
in searching for "ellipsis", "dots", "..." in the archives. I would
like to filter "..." arguments according to their name, and dispatch
them to two sub-functions, say fun1 and fun2. I looked at lm() but it
seemed more complicated than I need as it modifies the calling
2012 Oct 26
3
wanna create all points.....
Plz help me ;(( I lost 7 hours for thinking and doing this code ;( I need to
create points.....20 points(dots). All these dots have to be in one graph...
when i run this code....it gives me only one dote.....
number<- (0,2,3,4,5,6,8)
for (i in seq(1:20))
{rsidpVector=rsidp(i)
mean(rsidpVector)
plot (length(rsidpVector), mean(rsidpVector), ylab="sample mean", xlab=
"sample
2015 Feb 24
2
iterated lapply
> On Feb 24, 2015, at 10:50 AM, <luke-tierney at uiowa.edu> wrote:
>
> The documentation is not specific enough on the indented semantics in
> this situation to consider this a bug. The original R-level
> implementation of lapply was
>
> lapply <- function(X, FUN, ...) {
> FUN <- match.fun(FUN)
> if (!is.list(X))
> X <-
2004 Mar 23
3
how to modify variables of another frame (but not global)
Hello!
Maybe "frame" is not the right term in this context.
I explain my problem by example code:
fun2 <- function(objName, add) {
## the object "objName" should be increased by "add",
## but the evaluation should be done in the calling function (here:
fun1)
## ...... what's the right code??
}
fun1 <- function() {
x <- 1
fun2("x",
2010 Aug 11
2
storing the results of an apply call
Hi R-users,
I have a function (myfun) that I want to apply to the rows of a matrix.
Basically, "myfun" takes the values from the matrix ("exp.des"), which
represent the different combinations of my experimental design, and pass
them as arguments to some other functions (fun1 and fun2). As I want to
replicate the results of fun1 and fun2 a certain number of time (e.g.
5), I
2012 Oct 26
3
summation sign
Hi all,
I have a very quick question on how to use the summation sign in R for the
function.
Here?s a basic example: the function is sum(i=1 to 5)log(1-xi^2)
Id be grateful if someone knows how to do this without writing it out 5
times - I am looking sth along the lines of the following:
computeR <- function(x)
{
return (-sum(log(1-x^2))
}^
thank you vm in advance!
--
View this
2009 May 01
1
integrate with large parameters
Dear R-users,
i have to integrate the following function
`fun1` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a))
}
but if l1 is large, i get the "non-finite function value" error, so my
idea is to rescale with exp(-l1)
`fun2` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a) - l1)
}
but it seems this doesn't solve the problem, when
2002 Aug 01
6
update() can not find objects (PR#1861)
Full_Name: Yi-Xiong Zhou
Version: 1.5.1
OS: win2000pro
Submission from: (NULL) (64.169.249.42)
Update() can not find objects when it is used in a function, which is in turn
being called by another function. Here is a R script to show the problem:
######## begin of the test script ##########
fun1 <- function() {
x <- matrix(rnorm(500), 20,25)
y <- rnorm(20)
oo <- lm(y~x)