Displaying 20 results from an estimated 400 matches similar to: "rename object"
2007 Nov 22
1
Matrix of dummies from a vector
Hallo
>From a variable "x" that defines, say, four classes, I would like to define
the matrix "mat" of dummy variables indicating the classes, i.e.
x <- c(1,1,1,1,2,2,2,3,3,3,4,4)
mat <- matrix(c(1,0,0,0,
1,0,0,0,
1,0,0,0,
1,0,0,0,
0,1,0,0,
0,1,0,0,
0,1,0,0,
0,0,1,0,
0,0,1,0,
0,0,1,0,
0,0,0,1,
0,0,0,1), ncol=4, byrow=T)
Thank you for your help,
Serguei
2009 Dec 04
2
Solve linear program without objective function
Dear R-users,
i try to solve to following linear programm in R
0 * x_1 + 2/3 * x_2 + 1/3 * x_3 + 1/3 * x_4 = 0.3
x_1 + x_2 + x_3 + x_4 = 1
x_1, x_2, x_3, x_4 > 0,
x_1, x_2, x_3, x_4 < 1
as you can see i have no objective function here besides that i use the
following code.
library(lpSolve)
f.obj<-c(1,1,1,1)
f.con<-matrix(c(0,2/3,1/3,1/3,
1,1,1,1,
2010 Mar 18
1
Regression of a time series on its Quarters
# Dear List,
# I want to characterize a time series according to its Quarter components.
# My data ("a.ts":
http://docs.google.com/View?id=dfvvwzr2_478cr9k4cdb)? look like:
#???????????????? Qtr1????????? Qtr2????????? Qtr3????????? Qtr4
#?? 1948 -0.0714961837? 0.0101747827? 0.0654816569 -0.0227830729
#?? 1949 -0.1175517556? 0.1151378692? 0.1015777858 -0.1971535900
#?? 1950?
2010 Mar 04
1
IMPORTANT! How work "constrOptim"? Why error in this routine???
? stato filtrato un testo allegato il cui set di caratteri non era
indicato...
Nome: non disponibile
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100304/8595d7e1/attachment.pl>
2011 Jul 18
1
Multiple comparison test on selected contrasts
Dear Help-list, How can I do a multiple comparison test (mct) on selected contrasts from a linear model while using packages lme4 and multcomp? I am running R 2.13.0 under Windows 7. The following linear model and mct produces a global mct of 15 paired contrasts of the combined (Site, Position) factor SitePos of which only 9 are of interest. Model.G = lmer(log10(SrCa) ~ SitePos + (1 | Eel),
2007 Mar 24
2
sampling from the unoform distrubuton over a convex hull
Dear list,
Does anyone have a suggestion (or better still) code for sampling from the uniform distribution over the convex hull of a set of points?
Many thanks and best wishes,
Ranjan
2010 Aug 30
1
lost in vegan package
Hi R Helpers,
I'm still new to R and i experience many difficulties..I'm using vegan
package (R version 2.11) trying to calculate checkerboard units for each
species pair of a matrix. I've prepared the function:
pair.checker=function (dataset) {designdist (dataset,
method="c("(A-J)x(B-J)", terms ="binary", abcd=FALSE)}
to use with function oecosimu as
2024 Jan 30
1
linear programming in R | limits to what it can do, or my mistake?
Apart from the fact that the statement "such that t1+t2+t3+t4=2970 (as
it must)" is not correct, the LP can be implemented as follows:
library(lpSolve)
LHS <- rbind(
c(0,0,0,0, 1, 0, 0,0),
c(1,0,0,0,-1, 1, 0,0),
c(0,1,0,0, 0,-1, 1,0),
c(0,0,1,0, 0, 0,-1,1),
cbind(-diag(4),diag(4)),
c(0,0,0,0,0,1,0,0),
c(0,0,0,0,0,0,1,0),
c(0,0,0,0,0,0,0,1)
)
RHS <-
2008 Apr 15
2
glht with a glm using a Gamma distribution
Quick question about the usage of glht. I'm working with a data set
from an experiment where the response is bounded at 0 whose variance
increases with the mean, and is continuous. A Gamma error
distribution with a log link seemed like the logical choice, and so
I've modeled it as such.
However, when I use glht to look for differences between groups, I get
significant
2009 Dec 18
2
how to combine multiple indicator variables in a single factor
Say I have a dataframe like this:
df <- data.frame(cbind(c(1,0,0,1),c(0,1,0,0),c(0,0,1,0)))
names(df) <- c('a','b','c')
I would like to create a factor in a new column, where the factor values are taken from the column names, like this:
> df2
a b c f
1 1 0 0 a
2 0 1 0 b
3 0 0 1 c
4 1 0 0 a
How would I do this? Thanks,
Dan
Daniel Nordlund
Bothell, WA USA
2024 Jan 29
1
linear programming in R | limits to what it can do, or my mistake?
Question for 'experts' in LP using R (using the lpSolve package, say) --
which does not apply to me for the sort of problem I describe below.
I've run any number of LP's using lpSolve in R, but all of them to date
have objective and constraint functions that both contain the same
variables. This lets you set up a LHS and RHS matrix/vector that are
symmetrical.
But, for a
2007 Sep 22
0
error messages
Hi,
I have a density that I need to get MLEs from, which includes definite integrals both in the denominator and in the numerator of the density function. It looks like the outcome depends on the initial values given. My program is shown below:
library(circular)
########################################
4 parameters
########################################
z<-rvonmises(100,0,1)
2010 Sep 29
1
Understanding linear contrasts in Anova using R
#I am trying to understand how R fits models for contrasts in a
#simple one-way anova. This is an example, I am not stupid enough to want
#to simultaneously apply all of these contrasts to real data. With a few
#exceptions, the tests that I would compute by hand (or by other software)
#will give the same t or F statistics. It is the contrast estimates that
R produces
#that I can't seem to
2006 Nov 10
3
advanced plotting
!urgent! Hi all. I am facing a problem plotting a indicatormatrix to
visualize the pattern. Matrix consist from 1's and 0's.
for example x <- matrix(c(0,0,1,0, 1,1,1,1, 0,0,0,1, 1,0,1,1), nrow = 4,
ncol=4)
an i want to have a plot like
| .
| . . . .
| .
| . . .
|_______>
I thinking of somethink like a for loop, which creates a data point
whenever
2001 Mar 19
2
A limitation for polyroot ? (PR#880)
Dear R Development Team,
I have encountered the following difficulty in using the function polyroot
under either NT4.0 (R version 1.2.1) or linux (R version 0.90.1). In the
provided example, the non-zero root of c(0,0,0,1) depends on the results of
the previous call of polyroot.
R : Copyright 2001, The R Development Core Team
Version 1.2.1 (2001-01-15)
R is free software and comes with
2011 Apr 19
0
Error message in package:bayesSurv. Why?
Dear folks,
I have been struggling to create what I fondly imagined would be a
straightforward adaptation of the package's example to my own dataset, which
looks at incidence of depression following the birth of initial and up to 3
subsequent children (4 children in all, with all subjects having a first
child). I've regarded these as equivalent to tooth eruption and subsequent
caries in
2005 Aug 31
0
Imputation using Pan in R
Hi,
I've tried to run the multiple imputation for longitudinal data using Pan in
R.
The trimmed data consist 10 individuals across 4 time points.
Following the example in panex.R, I imputated the model with one y variable
and only random intercept.
It worked well.
The next step for me is to imputate a model with one y variable and both
random intercept and slope.
The program ran well, but
2009 Jun 10
1
how to get output from a nested loop
Dear all,
I imagine that this is a trival question, but it has perplexed for most of the day. Any help would be greatly appreciated.
Below is an example of what I'm trying to do.
Essentially I want to produce all unique 1 x 1 combinations of certain columns from a dataframe, and join these to other columns from the same dataframe. I'm having problems with the nested loop as I can only
2001 Jan 17
2
PR#751
I'd just like to report a possible R bug--or rather, confirm an existing one
(bug #751).
I have had some difficulty using the polyroot() function.
For example, in Win 98, R 1.1.1,
> polyroot(c(2,1,1))
correctly (per the help index) gives the roots of 1 + (1*x) + (2*x^2) as
[1] -0.5+1.322876i -0.5-1.322876i
However,
> polyroot(c(-100,0,1))
gives the roots of
[1] 10+0i -10+0i
2013 Jan 28
1
Using loop for a random vector (Montecarlo method)
Hi,
I would like to replicate a sort of Montecarlo experiment:
I have to generate a random variable N(0,1) with 100 observations but I have
to contaminate this values at certain point in order to obtain different
vectors with different samples:
tab<-function(N,n,E,L){
for(i in 1:100){
X1<-rnorm(N*(1-a),0,1)
X2<-rnorm(N*(a),E,L)
X_tab<-sample(c(X1,X2),n,replace=T)
}
return(X_tab)}