Displaying 20 results from an estimated 20000 matches similar to: "Finding a single unique item in duplicated vectors"
2008 Jun 19
5
R web site-Useability & finding varous bits of documentation
I was starting to write a note to a prospective R-user and came to the point of explaining how to get useful introductory information on R.
After mentioning the Into and the FAQs I went on to try to explain how to use a lot of the contributed information.
However I realised that there seems to be no direct way to get to Other Publications or Contributed Documenation.
The best I have seen is
2012 Jul 06
4
Poisson Ridge Regression
Dear everyone
I'm dealing with a problem related to Poisson Ridge Regression. If
anyone can help me in this regard by telling if any changes in the
source code of "glm.fit" may help
--
Regards
Umesh Khatri
2010 Jul 05
2
to remove duplicate values
Dear R family,
Suppose I have two series.
order value
1 0.52
2 0.23
3 0.43
4 0.21
5 0.32
6 0.32
7 0.32
8 0.32
9 0.32
10 0.12
11 0.46
12 0.09
13 0.32
14 0.25
For these two series, I figured out the way to detect the locations of
duplicate values.
The next thing to do is remove the repeated values except for a value
that would not be next to each other.
In other words, while keeping the
2007 Feb 22
4
Crosstabbing multiple response data
Using R version 2.4.1 (2006-12-18) on Windows, I have a dataset which resembles this:
id att1 att2 att3
1 1 1 0
2 1 0 0
3 0 1 1
4 1 1 1
ratings <- data.frame(id = c(1,2,3,4), att1 = c(1,1,0,1), att2 = c(1,0,0,1), att3 = c(0,1,1,1))
I would like to get a cross tab of counts of co-ocurrence, which might resemble this:
2006 Dec 31
4
Does SQL group by have a heavy duty equivalent in R
I have hundreds of humans who have undergone SNP genotyping at hundreds of
loci. Some have even undergone the procedure twice or thrice (kind of an
internal control).
So obviously I need to find those replications, and confirm that the results
are the same. If there is discordance then I need to address it.
I tried to use the aggregate function
nr.attempts
2010 Jul 05
4
To detect the location of duplicate values
Dear R family,
I have a question about how to detect some duplicate numeric observations.
Suppose that I have two variables dataset.
order value
1 0.52
2 0.23
3 0.43
4 0.21
5 0.32
6 0.32
7 0.32
8 0.32
9 0.32
10 0.12
11 0.46
12 0.09
13 0.32
14 0.25
;
Could you help me indicate where the duplicate observations in a row
(e.g., 0.32) are?
best,
moohwan
2010 Jun 13
5
Count of unique factors within another factor
I have a data frame with two factors (sampling 'unit', 'species'). I want to
calculate the number of unique 'species' per 'unit.' I can calculate the
number of unique values for each variable separately, but can't get a count
for each ?unit?.
> data=read.csv("C:/Desktop/sr_sort_practice.csv")
> attach(data)
> data[1:10,]
unit species
1
2008 Mar 06
1
switch with a single character
Can anyone explain the results from switch below when a single
charachter "E" is entered? It seems to work with letter S or N...
> switch("East",West=1,East=2) # Correct
[1] 2
> switch("E",W=1,E=2) # Not so correct
[1] 1
> switch("E",E=1,W=2) # Even stranger
[1] "E"
> switch("S",N=1,S=-1) # Correct
[1] -1
Kind regards,
2001 Feb 06
1
AW: Proposal: Generalizing unique() and duplicated()
On Tuesday 06 February 2001 12:36, Dr. Jens Oehlschlägel wrote:
> I like the idea. Why don't you call duplicated.matrix() directly in
> unique.matrix() and duplicated.data.frame() in unique.data.frame() ?
>
> Jens Oehlschlägel
Good point. I guess I got carried away with using methods (having just gotten
the hang of the concept). :-)
Anyway, here's a corrected version:
2010 Jun 13
1
Finding an order for an hclust (dendrogram) object without intersections
Hello all,
I manually created an hclust object.
Now I am looking to reorder the leafs so they won't intersect with each
other, and would be happy for advises on how to do that.
Here is an example code:
#-------------------------------------
a <- list() # initialize empty object
# define merging pattern:
# negative numbers are leaves,
# positive are merged clusters (defined by row
2009 Sep 07
2
finding the minimum value
Hi all,
I'm using a certain procedure to calculate the value of some variable(Bayes risk),B.
So I got the values B1, B2, ........, B1000, each under certain input values and using a long procedure.
Now, I want to put the values I got in a nummerical vector and find their minimum value. I think c( ) should work.For example if I have only 10 values I could have used
2007 Nov 19
1
Finding proportion of observations that are outliers from the left tail of the normal distribution
Hi fellow users
I have a new R problem i am hoping to get some pointers on. I have a
dataset that is approximately normally distributed but with a fat left
tail. I am interested in a good measurement on how much fatter the
left tail is than can be expected from a normal distribution. One
thing I'll tried was fitting a two component mixture model with the
Rmix package but i am also interested
2008 Oct 30
3
why does sample(x, n) give the same n items in every separate runs?
Hello R users,
I have gene expression data of two groups of genes (large and small). Gene expression intensities of those genes are classified into 1 to 10 levels. What I want is to make a random set of genes that have the same levels as the small group from large group using sample().
I used smallvec to hold the number of genes in each levels (1 to 10) for small group, largevec for large group.
2011 Feb 28
3
Problems using unique function and !duplicated
Hi, I am trying to simultaneously remove duplicate variables from two or more
variables in a small R data.frame. I am trying to reproduce the SAS
statements from a Proc Sort with Nodupkey for those familiar with SAS.
Here's my example data :
test <- read.csv("test.csv", sep=",", as.is=TRUE)
> test
date var1 var2 num1 num2
1 28/01/11 a 1 213 71
2
2008 Dec 15
2
Duplicates among columns of a data frame
Dear list,
I have a data frame of survey respondents, a little like this:
set.seed(20081215)
n <- 100
dat <- data.frame(id=1:100,
addr1=sample(LETTERS, n, replace=TRUE),
addr2=sample(LETTERS, n, replace=TRUE),
addr3=sample(LETTERS, n, replace=TRUE))
head(dat)
id addr1 addr2 addr3
1 1 R H Q
2 2 H C K
3 3
2007 Sep 13
3
difference between unique() and !duplicated()
Yesterday I spend the whole day struggling on how to get
the maximum value of "y" for every unique value of "x"
from the dataframe "test". In the R Book (Crawley, 2007)
an example of this can be found on page 121. I tried to do
it this way, but I failed.
In the end, I figured out how to get it working (first
order, and afterwards use !duplicated()). My question
2010 Jun 08
2
duplicated() and unique() problems
Hi everybody
I have found something (for me at least) strange with duplicated(). I will
first provide a replicable example of a certain kind of behaviour that I
find odd and then give a sample of unexpected results from my own data. I
hope someone can help me understand this.
Consider the following
# this works as expected
ex=sample(1:20, replace=TRUE)
ex
duplicated(ex)
ex=sort(ex)
ex
2008 Dec 09
2
Better way to find distances between points in a set?
I was playing around a bit to see how I could find the two points in a
set of points (or ordered pairs) furthest from each other.
Here's what I did:
1) created a Nrow by 2col matrix, so each row contains an x,y coordinate
pair.
2) fed the matrix to a nested mapply (cv is my matrix):
mapply(function(k,l) mapply(function(x,y,a,b)
+
2008 Aug 06
4
Union of columns of two matrices
I was posed the following problem/teaser:
given two matrices, come up with an "elegant" (=fast & short) function that
returns a matrix with all and only the non-duplicated columns of both
matrices; the column order does not matter. In essence, a matrix equivalent
of union(x,y), where x and y are vectors. I could not come with anything
nice. Any ideas?
Giuseppe
--
Giuseppe A.
2007 Nov 30
2
finding roots (Max Like Est)
I have this maximum liklihood estimate problem
i need to find the roots of the following:
[sum (from i=1 to n) ] ((2(x[i]-parameter)/(1+(x[i]-parameter)^2))=0
given to me is the x vector which has length 100
how would I find the roots using R?
I have 2 thoughts...... 1 is using a grid search ... eg. brute force, just
choosing a whole bunch of different values for my parameter .... such as