Displaying 20 results from an estimated 1000 matches similar to: "avoiding expression evaluation when calling a function"
2012 Apr 01
1
indexing in a function doesn't work?
Hello,
I've written a small function that's supposed to save me some time, and
it's ending up killing it- the intention is to iteratively subset a dataset
fram on framevec, fit a model (either lm or nls depending on type) and
return the r2 or AIC from the model, respectively. Although as far as I can
tell in my code the plots are dependent on the fit of the model to the data
and the
2012 Mar 29
3
scalar assignment within a vector within function
Hello,
I'm trying to create a vector of r^2 values for using a function which I
will run in a "for" loop. Example:
per<-rnorm(100,.5,.2)^2
x<-rnorm(100,10,5)
y<-rnorm(100,20,5)
fr<-data.frame(x,y,per)
test<-rep(0,9)
plotter<-function(i){
temp.i<-fr[fr$per <=(i*.10),]
with(temp.i, plot(x, y, main=(i*.10),))
mod<-lm(y~x-1,data=temp.i)
2011 May 13
1
graphs of gamma, normal fit to a histogram are about half as large as they should be
Hello,
I'm trying to compare the fit of two distributions, normal and gamma, to a
histogram of my response variable.
rate<-mean(na.omit(rwb$post.f.crwn.length))/var(na.omit(rwb$post.f.crwn.length))
shape<-rate*mean(na.omit(rwb$post.f.crwn.length))
hist((rwb$post.f.crwn.length), main="rwb$post.f.crwn.length")
2005 Jun 20
3
vectorisation suggestion
Hi All,
I am counting the number of occurrences of the terms listed in one
vector in another vector.
My code runs:
for( i in 1:length(vector3)){
vector3[i] = sum(1*is.element(vector2, vector1[i]))
}
where
vector1 = vector containing the terms whose occurrences I want to count
vector2 = made up of a number of repetitions of all the elements of
vector1
vector3 = a vector of NAs that is
2008 Feb 26
2
Subsetting within xyplot()
All,
I'm having problems w/ a simple attempt to subset an xyplot.
The first plot below is a plot of y versus x for certain values of a third
categorical variable z. Now I'd like to further restrict this to certain
values of variable y. Neither of the two attempts below work. Any
suggestions much appreciated. (note: I don't want to merely use ylim since
I have a loess plot and I
2011 Feb 27
3
accessing variables inside a function, inside a loop
dear list!
I KNOW this has been answered a million times before. But, as some might
remember from their "freelance" times as a statistic consultant,
sometimes you're blinded by the facts. I KNOW I have seen this problem
solved, but due to the mental blockade i have been suffering from the
last 3 hours, I can neither find the answer on the mailing list nor on
google. I wrote a
2012 Oct 05
1
Format of numbers in plotmath expressions.
I want to do something like:
TH <- sprintf("%1.1f",c(0.3,0.5,0.7,0.9,1))
plot(1:10)
legend("bottomright",pch=1:5,legend=parse(text=paste("theta ==",TH)))
Notice that the final "1" comes out in the legend as just plain "1" and NOT
as "1.0" although TH is
[1] "0.3" "0.5" "0.7" "0.9"
2006 Jun 08
1
BN8S0 problem - Extension can never match, so disconnecting
hi
i've configured a Beronet BN8S0 Card with misdn beronet utility.
the card is configured with all lines in TE and P2P mode, and it is
connected with the special cable with an ISDN connection.
i've turned on debugging to level 4, this is the output from the
asterisk cli when i receive a call:
P[ 5] MGMT: Short status dinfo 1000001
P[ 5] MGMT: SSTATUS: L1_ACTIVATED
P[ 5] handle_frm:
2025 Mar 30
1
[External] Creating model formulas programmatically
As always, I would like to thank all who responded for their insights and
suggestions. I have learned from them.
Thus far, my own aesthetic preference -- and therefore not to be considered
in any sense as a "best" approach -- is to use Duncan's suggestion to
produce the call directly with call() rather than substitute in my simple
for() loop; i.e.
somenames <-
2006 Jun 14
3
appending
All,
In the function below I have 24 individuals and 6 calculations per
individual.
The 6 calculations are collected each time in a 1:24 loop when
calculating "delta".
I'd like to collect all 144 = 24*6 calculations in one vector
("delta.patient.comb").
The function works as is via indexing, but is there an easier way to
collect the measurements via appendinng the 6
2006 Mar 10
2
Plot.date and legends
Hi:
I'm trying to plot dates on the x-axis of a code, but the legend is not being
displayed. I receive the following error:
Error in match.arg(x, c("bottomright", "bottom", "bottomleft", "left", :
'arg' should be one of bottomright, bottom, bottomleft, left,
topleft, top, topright, right, center
In addition: Warning message:
longer
2010 Feb 02
2
mysterious extra spaces appearing in expression paste
Hi,
i'm trying to put a legend on some figures and they're coming out a
bit wonky. here's an example:
a <- c(1:10)
par(mfrow=c(2,1))
plot(a,type="s",lwd=3)
leg <- c(expression(paste("data1 (",rho,"=1)")),
expression(paste("data2 (",rho,"=0.0)")))
legend("bottomright",legend=leg,col=c(1,2),lwd=3)
2008 Feb 28
2
Replacing plot symbols w/ subject IDs in xyplot()
All,
How does one replace plot symbols with say subject IDs when using xyplot? Or
superimpose them next to plot symbols? I searched the archives under
various key words but haven't had much. Any suggestions or links much
appreciated. Sample code below.
David
junk.frm = data.frame(ID = rep(1:16, each = 2), x, y, z = rep(c("D", "P"),
16))
y = c( 0.4, 0.6, -0.1,
2011 Jul 25
1
Creating png of layered legend
I am trying to create a plot that has multiple plot characters for
each point (e.g. a point within a triangle, a triangle within a
square, etc). The workaround I have found to do this is by plotting
twice, as in this example:
x <- c(1.1, 2.3, 4.6)
y <- c(2.0, 1.6, 3.2)
plot(x, y)
points(x,y, pch=20, col="red", cex=0.5)
This works, but perhaps there is a better way to do it in one
2010 Jan 28
1
rails files are missing
I''ve built the slackware packages of rails.
rails path is: /frm/ruby/1.8.6/lib/ruby/site_ruby/1.8
RUBYLIB : /frm/ruby/1.8.6/lib/ruby/site_ruby/1.8:/frm/ruby/1.8.6/lib/
ruby/site_ruby/1.8/i686-linux/
I could created the rails application, but files are missing.
Config
- boot.rb, database.yml, environment.rb and routes.rb
Public
-
2006 Feb 09
7
putting text in the corner
I want to write some text in a corner of my plot.
Is it possible to get the xlim and ylim of an open window?
Or is there anything similar like
legend(x="bottomright", inset=0.01,legend=...)
for
text(x=1,y=2, "test")
Thomas
2004 Apr 21
2
Resizing a ListCtrl
Hi Guys,
I''m having serious troubles resizing a dialog with a ListCtrl. The ctrl
will not resize horizontally no matter what I''m doing. I''ve attached a
sample code below. Any help will be greatly appreciated, as I really
like wxRuby :)
I''ve also tried to copy from the example from listtest.rbw, but that
also doesn''t seem to work.
Another thing
2007 Jan 24
1
Query Failed because: Incorrect information in file: './asterisk/sip.frm'
Hi,
I have a working asterisk 1.4.0 with Mysql Realtime configuration, and today
I encountered this error.
Now, I have no acces to any information in mysql realtime, so nothing work
now !!!!!
[Jan 24 10:32:40] DEBUG[31070] res_config_mysql.c: MySQL RealTime:
Everything is fine.
[Jan 24 10:32:40] DEBUG[31070] res_config_mysql.c: MySQL RealTime: Retrieve
SQL: SELECT * FROM extensions
2010 Jun 02
2
pdf function, resize xyplot plot automatically
All,
When saving plots to a pdf file via the pdf function, I would like to be
able to automatically expand the graphics device to achieve the same result
as when one does this manually (e.g., clicking the green expand button on
the upper left of the graph on Mac OS). Consider simple example below:
library("lattice")
foo.frm = data.frame(Subject = rep(c(1:4), each = 9), Y =
2008 Jun 13
1
x86 SSE* Pointer Favors
Dear Statisticians--- This is not even an R question, so please
forgive me. I have so much ignorance in this matter that I do not
know where to begin. I hope someone can point me to documentation
and/or a sample.
I want to compute a covariance as quickly as non-humanly possible on
an Intel core processor (up to SSE4) under linux. Alas, I have no
idea how to engage CPU vectorization. Do I need