similar to: manipulating elements of a vector

Displaying 20 results from an estimated 1000 matches similar to: "manipulating elements of a vector"

2005 Mar 23
4
sampling from a mixture distribution
Dear R users, I would like to sample from a mixture distribution p1*f(x1)+p2*f(x2). I usually sample variates from both distributions and weight them with their respective probabilities, but someone told me that was wrong. What is the correct way? Vumani
2004 Mar 25
3
subsetting based on vector
Dear R users; I am trying to write a small program which reads in a data set, and selects observations from certain years before the analysis. I have a problem including the selection criteria in the header of the program. Here is the problem; dataFIT<-function(MODEL, MARGINS, yearConsidered){ library(foreign CovPaper<-read.spss("C:/Data/data.sav") NewData <-
2005 Aug 04
2
drawing a network digraph
Dear R users, I have a matrix with 2 columns with the variables: "daughter index", "mother index". I would like to draw a network digraph using this data, where each daughter is connected to a mother and between the connections inlcude a circle with the information on the indices ("daughter index", "mother index"): i.e. something similar to graphs
2006 Mar 08
2
fitting a distribution using glm
it is easy to fit a distribution using fitdistr poisdata <- rpois(n = 100, lambda = 2) poismle <- fitdistr(poisdata, "Poisson") poismle but i would like to know whether its possible to get an identical result using glm. I use poistab <- data.frame(table(poisdata)) colnames(poistab) <- c("width","freq"); poistab[,"width"] <-
2003 Jan 22
1
something wrong when using pspline in clogit?
Dear R users: I am not entirely convinced that clogit gives me the correct result when I use pspline() and maybe you could help correct me here. When I add a constant to my covariate I expect only the intercept to change, but not the coefficients. This is true (in clogit) when I assume a linear in the logit model, but the same does not happen when I use pspline(). If I did something similar
2003 Jun 16
1
Hmisc multiple imputation functions
Dear all; I am trying to use HMISC imputation function to perform multiple imputations on my data and I keep on getting errors for the code given in the help files. When using "aregImpute" the error is; >f <- aregImpute(~y + x1 + x2 + x3, n.impute=100) Loading required package: acepack Iteration:1 Error in .Fortran("wclosepw", as.double(w), as.double(x),
2007 Jun 20
2
"xtable" results doesn't correspond to data.frame
Dear useRs, Am trying to use xtable on the following data.frame and I don't get what I expect: example.table <- data.frame(rbind( c("Gender"," "," "," "), cbind(rep(" ",2),c("Male","Female"),c(3.0,4.0),c(3/7,4/7)) )) colnames(example.table) <- c(" "," ","number of
2003 May 09
1
manipulating elements of a matrix
Dear R users: I have the following matrix. 0 1 1 0 1 0 2 1 0 3 0 0 I would like to spread the matrix such that whenever the row sum is greater than 1 the row is repeated the number of times given by the row sum. Furthermore I would like to split the following cases: 0 1 1 such that it map to the following matrix 0 1 0 0 0 1 such that each row adds up to 1. I have no problems with cases
2003 Jan 17
2
Re: Universal legend in plot
Dear R-users: I asked a question on how I can have a universal legend in a plot and received the following result. I tried using "layout" but I can't seem to work on the "empty" plot (where I have to have the legend). I tried "oma" but I couldn't improve the quality of the plot, and that I didn't know how to specify all the line types using the
2005 Feb 15
2
special symobol / character
Hi all, Is it possible to add a permil (or per mille) symbol to an R plot (I couldn't find this symbol under demo(Hershey) or the plotmath information). In some ascii tables it is symbol no. 137. cheers, Matt. [[alternative HTML version deleted]]
2004 Nov 18
5
Lexical Scoping: eval(expr,envir=)
Hi R-listers, I am trying to better undertand what we would call "functional paradigm" use of S/R to better map my programming activities in other languages. This little function is aimed to create an object (at the end end, it would have it's own class): -- myObject =function(){ list( a=1, foo=function(b) { cat("b:",b)
2005 Jun 01
1
"\n" in legend using substitute and as.expression
Dear R users, Is it possible to force a hard return in an expression. I tried including one for a legend using an expression and it didn't work. Here is my code, legend(12, 0.10, c("Fitted density", as.expression(substitute(paste("Weibull (", alpha==shapeU," , ", beta==scaleU,") Mean = ",meanU," days"), list(shapeU =
2003 Jan 20
1
R analogue
Dear R users: Is there any R analogue for the S+ function "na.gam.replace". I would like to make an interaction of a categorical and smooth continuous covariate. Thanks. Vumani Dlamini Central Statistical Office Swaziland
2003 Dec 18
3
Summaries
Hello UseRs: Excuses for my english. I have a dataset with 65000 records and I'd like to make a summary where I can view all the values (with the number of times that it repeats) that there are each column of my dataset. I tried with summary( ), str( ), but nothing gives me the result that I am loking for. Thank you very much.
2005 Nov 21
2
Multinomial Nested Logit package in R?
Dear R-Help, I'm hoping to find a Multinomial Nested Logit package in R. It would be great to find something analogous to "PROC MDC" in SAS: > The MDC (Multinomial Discrete Choice) procedure analyzes models > where the > choice set consists of multiple alternatives. This procedure > supports conditional logit, > mixed logit, heteroscedastic extreme value,
2006 Jun 29
1
using "rbinom" in C code gives me erroneous results... random variable is not random (always zero)...
Dear Listers, I am trying to use "rbinom" in my C code, but i always get zeros as output no matter the probability. Am not sure what I am doing wrong because the function has worked before. Attached in an example. Noticed that "rbinom" expects 'n' to be REAL. Regards, Vumani R 2.3.1 (2006-06-01) Windows XP Gcc /* Called this file binom.c and then ran rcmd shlib on it
2004 Apr 27
5
parsing a data file
Hi, I need to parse a data file (output of a measuring device) of the following format: BEGIN RECORD [first record data] RECORD [second record data] RECORD [third record data] END Line breaks can (and do ;-() occur anywhere. White space behaves very much like TeX, eg it is not important whether there are one or more spaces or linebreaks as long as there is one of them. It is a text file, not
2006 Jul 05
1
i suspect that there a memory leak in "vmmin"?
Dear listers, Am currently using MCMC approaches to estimate some parameters of my model. One parameter has to be updated using a tuned gamma distribution. So at each iteration I estimate the mean and variance of the density of the gamma approximation using "vmmin" (i also supply the gradient argument). For moderate replications the procedure works, but if I increase them R crashes.
2004 Nov 09
2
do.call invoking a function with multiple arguments
Hi users, I am not sure to understand the help page about do.call. -- do.call(what, args) args: a _list_ of arguments to the function call. The 'names' attribute of 'args' gives the argument names. -- If we take the following sample data: > (tab=as.data.frame(table(factor(1:10)))) Var1 Freq 1 1 1 2 2 1 3 3 1 4 4 1 5 5
2004 Jun 04
1
[Wish]: Add "..." argument to library function
Hello, I would find it very usefull to have the ability to load packages with options. Consider for example the SciViews package Philippe and me are working on. When loading on Windows, it automatically loads the associated GUI executable. It should be convenient to have an option not to load the exe but still have an access to the R functions of the package. For that, I think a simple change