Displaying 20 results from an estimated 90 matches for "100,100".
Did you mean:
100,000
2012 Feb 21
2
Using substitute in nested function calls
...mbers,
I really, like the feature that one can call R functions with
mathematical expressions, e.g.
curve(x^2, 0, 1)
I wonder, how I can construct in a simple way a function like
mycurve = function (expr) {...}
such that that a call
mycurve(x^2)
has the same effect as the call
curve(x^2, -100,100)
Below is some code that works, but it seems much to complicated: it
first substitutes and deparses the expression, creates a string with the
new function call and then parses and evaluates the string again. Does
anybody know a simpler, more elegant solution?
mycurve = function(expr) {...
2012 May 11
1
domain/number line/range reduction problem
...inclusion/exclusion issue here for simplicity, but in a perfect world the
resulting ranges would not include the s range endpoints and would include
endpoints of the x range if they were not eliminated by an s range.
Is there some function(s) in R that would make this easy?
Ex 1.
For:
x_rng = c(-100,100)
s1_rng = c(-25.5,30)
s2_rng = c(0.77,10)
s3_rng = c(25,35)
s4_rng = c(70,80.3)
s5_rng = c(90,95)
I would get:
xa_rng = c(-100,-25.5)
xb_rng = c(35,70)
xc_rng = c(80.3,90)
xd_rng = c(95,100)
Ex 2.
For:
x_rng = c(-50.5,100)
s1_rng = c(-75.3,30)
I would get:
xa_rng = c(30,100)
Ex 3.
For:
x_...
2012 May 12
2
range segment exclusion using range endpoints
...problem: I have endpoints of one x range (x_rng) and an unknown number
of s ranges (s[#]_rng) also defined by the range endpoints. I'd like to
remove the x ranges that overlap with the s ranges. The examples below
demonstrate what I mean.
What is the best way to do this?
Ex 1.
For:
x_rng = c(-100,100)
s1_rng = c(-25.5,30)
s2_rng = c(0.77,10)
s3_rng = c(25,35)
s4_rng = c(70,80.3)
s5_rng = c(90,95)
I would get:
-100,-25.5
35,70
80.3,90
95,100
Ex 2.
For:
x_rng = c(-50.5,100)
s1_rng = c(-75.3,30)
I would get:
30,100
Ex 3.
For:
x_rng = c(-75.3,30)
s1_rng = c(-50.5,100)
I would get:
-75.3...
2020 Oct 06
4
Solving a simple linear equation using uniroot give error object 'x' not found
...I hope someone can tell we how I can fix the problem
if(!require(rootSolve)){install.packages("rootSolve")}
library(rootSolve)
# Define the function
yfun <- function(x,diffMean,diffSE) ((abs(diffMean)-x)/diffSE)
# Prove the function and a call to the function work
yfun(10,100,10)
# use uniroot to find a solution to the
# function in the range -100 to 100
uniroot(yfun(x,10,20),c(-100,100))
My output:
> # Define the function
> yfun <- function(x,diffMean,diffSE) ((abs(diffMean)-x)/diffSE)
> # Prove the function and a call to the funciton works
&g...
2020 Oct 06
0
Solving a simple linear equation using uniroot give error object 'x' not found
...roblem
>
> if(!require(rootSolve)){install.packages("rootSolve")}
> library(rootSolve)
>
> # Define the function
> yfun <- function(x,diffMean,diffSE) ((abs(diffMean)-x)/diffSE)
> # Prove the function and a call to the function work
> yfun(10,100,10)
> # use uniroot to find a solution to the
> # function in the range -100 to 100
> uniroot(yfun(x,10,20),c(-100,100))
>
>
> My output:
>> # Define the function
>> yfun <- function(x,diffMean,diffSE) ((abs(diffMean)-x)/diffSE)
>> # Prove...
2006 Jun 27
3
looking for a more efficient R code.
Dear R-users
I have four simple linear models, which are all in the form of a*X+b
The estimated parameter vectors are
a <- c(1,2,3,4)
b <- c(4,3,2,1)
My goal is to draw a plot where x-axis is X (range from -100 to 100) and
y-axis is the sum of
all four linear models
X <- seq(-100,100, length=10000)
plot(X, sum of the four linear functions)
I started with a function for summing
summing <- function(a,b)
{temp <-0;
for (i in 1:length(a))
temp <- temp + a[i]*X+b[i]
}
plot(X, summing(a,b))
I...
2010 Dec 18
1
how to use expression as function arguements?
Hi all,
#####################################
integ=function(f,n){
# computes vector y = f(x)
x=runif(10000)
y=f
hatI=mean(y)
hatI
}
# example of use
integ(x^2+x+100,100)
#####################################
it returns an error says no obj 'x'
how do I 'tell' R to treat 'f' as an input expression?
Thanks.
casper
--
View this message in context: http://r.789695.n4.nabble....
2012 Jul 20
3
Crosstab with Average and Count
I have the following data:
x <- as.factor(c(1,1,1,2,2,2,3,3,3))
y <- as.factor(c(10,10,10,20,20,20,30,30,30))
z <- c(100,100,NA,200,200,200,300,300,300)
I could create the cross tab of x and y with Sum of z as its elements using
the xtabs function as follows:
# X Vs. Y with Sum Z
xtabs(z ~ x + y)
y
x 10 20 30
1 200 0 0
2 0 600 0
3 0 0 900
How do I replace the sum with average and count...
2009 Jun 08
2
Re flect Back to Back Histograms in x-axis?
I've looked long and hard for this, but maybe I am missing something...
There is a nice module that displays histograms reflected in the y axis,
i.e. http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=136
but is it possible to reflect in the x-axis, so to have two datasets, one
pointing up and one down rather than left and right? I haven't been able to
find a way to plot this
2010 Oct 07
1
Quantile question
Simple Question
I have 100x100 matrix and I want to calculte each row's 30,50% quantile
ex)
a=matrix(rnorm(10000),100,100)
quantile(a[1,],c(0.3,0.5))
quantile(a[2,],c(0.3,0.5))
.
.
.
.
I want get results at once.
so I try quantile(a[1:100,],c(0.3,0.5)) but I can get what I exactly want.
How can I calculte that?...
2005 Jun 30
0
vecortizing uniroot() for numerical solutions
...^2))
# I'd like to solve it across a parameter space of d1 and d2, holding
# h1 and h2 constant.
# It seems that uniroot() can do it, but I don't see how to
vectorize it.
# This works just fine:
R12 = function(d1, d2, h1, h2) (d1/(h1^2))-(h2*(d2^2))
uniroot(R12, interval=c(-100,100), tol=0.0001, d2=1, h1=1, h2=1)
# but to explore the entire parameter space it seems I would need a
series of loops
R12 = function(d1, d2, h1, h2) (d1/(h1^2))-(h2*(d2^2))
df1=data.frame(h1=numeric(0), h2=numeric(0),d1=numeric(0),d2=numeric(0))
h1=1
h2=1
for(i in 1:5) {
output=uniroot(...
2012 Jul 14
1
changing the x axis labels in a time series plot
...xis labels in a time series graph, from its
default numbering (which starts at 1 and increments by 1), to values I have
in another vector, "Year". It has to be a time series graph, I don't want
to have to use a scatter plot because there are many lines to draw.
Example:
z = cbind(1:100,100:1); Year = 1322:1421
windows()
plot.ts(z[,1:2],,"single", xaxt="n", xlab="")
axis(1,at=Year)
This doesn't work, not any of the permutations I've tried with the various
arguments to plot.ts and axis.
Thanks for any help.
[[alternative HTML version deleted...
2010 May 26
2
xlim/ylim and actual axis length
...plotting wizards,
when plotting in R, the actual lengths of the axes are slightly
greater than the ranges of the x/y variables or xlim/ylim values.
how do I control the amount by which the axes are enlarged? Is
there a way to enforce that the lengths of the axes equal
xlim/ylim?
example:
plot(0:100,0:100,pch="+")
it can be observed, that the x- and y-axis join at approx. (-4,-4)
and (104,104). If I want the axes to join at (0,0) and (100,100)
I have to cheat R into doing it by providing wrong xlim/ylim values:
plot(0:100,0:100,pch="+",xlim=c(4,96),ylim=c(4,96))
is there...
2012 May 05
1
Correct use of ddply with own function
...max(x2)
df <- data.frame(x1,x2,x3)
df
}
Probably this is not the best form of the function, but at least it produces what I want (data to plot a cumulative count curve).
This function works on a single vector but I have a melted dataframe like:
var1 <- rep(c("a","b"),c(100,100))
var2 <- runif(200,1,50)
df.test <- data.frame(var1,var2)
..and I want to apply that function on var2 but splitted by the variable var1. I think this might be a case for ddply...
anything like: ddply(df.test,.(var1),fn(var2))...
maybe someone know how to do that (modifying my function...
2004 Oct 06
3
crossprod vs %*% timing
...A
%*% a' many many times, and performance is becoming crucial. With
f1 <- function(a,X){ ignore <- t(a) %*% X %*% a }
f2 <- function(a,X){ ignore <- crossprod(t(crossprod(a,X)),a) }
f3 <- function(a,X){ ignore <- crossprod(a,X) %*% a }
a <- rnorm(100)
X <- matrix(rnorm(10000),100,100)
print(system.time( for(i in 1:10000){ f1(a,X)}))
print(system.time( for(i in 1:10000){ f2(a,X)}))
print(system.time( for(i in 1:10000){ f3(a,X)}))
I get something like:
[1] 2.68 0.05 2.66 0.00 0.00
[1] 0.48 0.00 0.49 0.00 0.00
[1] 0.29 0.00 0.31 0.00 0.00...
2004 Aug 27
4
SWIG Bug
...is static there isn''t a self value there, shifting
all arguments over one. One way to demonstrate this is with the
following sample:
require ''wx''
#begin sample
include Wx;
class TestFrame < Frame
def initialize()
super(nil,-1,"Test",Point.new(100,100),Size.new(100,100))
@win = Window.new(self,-1,Point.new(0,0),Size.new(100,100))
end
end
class TestApp < App
def on_init()
TestFrame.new().show(true)
end
end
TestApp.new().main_loop()
#end sample
On my build, Window won''t create complaining that there...
2015 Mar 19
3
Familia *pply
...ones de la familia *pply en todo lo que puedo, pero todavía no es
algo que me surja tan rápidamente o naturalmente al momento de los loops
como usar for().
Conozco las ventajas de usar estas funciones y por eso mi intento de
hacerme de ellas.
Por ejemplo en este problema:
data=matrix(rnorm(100*20),20,100)
col=sample(1:100,100)
t1=Sys.time()
medias=replicate(1000,{
sel=sample(1:20,10)
pareja=sample(sel,100,replace = T)
ta=Sys.time()
*recep=NULL**
** for(i in 1:100){**
** n=col[i]**
** m=pareja[i]**
** c=data[m,n]**
**...
2015 Mar 19
2
Familia *pply
...ía causar problemas, envío de nuevo el código sin formatos.
La idea básica es para un set de números de columnas (desordenados) y un
set de numeros de fila el loop lo que hace es ir a la fila y columna
correspondiente de data, tomar el valor y luego hacer la media sobre esos.
data=matrix(rnorm(100*20),20,100)
col=sample(1:100,100)
t1=Sys.time()
medias=replicate(1000,{
sel=sample(1:20,10)
pareja=sample(sel,100,replace = T)
ta=Sys.time()
recep=NULL
for(i in 1:100){
n=col[i]
m=pareja[i]
c=data[m,n]
recep=c(recep,c)
}
tb=Sys.time()
media=mean(recep)...
2016 Apr 05
5
R-dvel [robustness Simulation study of 2 sample test on several combination of factors ]
...estions/36404707/simulation-study-of-2-sample-test-on-different-combination-of-factors#>
If I wish to conduct a simulation on the robustness of two sample test by using R language, is that any ways in writing the code?
There are several factors
(sample sizes-(10,10),(10,25),(25,25),(25,50),(25,100),50,25),(50,100), (100,25),(100,100))
(standard deviation ratio- (1.00, 1.50, 2.00, 2.50, 3.00 and 3.50))
distribution of gamma distribution with unequal skewness and equal skewness
I wish to test the pooled variance t test and welch t test and mann whitney by using the above combination of facto...
2004 Feb 29
0
[RESEND] Mixer + Joystick problems with a game. Anybody willing to debug?
...rrun on sound buffer 0x4534ff20
> fixme:dinput:JoystickAImpl_SetProperty (this=0x47d00090,<guid-
> 0x0004>,0x4081fa78)
> fixme:dinput:JoystickAImpl_SetProperty ph.dwSize = 24, ph.dwHeaderSize
> =16, ph.dwObj = 258, ph.dwHow= 2
> fixme:dinput:JoystickAImpl_SetProperty proprange(-100,100)
> fixme:dinput:JoystickAImpl_SetProperty (this=0x47d00090,<guid-
> 0x0004>,0x4081fa78)
> fixme:dinput:JoystickAImpl_SetProperty ph.dwSize = 24, ph.dwHeaderSize
> =16, ph.dwObj = 514, ph.dwHow= 2
> fixme:dinput:JoystickAImpl_SetProperty proprange(-100,100)