Displaying 20 results from an estimated 80 matches for "0.3333333".
2008 Mar 07
4
Warning: matrix by vector division
Dear list,
I just made a very simple mistake, but it was hard to spot. And I
think that I should warn other people, because it is probably so
simple to make...
=== R code ===
# Let us create a matrix:
(a <- cbind(c(0,1,1), rep(1,3)))
# [,1] [,2]
# [1,] 0 1
# [2,] 1 1
# [3,] 1 1
# That is a MISTAKE:
a/colSums(a)
# [,1] [,2]
# [1,] 0.0000000 0.3333333
2011 Jan 11
5
A question on dummy variable
Dear all, I would like to ask one question related to statistics, for
specifically on defining dummy variables. As of now, I have come across 3
different kind of dummy variables (assuming I am working with Seasonal
dummy, and number of season is 4):
> dummy1 <- diag(4)
> for(i in 1:3) dummy1 <- rbind(dummy1, diag(4))
> dummy1 <- dummy1[,-4]
>
> dummy2 <- dummy1
>
2004 Jun 29
1
PAM clustering: using my own dissimilarity matrix
Hello,
I would like to use my own dissimilarity matrix in a PAM clustering with
method "pam" (cluster package) instead of a dissimilarity matrix created
by daisy.
I read data from a file containing the dissimilarity values using
"read.csv". This creates a matrix (alternatively: an array or vector)
which is not accepted by "pam": A call
2007 Jul 17
1
distance function (analogue)
Hello R-Users,
its again me with a question.
I´m using R 2.5.0 on Mac Power Book running Mac OS X 10.4.10
I try to calculate distances betweeen two data tables looking like this
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18
V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36
1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 0 1
0 0
2011 Jan 28
3
sapply puzzlement
Hi,
I have this data.frame with two variables in it,
> z
V1 V2
1 10 8
2 NA 18
3 9 7
4 3 NA
5 NA 10
6 11 12
7 13 9
8 12 11
and a vector of means,
> means <- apply(z, 2, function (col) mean(na.omit(col)))
> means
V1 V2
9.666667 10.714286
My intention was substracting means from z, so instictively I tried
> z-means
V1 V2
1 0.3333333
2007 Sep 13
6
Number -> Fraction
Hi everybody!
I'm new to this list and also to the R program.
I'd like to know if there is a function able to convert results into
Fractional form like my scientific calculator have. For example:
> 1/3
[1] 0.3333333
> function_that_return_a_fraction_from_numbers(0.3333333)
[1] 1/3
Thanks
Mauro
--
Man, he is constantly growing
and when he is bound by a set
pattern of ideas
2001 Jan 09
2
PAM clustering (using triangular matrix)
Hi,
I'm trying to use a similarity matrix (triangular) as input for pam() or
fanny() clustering algorithms.
The problem is that this algorithms can only accept a dissimilarity
matrix, normally generated by daisy().
However, daisy only accept 'data matrix or dataframe. Dissimilarities
will be computed between the rows of x'.
Is there any way to say to that your data are already a
2010 Apr 18
3
xtabs() of proportions, and naming a dimension (not a row)
Hi,
xtabs() creates a table of counts. I want a table of proportions -- that
is, I want to divide every vector (along a particular dimension) by its sum.
The tiny example below does that. The call to xtabs() creates a matrix "A"
with dimensions ("x1","x2","y"). I transform "A" using aperm() and aaply()
to get the matrix "B". The
2009 Nov 04
3
Constrained Optimization
Hi All,
I'm trying to do the following constrained optimization example.
Maximize x1*(1-x1) + x2*(1-x2) + x3*(1-x3)
s.t. x1 + x2 + x3 = 1
x1 >= 0 and x1 <= 1
x2 >= 0 and x2 <= 1
x3 >= 0 and x3 <= 1
which are the constraints.
I'm expecting the answer x1=x2=x3 = 1/3.
I tried the "constrOptim" function in R and I'm running into some issues.
I first start off
2018 Mar 15
0
cubic complete Scheffe mixture models
Hello everyone
I'm trying to use Scheffe's complete cubic model (mixture design).
In the bibliographies, they indicate that the term is of the type: A * B
* (A-B).
But I see that trying to adjust the three cubic terms results in
singularities.
I know this implies not having the inverse matrix:
solve (t (X)% *% X) does not exist.
The bibliographies show all three cubic terms.
So my
2002 Mar 08
1
Matrix multiplication problem
Dear List,
I am having trouble with some R code I have written to perform
Redundancy Analysis (RDA) on a matrix of species abundance data (Y) and
a matrix of environmental data (X).
RDA is a constrained form of PCA and can be thought of as a PCA of the
fitted values of a regression of each variable in Y on all variables in
X.
For info, the first use of RDA is in:
Rao, C.R, 1964. The use and
2009 Jan 23
1
Interpreting model matrix columns when using contr.sum
With the following example using contr.sum for both factors,
> dd <- data.frame(a = gl(3,4), b = gl(4,1,12)) # balanced 2-way
> model.matrix(~ a * b, dd, contrasts = list(a="contr.sum", b="contr.sum"))
(Intercept) a1 a2 b1 b2 b3 a1:b1 a2:b1 a1:b2 a2:b2 a1:b3 a2:b3
1 1 1 0 1 0 0 1 0 0 0 0 0
2 1 1 0 0 1 0
2008 Apr 19
1
resampling from distributions
Hello All,
Once again thanks for all of the help to date. I am climbing my R learning
curve. I've got a few more questions that I hope I can get some guidance on
though. I am not sure whether the etiquette is to break up multiple
questions or not but I'll keep them together here for now as it may help put
the questions in context despite the fact that the post may get a little
long.
2013 Mar 14
1
ggplot2 problem
Hello all!
I have a problem with ggplot2 library. I want to do an heat map and the y
variables are the year months. If I use the following code, he y values are
in alphabetical order, but I want it in month order.
The code is:
library(reshape)
library(ggplot2)
library(scales)
p <- ggplot(data.m, aes(variable, Month)) + geom_tile(aes(fill = value),
2008 Aug 27
1
ifelse() fill order and recycling rules [Sec=Unclassified]
Hi all,
Using R v2.7.1, platform i386-pc-mingw32
Can someone please shed some light on the behaviour of ifelse() for me?
My intent is to calc relative proportions of z$b, at the same time
subsetting z$b based on z$a. I could attack the problem other ways
(suggestions welcome) but I am also intrigued by the _order_ in which
ifelse seems to assign values, and how recycling works. For instance,
2011 Oct 31
3
Plot two matrices and keeping the record of row names
Dear all,
I have two data frames- x1 and y1 with same row names and column names(actually the names of the patients).
x1
a b c d e
a 1.0000000 0.4730679 0.6226994 0.6036036 0.6433333
b 0.4730679 1.0000000 0.6227273 0.6303855 0.5730858
c 0.6226994 0.6227273 1.0000000 0.7290503 0.6900585
d 0.6036036 0.6303855 0.7290503 1.0000000
2012 Jun 11
1
saving sublist lda object with save.image()
Greetings R experts,
I'm having some difficulty recovering lda objects that I've saved within sublists using the save.image() function. I am running a script that exports a variety of different information as a list, included within that list is an lda object. I then take that list and create a list of that with all the different replications I've run. Unfortunately I've been
2016 May 13
2
Division entre el numero de ocurrencias parciales y totalesdentro de un DataFrame de manera eficiente
Hola:
Aplicaré lo que dices de usar data.table.
Sobre hacer for, etc. Ya lo he hecho, pero pensaba que usar dplyr haría la
tarea más rápida por estar este implementado en C (si no me equivoco).
Siempre que puedo utilizo estas funciones, porque codificas menos y van más
rápido. En este caso el problema es que no he encontrado la manera de hacer
lo que quiero con dplyr o similar. La idea era al
2010 Feb 08
2
Incorrect Kendall's tau for ordered variables (PR#14207)
Full_Name: Marek Ancukiewicz
Version: 2.10.1
OS: Linux
Submission from: (NULL) (74.0.49.2)
Both cor() and cor.test() incorrectly handle ordered variables with
method="kendall", cor() incorrectly handles ordered variables for
method="spearman" (method="person" always works correctly, while
method="spearman" works for cor.test, but not for cor()).
In
2013 Jan 18
1
scaling of nonbinROC penalties
Dear R Helpers
I am having difficulty understanding how to use the penalty matrix for the nomROC function in package 'nonbinROC'.
The documentation says that the values of the penalty matrix code the
penalty function L[i,j] in which 0 <= L[i,j] <= 1 for
j > i. It gives an example that if we have an ordered response with 4 categories, then we might wish to penalise larger