Hi R-useRs,
after having read
http://tolstoy.newcastle.edu.au/R/help/05/07/8498.html
with the same topic but five years older. the solution for a contr.sum
with names for factor levels for R version 2.10.1 will be to comment out
the following line
#colnames(cont) <- NULL
in contr.sum i gue
Dear R-users,
i have the following exmple for which i want to use ecm.mix from the
mix-package.
with da.mix after using em.mix i get the error "improper
posterior--empty cells", which is not uncommen because of 17 * 5 * 3 =
255 cells.
so the next attempt is to use the ecm.mix for the restric
Dear R-users,
i try to fit a multinomial model in order to get an imputation for a
missing value in factor1.
library(nnet)
factor1 <- factor(c("a","b","c","d"))
factor2 <- factor(c("e","f","g","h"))
size <- c(3,8,2,1)
factor1[3] <- NA
Z<-ifelse(is.na(factor1), 0, 1)
assign("data", cbind.data
Dear R-Users,
i want to use the function mice of the mice package with data, that
contains dates, but this gives an error
x <- Sys.time()
dat <- data.frame(dates=(1:10)*60*60*24+x, size=rnorm(10))
dat$dates[c(3,7)]<-NA
mice(dat)
Fehler in check.imputationMethod(imputationMethod,
defaultImpu
Dear R-Users,
i want to use the function svm of the e1071 package to predict missing data
data(iris)
## create missing completely at random data
for (i in 1:5)
{
mcar <- rbinom(dim(iris)[1], size=1, prob=0.1)
iris[mcar == 1, i] <-
Dear R-users,
i try to recode a factor according to old levels
F <- factor(sample(c(rep("A", 4), rep("B",2), rep("C",5
recode(F, "levels(F)[c(1,3)]='X'; else='Y'")
i tried to work with eval or expression around levels(F)[c(1,3)], but
nothing seems to work.
Many thanks if anyone could t
Dear R-users,
in the follwing thread
http://tolstoy.newcastle.edu.au/R/help/03b/3322.html
the problem how to remove rows for predict that contain levels which are
not in the model.
now i try to do this the other way round and want to remove columns
(variables) in the model which will be lat
ain.
I thought this problem is quite common and i can use an algorithm somebody has
already implemented.
best regards
Andreas
Original-Nachricht
> Datum: Wed, 25 Nov 2009 00:48:59 -0500
> Von: David Winsemius
> An: Andreas Wittmann
> CC: r-help@r-project.org
}
else
stop("dat and newdat must have the same column length!")
m <- lm(formula(f), data=dat[,(1:ncol(dat))[!drop]])
p <- predict(m, newdat)
return(list(drop=drop, p=p))
}
predict.drop(x ~ ., training, test)
best regards
Andreas
David Winsemius wrote:
On Nov 25
Dear R-users,
i try to generate missing values in a matrix X according to a given
missingnes pattern R with the probabilities p per row.
X<-matrix(rnorm(3*100),ncol=3)
## indicator matrix for missingnes (1 observed, 0 missing)
R<-matrix(c(1,1,1,
0,0,1,
1,1,0,
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)
Dear R-users,
after several tries with lapply and searching the mailing list, i want
to ask, wheter and how it is possibly to avoid the for-loop in the
following piece of code?
set2<-as.data.frame(matrix(rnorm(9),ncol=3))
set2[1,1] <- NA
set2[3,2] <- NA
set2[2,1] <- NA
dimnames(set2)[1] <-
,
baptiste
2009/12/10 Andreas Wittmann :
Dear R-users,
after several tries with lapply and searching the mailing list, i want to
ask, wheter and how it is possibly to avoid the for-loop in the following
piece of code?
set2<-as.data.frame(matrix(rnorm(9),ncol=3))
set2[1,1] <- NA
set2[3,2]
Dear R useRs,
after searching r-help and r-manuals for about one hour i have the
following, probably easy question for you.
i have the following R-code, in the file test01.R
`fun1` <- function(x)
{
x <- x + 2
Dear R users,
i try to integrate lgamma from 0 to Inf. But here i get the message "roundoff
error is detected in the extrapolation table", if i use 1.0e120 instead of Inf
the computation works, but this is against the suggestion of integrates help
information to use Inf explicitly. Using stirli
Dear R-users,
i have to integrate the following function
`fun1` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1) - l2 * lgamma(a))
}
but if l1 is large, i get the "non-finite function value" error, so my
idea is to rescale with exp(-l1)
`fun2` <- function (a, l1, l2)
{
exp(log(l1) * (a - 1)
Dear R-users,
actually i try to parse some state protocols for my work. i an easy
stetting the code below works fine, if states are reached only once. in
harder settings it could be possible that one state gets visited more
times. in this case for me its interesting to see how much waiting tim
Dear R-users,
i have a simple problem maybe, but i don't see the solution. i want to
find the entry-wise closest element of an vector compared with another.
ind1<-c(1,4,10)
ind2<-c(3,5,11)
for (i in length(ind2):1)
{
print(which.min(abs(ind1-ind2[i])))
}
for ind2[3] it should be ind1[3] 10,
On Jan 17, 2010, at 11:00 AM, Andreas Wittmann wrote:
Dear R-users,
i have a simple problem maybe, but i don't see the solution. i want
to find the entry-wise closest element of an vector compared with
another.
ind1<-c(1,4,10)
ind2<-c(3,5,11)
for (i in length(ind2):1)
{
prin
Dear R-useRs,
I'm looking for an R-function for censored linear regression. I have the
following data
x1 <- rnorm(100)
x2 <- rnorm(100)
y <- x1 + 2*x2 + rnorm(100,0,0.5)
stat <- rep(1,100)
stat[50:100] <- 0
data <- data.frame(y,x1,x2,stat)
y is the dependent variable, x1 and x2 are the indepe
Dear R-users,
i try to use the following code to do a gamma regression
glm(x1 / x2 ~ x3 + x4 + x5 + x6 + x7 + x8, family=Gamma(link="log"),
weights=x2)
but here i get the error
Error: NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning message:
step size truncated due to diverge
Dear R users,
i try to calculate the probabilty to survive a given time by using the
estimated survival curve by kaplan meier.
What is the right way to do that? as far as is see i cannot use the
predict-methods from the survival package?
library(survival)
set.seed(1)
time <- cumsum(rexp(100
Dear R-users,
after trying and searching a long time i have the following question.
is it possible to replace to following double loop by some apply calls?
###
m1 <- data.frame(v1=factor(letters[1:5]),
v2=factor
ind],
type = "response")
}
On 14.05.2010 14:42, Henrique Dallazuanna wrote:
> Try this:
>
> mapply(function(x, y)x[match(x, y)], m2, m1)
>
> On Fri, May 14, 2010 at 9:23 AM, Andreas Wittmann
> mailto:andreas_wittm...@gmx.de>> wrote:
>
> Dear R-users,
Dear R useRs,
i have the following code to compute values needed for a contour plot
"myContour" <- function(a, b, plist, veca, vecb, dim)
{
tmpb <- seq(0.5 * b, 1.5 * b, length=dim)
tmpa <- seq(0.5 * a, 1.5 * a, length=dim)
z
Thank you very much, yes maybe its worth working on it.
best regards
Andreas
Uwe Ligges wrote:
Andreas Wittmann wrote:
Dear R useRs,
i have the following code to compute values needed for a contour plot
"myCo
Dear R useRs,
i try to integrate the following function for many values
"integrand" <- function(z)
{
return(z * z)
}
i do this with a for-loop
for(i in 2:4)
{
z <- integrate(integrand, i-1, i)$value
cat("z", z, "\n")
}
to speed up the computation for many values i tried vectors
in integrat
3
vec2<-2:4
mapply(integrate, lower=vec1, upper=vec2, MoreArgs=list(f=integrand) )
baptiste
On 20 Sep 2008, at 13:08, Andreas Wittmann wrote:
Dear R useRs,
i try to integrate the following function for many values
"integrand" <- function(z)
{
return(z * z)
}
i do this with a
Dear R useRs,
i try to compute the posterior mean for the parameters omega and beta
for the following
posterior density. I have simulated data where i know that the true
values of omega=12
and beta=0.01. With the function postMeanOmega and postMeanBeta i wanted
to compute
the mean values of om
Dear R useRs,
on ubuntu 8.04 i try to create a shared object out of a c-file
this is
// add.c
#include
SEXP addiere(SEXP a, SEXP b)
{
int i, n;
n = length(a);
for (i = 0; i < n; i++)
REAL(a)[i] += REAL(b)[i];
return(a);
}
in terminal i type
R CMD SHLIB add.c
and get
gcc -std=gnu99 -
the
compilation, if i delete it and try the compilation under ubuntu
everything works fine, don't know why?
best regards
Andreas
Dirk Eddelbuettel wrote:
> On Sun, Oct 19, 2008 at 01:27:06AM +0200, Andreas Wittmann wrote:
>
>> Dear R useRs,
>>
>> on ubuntu
Dear R useRs,
i wanted to ask if the folded normal destribution (Y = abs(X) with X
normal distributed)
with density and random number generator is implemented in R or in any
R-related package
so far? Maybe i can use the non-central chi-square distribution and
rchisq(n, df=1, ncp>0) here?
Tha
Dear R users,
i would like to transform the following function from R-code to C-code and call
it from R in order to speed up the computation because in my other functions
this function is called many times.
`dgcpois` <- function(z, lambda1, lambda2)
{
`f1` <- function(alpha, lambda1, lambda2
Dear R useRs,
i have the function f1(x, y, z) which i want to integrate for x and y.
On the one hand i do this by first integrating for x and then for y, on
the other hand i do this the other way round and i wondering why i
doesn't get the same result each way?
z <- c(80, 20, 40, 30)
"f1" <
On Sat, 24 Jan 2009, Duncan Murdoch wrote:
On 24/01/2009 5:23 AM, Andreas Wittmann wrote:
Dear R useRs,
i have the function f1(x, y, z) which i want to integrate for x and
y. On the one hand i do this by first integrating for x and then for
y, on the other hand i do this the other way round
Dear R useRs,
yesterday i updated my system from ubuntu 8.04 to 8.10. I use emacs-
snapshot, this is emacs 23.0.60.1 and ess 5.3.8. Before the update i
had when starting emacs with an R file an ess-toolbar with little
icons to start R or to evaluate a line or a region of my R file, but
no this too
Dear R useRs,
with the following piece of code i try to find the first value which can
be calculated without warnings
`test` <- function(a)
{
repeat
{
## hide warnings
suppressWarnings(log(a))
if (exists("last.warning", envir = .GlobalEnv))
{
a <- a + 0.1
## clear exis
Hello everybody,
i have the following problem to write a function which recognizes depending
on the parameter-inputs how many equations for the calculation in the function
are needed.
Here is an example of my problem:
"myfun" <- function(a, b, c, d)
{
k <- length(a)
#here d = 3 for exa
38 matches
Mail list logo