Displaying 20 results from an estimated 2000 matches similar to: "Reshaping data with xtabs reorders my rows"
2012 Feb 17
2
(subscript) logical subscript too long in using apply
Dear ALL
I have this function in R:
func_LN <- function(data){
med_ge <- matrix(c(rep(NA,nrow(data)*ncol(data))), nrow = nrow(data),
ncol=ncol(data), byrow=TRUE)
T <- matrix(c(rep(NA,length(n)*ncol(data))), nrow = length(n),
ncol=ncol(data), byrow=TRUE)
Tdiff<- matrix(c(rep(NA,length(n)*ncol(data))), nrow = length(n),
ncol=ncol(data), byrow=TRUE)
T1<- c(rep(NA,ncol(data)))
2004 Apr 18
2
lm with data=(means,sds,ns)
Hi Folks,
I am dealing with data which have been presented as
at each x_i, mean m_i of the y-values at x_i,
sd s_i of the y-values at x_i
number n_i of the y-values at x_i
and I want to linearly regress y on x.
There does not seem to be an option to 'lm' which can
deal with such data directly, though the regression
problem could be algebraically
2003 Jul 17
3
univariate normal mixtures
Hello,
I have a concrete statistical question:
I have a sample of an univariate mixture of an unknown number (k) of
normal distributions, each time with an unknown mean `m_i' and a
standard deviation `k * m_i', where k is known factor constant for all
the normal distributions. (The `i' is a subscript.)
Is there a function in R that can estimate the number of normal
distributions k
2010 Jan 20
1
Reshaping data with xtabs giving me 'extra' data
Dear all,
Lets say I have several data frames as follows:
> set.seed(42)
> dates <- as.Date(c("2010-01-19", "2010-01-20"))
> times <- c("09:30:00", "11:30:00", "13:30:00", "15:30:00")
> shows <- c("Red Dwarf", "Being Human", "Doctor Who")
>
> df1 <- data.frame(Date = dates[1],
2006 May 08
2
On the speed of apply and alternatives?
Dear all,
I have to handle a large matrix (1000 x 10001) where in the
last column i have a value that all the preceding values in the same row
has to be compared to.
I have made the following code :
# generate a (1000 x 10001) matrix, testm
# generate statistics matrix 1000 x 4:
qnt <- c(0.01, 0.05)
cmp_fun <- function(x)
{
LAST <- length(x)
smpls <- x[1:(LAST-1)]
real
2012 May 23
1
numerical integration
Greetings,
Sorry, the last message was sent by mistake! Here it is again:
I encounter a strange problem computing some numerical integrals on [0,oo).
Define
$$
M_j(x)=exp(-jax)
$$
where $a=0.08$. We want to compute the $L^2([0,\infty))$-inner products
$$
A_{ij}:=(M_i,M_j)=\int_0^\infty M_i(x)M_j(x)dx
$$
Analytically we have
$$
A_{ij}=1/(a(i+j)).
$$
In the code below we compute the matrix
2018 May 12
3
(no subject)
hello
for exampl, i have this programme
# Generating data which are right truncated
library(DTDA)
library(splines)
library(survival)
n<-25
X<-runif(n,0,1)
V<-runif(n,0.75,1)
for (i in 1:n){
while (X[i]>V[i]){
X[i]<-runif(1,0,1)
V[i]<-runif(1,0.75,1)
}}
res<-lynden(X=X,U=NA, V=V, boot=TRUE)
attach(res)
temps = time
M_i = n.event
L_t = res
2005 Sep 14
1
Random effect model
Dear R-help group,
I would like to model directly following random effect model:
Y_ik = M_ik + E_ik where M_ik ~ N(Mew_k,tau_k^2)
E_ik ~ N(0,s_ik^2)
i = number of study
k = number of treatment
---------------------------------------------------------------------------
I have practiced using the command from 'Mixed -Effects models in S and
S-plus'
2012 May 29
0
mlogit package inquiry
Dear all,
? I am implementing a stochastic utility model that will eventually
make use of multinomial logit. I found that there is a package in R
called mlogit. I am not sure whether I have already found the correct
package or software. May I ask am I correct?
? Basically, let's say
? I have observations of n outcomes, for each outcome 1<=i<=n, they
were selected by a choice from a set
2010 Nov 08
1
try (nls stops unexpectedly because of chol2inv error
Hi,
I am running simulations that does multiple comparisons to control.
For each simulation, I need to model 7 nls functions. I loop over 7 to do
the nls using try
if try fails, I break out of that loop, and go to next simulation.
I get warnings on nls failures, but the simulation continues to run, except
when the internal call (internal to nls) of the chol2inv fails.
2003 Oct 21
2
Denominator Degrees of Freedom in lme() -- Adjusting and Understanding Them
Hello all.
I was wondering if there is any way to adjust the denominator degrees of
freedom in lme(). It seems to me that there is only one method that can be
used. As has been pointed out previously on the list, the denominator
degrees of freedom given by lme() do not match those given by SAS Proc
Mixed or HLM5. Proc Mixed, for example, offers five different options for
computing the
2018 May 13
0
(no subject)
> On May 12, 2018, at 9:42 AM, malika yassa via R-help <r-help at r-project.org> wrote:
>
>
> hello
> for exampl, i have this programme
> # Generating data which are right truncated
> library(DTDA)
> library(splines)
> library(survival)
> n<-25
> X<-runif(n,0,1)
> V<-runif(n,0.75,1)
> for (i in 1:n){
> while (X[i]>V[i]){
>
2013 Apr 13
1
Reshaping Data for bi-partite Network Analysis [SOLVED]
Wow !
so many thanks Arun and Rui
works like a charm
problem solved
2013/4/13 arun <smartpink111@yahoo.com>
> Hi,
> Try this;
> library(reshape2)
> res<-dcast(Input,people~place,value.var="time")
> res[is.na(res)]<-0
> res
> # people beach home school sport
> #1 Joe 5 3 0 1
> #2 Marc 0 4 2 0
> #3 Mary
2012 Nov 17
3
Reshaping a dataframe
Seems like this should be easy but I'm struggling a bit. How do I rearrange a
data frame to go from the first one to the second shown below ?
State Date lbs
TX 200701 400
TX 200702 650
TX 200703 950
TX 200704 1000
FL 200701 200
FL 200702 300
FL 200703 500
FL 200704 333
NJ 200701 409
NJ 200702 308
NJ 200703 300
NJ 200704 800
Date TX FL NJ
200701 400 200 409
200702 650
2003 May 14
2
how to include 'NA's in xtabs?
Hello!
I have a dataset with NA's in some variables (factors), for example:
$ P67 : Factor w/ 2 levels "-","+": NA 2 1 NA NA 2 1 1 2 NA ...
I need to use 'xtabs' like
xtabs(~x$P67)
It works well and produces something like this:
x$P67
- +
779 1318
but i want to compute NA's too, like this:
x$P67
- + NA
779 1318 137
I am trying
2009 Sep 04
1
Problem with xtabs(), exclude=NULL, and counting NA's
Hi all,
I cannot get xtabs to count NA's like I expect. Below is a sample session, and
note that the last two calls to xtabs() yield exactly the same thing.
I am running R-2.5.0 -- if there was a bug in xtabs that got fixed, I would love
to know about it. If there is a bug tracker somewhere, I can file it too. It
isn't my fault that the server is so ridiculously outdated, but I would
2009 Dec 13
1
xtabs - missing combination
Dear list,
I am trying to make a contingency table with xtabs but I am getting
a 0 where I expect a 'NA'. Here is a simple example:
options(stringsAsFactors = FALSE)
rn <- LETTERS[1:4]
df1 <- data.frame(r07 = rep(rn, each=4),
r08 = rep(rn, 4), value = 1:16)
xtabs(value ~ r07 + r08, df1)
# Delete the combination [A, C]
df1 <- df1[-3,]
# Set 'value'
2013 Apr 13
2
Reshaping Data for bi-partite Network Analysis
Hello
I have a dataset of people spending time in places. But most people don't
hang out in all the places.
it looks like:
> Input<-data.frame(people=c("Marc","Marc","Joe","Joe","Joe","Mary"),
+ place=c("school","home","home","sport","beach","school"),
+
2017 Jan 20
0
xtabs(), factors and NAs
>>>>> Milan Bouchet-Valat <nalimilan at club.fr>
>>>>> on Thu, 19 Jan 2017 13:58:31 +0100 writes:
> Hi all,
> I know this issue has been discussed a few times in the past already,
> but Martin Maechler suggested in a bug report [1] that I raise it here.
>
> Basically, there is no (easy) way of printing NAs for all variables
> when calling
2009 Jul 02
1
From xtabs to matrix
Hi list,
is it possible convert the xtabs result
xtabs(breaks~tension+wool,data=warpbreaks)
wool
tension A B
L 401 254
M 216 259
H 221 169
to a simple matrix or data frame?
A B
L 401 254
M 216 259
H 221 169
Thanks a lot! Gianandrea
--
View this message in context: http://www.nabble.com/From-xtabs-to-matrix-tp24304588p24304588.html