Displaying 20 results from an estimated 300 matches similar to: "Generic code for simulating from a distribution."
2009 Feb 27
1
Sweave doesn't do csv.get()
Hi Everybody
I use R2.8.0 on Mac OS X. I set up LyX 1.6.1 to use Sweave today. I can
compile the test file I found on CRAN (
http://cran.r-project.org/contrib/extra/lyx/) without a problem and the
output looks very nice. In the test file the following R code is used.
<<myFirstChunkInLyX>>=
xObs <- 100; xMean <- 10; xVar <- 9
x <- rnorm(n=xObs, mean=xMean, sd=sqrt(xVar))
2006 Feb 20
2
formatting results from a function argument
Hello all,
I have a simple function which calculates summary statistics of a dataset
in terms of a factor (say area).
> x = data.frame(Area = c(rep("cleanup", 5), rep("ref", 5)), TcCB =
c(rnorm(5)+2, rnorm(5)));x
Area TcCB
1 cleanup 2.5829747
2 cleanup 2.6796868
3 cleanup 2.5437094
4 cleanup 2.8453616
5 cleanup 1.1789683
6 ref 1.0140391
7
2011 May 04
3
Error in .Fortran Call
I have the following FORTRAN code converted to a DLL:
! my_xmean.f90
!
! FUNCTIONS/SUBROUTINES exported from my_function.dll:
! my_function - subroutine
!
subroutine my_xmean(X,N,XMEAN)
! Expose subroutine my_function to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT,C,REFERENCE,ALIAS:'my_xmean_'::my_xmean
! Body of my_function
DOUBLE PRECISION X(N)
XMEAN=0D0
DO J=1,N
2006 Feb 22
1
stripchart-y axis labels
Hello,
I am trying to create a stripchart for my data, where y axis labels are
characters (ie,names of cities). I would like to change the orientation
of the y - axis labels, ie perpendicular to y axis.
Below is the code i am using:
par(srt=90)
with(ozone.ne.trim,
stripchart(Median~City,main = "stripchart(ozone)"))
The par option doesn't seem to working.
Kindly help.
Thanks
2006 Nov 17
2
effects in ANCOVA
Dear R users,
I am trying to fit the following ANCOVA model in R2.4.0
Y_ij=mu+alpha_i+beta*(X_ij-X..)+epsilon_ij
Particularly I am interested in obtaining estimates for mu, and the effects
alpha_i
I have this data (from the book Applied Linear Statistical Models by Neter
et al (1996), page 1020)
y<-c(38,43,24,39,38,32,36,38,31,45,27,21,33,34,28)
2012 May 02
1
returning value from source() in R .Net
Hello
I would like to source an R script from within a C# .Net application equivalent to:
source("my_r_code.r")
I can get this to run but am not sure how to retrieve R objects defined with script my_r_code.r at runtime.
For example, if "my_r_code.r" contains
#-- contents of my_r_code.r---------------------
x <- 1:10
xmean <- mean(x)
2011 Aug 07
2
help annotating plot.xmean.ordinaly in rms package
Hello List:
Does anyone know if there's a way to annotate the plots produced by the
plot.xmean.ordinaly function in the rms package. I'd like to produce
publication quality figures, but first need to annotate the axis labels. Is
there a way to do that?
I appreciate any advice.
Chris
[[alternative HTML version deleted]]
2002 Jun 20
2
tabulate means & NA
Hi,
i have some problems to get means, but the data have got
NA's which should not be replaced or delete !
tapply(data,var,mean) # makes me problem,because when one value is
NA mean is NA,too.
Another attempt is this, because the summary does what i want , but
is not subsetable to summary[4] if i use tapply,table and the the
function below gives me
again all means as NA ?
xmean
2012 Mar 29
1
how to increase speed for function?/time efficiency of below function
i am using sarima() function as below
___________________________________________________________________________________________
sarima=function(data,p,d,q,P=0,D=0,Q=0,S=-1,tol=.001){
n=length(data)
constant=1:n
xmean=matrix(1,n,1)
if (d>0 & D>0)
fitit=arima(data, order=c(p,d,q), seasonal=list(order=c(P,D,Q),
period=S),
2004 Dec 02
3
R and Fortran in Windows
I just joined the list and appologize if this has been answered before
but I am trying to interface between R and the Compaq Visual Fortran
compiler version 6.6 for Windows.
I found the following instructions on the web -- and an example. When I
follow these directions exactly. R 2.0.0 crashes. Has anyone had any
experience with this?
Below are the instructions that I located:
Thanks
Dan
2013 Apr 19
2
NAMESPACE and imports
I am cleaning up the rms package to not export functions not to be called
directly by users. rms uses generic functions defined in other packages.
For example there is a latex method in the Hmisc package, and rms has a
latex method for objects of class "anova.rms" so there are anova.rms and
latex.anova.rms functions in rms. I use:
2006 Feb 28
2
Elegant way to express residual calculation in R?
Hi All,
I am illustrating a simple, two-way ANOVA using the following data and I'm
having difficulty in expressing the predicted values succinctly in R.
X<- data.frame(read.table(textConnection("
Machine.1 Machine.2 Machine.3
53 61 51
47 55 51
46 52 49
50
2009 Aug 13
2
Coding problem: How can I extract substring of function call within the function
In order to ease my students into the R environment I am developing a package which installs a variety of utility functions as well as slightly modified versions of some standard R functions -- e.g. mean, hist, barplot, .... In my versions of these standard R functions I either add options or alter some defaults that seem to create difficulties for most of my students -- for example, when they do
2005 Nov 09
2
help with legacy R code
Hi there,
Could somebody help me disect this legacy R script I inherited at work, I
have two questions:
1. I've tried to upgrade our R version from 1.6.2 (yeah, I know), to R 2.0,
but some of the lines in this script are not compatible with R 2.0, could
someone help me figure out where the problem is?
2. the jpeg generated (attached) seems to be off on some of the data, is
there a better way
2006 Aug 02
0
Trying to use segmented in a function
Hi folks
I wonder if anyone can help me. I want to run some simulations to see
how big a sample size might be necessary to distinguish a curved
bivariate relationship (e.g. something that might be best described
by a quadratic model) from a relationship that is two straight lines
with a sudden change in slope (e.g. something best described by a
breakpoint regression). I am using
2010 Dec 05
0
Help with time varying covariate-unfold function
Hello All,
I am trying to use the unfold function in RcmdrPlugin.survival library,
which converts the survival data with time varying covariates to the
counting process notation. The problem is somehow, the event indicator
created is not correct.
Below is the data, I am trying to convert:
CASE TRT FAILTIME FAILCENS SEX AGE IGG0 IGG28 IGG42 IGG84 IGG364
26003 A 11.2033
2017 Sep 25
2
Sample of a subsample
Hello everybody!
I have the following problem: I'd like to select a sample from a subsample
in a dataset. Actually, I don't want to select it, but to create a new
variable sampleNo that indicates to which sample (one or two) a case
belongs to.
Lets suppose I have a dataset containing 40 cases:
data <- data.frame(var1=seq(1:40), var2=seq(40,1))
The first sample (n=10) I drew like
2017 Sep 25
1
Sample of a subsample
Hi David,
I was about to post a reply when Bert responded. His answer is good
and his comment to use the name 'dat' rather than 'data' is instructive.
I am providing my suggestion as well because I think it may address
what was causing you some confusion (mainly to use "which", but also
the missing !)
idx2 <- sample( which( (!data$var1%%2) & data$sampleNo==0 ),
2017 Sep 25
0
Sample of a subsample
For personal aesthetic reasons, I changed the name "data" to "dat".
Your code, with a slight modification:
set.seed (1357) ## for reproducibility
dat <- data.frame(var1=seq(1:40), var2=seq(40,1))
dat$sampleNo <- 0
idx <- sample(seq(1,nrow(dat)), size=10, replace=F)
dat[idx,"sampleNo"] <-1
## yielding
> dat
var1 var2 sampleNo
1 1 40
2007 Jun 14
4
question about formula for lm
Dear all;
Is there any way to make this to work?:
.x<-rnorm(50,10,3)
.y<-.x+rnorm(50,0,1)
X<-data.frame(.x,.y)
colnames(X)<-c("Xvar","Yvar")
Ytext<-"Yvar"
lm(Ytext~Xvar,data=X) # doesn't run
lm(Yvar~Xvar,data=X) # does run
The main idea is to use Ytext as input in a function, so you just type
"Yvar" and the model should fit....