Perhaps have a look at the sp package and especially the over function.
Br. Frede
Sendt fra Samsung mobil
Oprindelig meddelelse
Fra: Leonid Shvartser
Dato:27/03/2014 20.27 (GMT+01:00)
Til: r-help@r-project.org
Emne: [R] index polygons
Hello,
I need to compare a polygon with
Hello,
I need to compare a polygon with a set of other polygons.
I'd like to index polygons with a grid in order not to compare definitely
distant ones.
How can I do this?
I need
1. Transform polygons to cells
2. Find cell neighbors (defined cell distance) for a polygon
Thanks
Leoni
Dear all,
I would like to compute index of quantile variation (iqv) for each
observation in my survey data according to their responses on three
categorical variable.
Do you know iqv function for this purpose in a package?
All the best,
Niklas
[[alternative HTML version deleted]]
_
arl...@tamu.edu; r-help@r-project.org
Cc: sarah.gos...@gmail.com
Subject: RE: [R] Index out SNP position
Hi David,
Thanks for your reply!
But what if I cannot change the positions of each row pairs in A. Sorry I
did not make it very clear.
The two columns in A represent start-and-end or end-
On Jan 3, 2013, at 1:54 PM, JiangZhengyu wrote:
>
>
>
>
>
>
> Dear R experts,
>
> I have 2 matix: A& B. I am trying to index B against A - (1) find out B rows
> that fall between the col 1 and 2 of A& put them into a new vector SNP.I
> made code as below, but I cannot think of a right w
index out all the single
nucleotides that fall between the start and end region of a gene. Jiang
> From: dcarl...@tamu.edu
> To: dcarl...@tamu.edu; zhyjiang2...@hotmail.com; r-help@r-project.org
> CC: sarah.gos...@gmail.com
> Subject: RE: [R] Index out SNP position
> Date: Thu, 3 Ja
sapply(1:nrow(B), function(i) any(B[i]>A[,1] & B[i] SNP <- B[indx]
> SNP
[1] 36003918 35838399 35838589
---
David
> -Original Message-
> From: David L Carlson [mailto:dcarl...@tamu.edu]
> Sent: Thursday, January 03, 2013 4:23 PM
> To: 'JiangZhengyu'; &
Station, TX 77843-4352
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of JiangZhengyu
> Sent: Thursday, January 03, 2013 3:55 PM
> To: r-help@r-project.org
> Subject: [R] Index out SNP position
>
>
>
>
&g
t; Actually, I have over 10,000 in B and over 5000 ranges in A. What if I only
> need to take out all the B rows that fall into the ranges of A? - remove the
> repetitive results.
>
> Best,
> Jiang
>
>> Date: Thu, 3 Jan 2013 17:04:59 -0500
>> Subject: Re: [R] Index
Thu, 3 Jan 2013 17:04:59 -0500
> Subject: Re: [R] Index out SNP position
> From: sarah.gos...@gmail.com
> To: zhyjiang2...@hotmail.com
> CC: r-help@r-project.org
>
> Assuming I understand what you want, which I'm not certain of, here's
> one way; there are more (probabl
Assuming I understand what you want, which I'm not certain of, here's
one way; there are more (probably some more elegant).
I'm not sure how you'd put them in a vector, since there are different
numbers of values for each row of A, so instead I've made a list.
unlist(SNP) will turn it into a vecto
Dear R experts,
I have 2 matix: A& B. I am trying to index B against A - (1) find out B rows
that fall between the col 1 and 2 of A& put them into a new vector SNP.I made
code as below, but I cannot think of a right way to do it. Could anyone help
me with the code? Thanks,Jiang
A
Dear All,i applied "NbClust", to my data to find optimum number of clusters,
and got following resultsNow, i don't know how to read these results. more
precisely, i would like to know, how to see which method is more precise for my
data considering these index values.your help is needed...thank
On May 1, 2012, at 09:06 , Ulfa Hasanah wrote:
> what is "nb2listw" in index moran?
Did you try help(nb2listw) ?
--
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk Priv: pda..
what is "nb2listw" in index moran?
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide c
Joshua,
Just confirming quickly that your method using cmpfun and your f function
below was fastest using my real data. Again, thank you for your help!
Ben
On Sat, Mar 10, 2012 at 1:21 PM, Joshua Wiley wrote:
> On Sat, Mar 10, 2012 at 12:11 PM, Ben quant wrote:
> > Very interesting. You are d
On Sat, Mar 10, 2012 at 12:11 PM, Ben quant wrote:
> Very interesting. You are doing some stuff here that I have never seen.
and that I would not typically do or recommend (e.g., fussing with
storage mode or manually setting the dimensions of an object), but
that can be faster by sacrificing high
Very interesting. You are doing some stuff here that I have never seen.
Thank you. I will test it on my real data on Monday and let you know what I
find. That cmpfun function looks very useful!
Thanks,
Ben
On Sat, Mar 10, 2012 at 10:26 AM, Joshua Wiley wrote:
> Hi Ben,
>
> It seems likely that t
Hi Ben,
It seems likely that there are bigger bottle necks in your overall
program/use---have you tried Rprof() to find where things really get
slowed down? In any case, f2() below takes about 70% of the time as
your function in your test data, and 55-65% of the time for a bigger
example I constr
Thanks for the info. Unfortunately its a little bit slower after one apples
to apples test using my big data. Mine: 0.28 seconds. Yours. 0.73 seconds.
Not a big deal, but significant when I have to do this 300 to 500 times.
regards,
ben
On Fri, Mar 9, 2012 at 1:23 PM, Rui Barradas wrote:
> Hel
Hello,
I don't know if it's the fastest but it's more natural to have an index
matrix with two columns only,
one for each coordinate. And it's fast.
fun <- function(valdata, inxdata){
nr <- nrow(inxdata)
nc <- ncol(inxdata)
mat <- matrix(NA, nrow=nr*nc, ncol=2)
i1
Here is my latest. I kind of changed the problem (for speed). In real life
I have over 300 uadata type matrices, each having over 20 rows and over
11,000 columns. However the rddata file is valid for all of the uadata
matrices that I have (300). What I am doing now: I'm creating a matrix of
row ind
> Hello,
>
> Is this the fastest way to use indices from one matrix to reference rows
> in another smaller matrix? I am dealing with very big data (lots of columns
> and I have to do this lots of times).
>
> ##sample data ##
> vals = matrix(LETTERS[1:9], nrow=3,ncol=3)
> colnames(va
Hello,
> Humm If I understand what you are saying, you are correct. I get
> 144.138 for 2009-03-20 for column C. Maybe I posted the wrong code? If
> so,
> sorry.
I think I have the fastest so far solution, and it checks with your
corrected,last one.
I've made just a change: to transform it
Humm If I understand what you are saying, you are correct. I get
144.138 for 2009-03-20 for column C. Maybe I posted the wrong code? If so,
sorry. Let me know if you disagree. I still plan to come back to this and
optimize it more, so if you see anything that would make it faster that
would b
Hello again.
Ben quant wrote
>
> Hello,
>
> In case anyone is interested in a faster solution for lots of columns.
> This
> solution is slower if you only have a few columns. If anyone has anything
> faster, I would be interested in seeing it.
>
> ### some mockup data
> z.dates =
> c("2007-03
Hello,
In case anyone is interested in a faster solution for lots of columns. This
solution is slower if you only have a few columns. If anyone has anything
faster, I would be interested in seeing it.
### some mockup data
z.dates =
c("2007-03-31","2007-06-30","2007-09-30","2007-12-31","2008-03-3
Hello,
> Just looking at this, but it looks like ix doesn't exist:
>sapply(1:length(inxlist), function(i) if(length(ix[[i]]))
> fin1[ix[[i]], tkr + 1] <<- ua[i, tkr])
>
> Trying to sort it out now.
Right, sorry.
I've changed the name from 'ix' to 'inxlist' to make it more readable just
Unfortunately, your solution is does not scale well. (Tough for you to
test this without my real data.) If ua is my data and rd1 are my report
dates (same as the code below) and I use more columns, it appears that your
solution slows considerably. Remember I have ~11k columns in my real data,
so
I think this is what you meant:
z.dates =
c("2007-03-31","2007-06-30","2007-09-30","2007-12-31","2008-03-31","2008-06-30","2008-09-30","2008-12-31")
nms = c("A","B","C","D")
# these are the report dates that are the real days the data was available
rd1 = matrix(c("20070514","20070814","20071115",
Just looking at this, but it looks like ix doesn't exist:
sapply(1:length(inxlist), function(i) if(length(ix[[i]]))
fin1[ix[[i]], tkr
+ 1] <<- ua[i, tkr])
Trying to sort it out now.
Ben
On Mon, Mar 5, 2012 at 7:48 PM, Rui Barradas wrote:
> Hello,
>
> >
> > Mar 05, 2012; 8:53pm by Ben
Hello,
>
> Mar 05, 2012; 8:53pm — by Ben quant Ben quant
> Hello,
>
> Does anyone know of a way I can speed this up?
>
Maybe, let's see.
>
> # change anything below.
>
# Yes.
# First, start by using dates, not characters
fdate <- function(x, format="%Y%m%d")
Hello,
Does anyone know of a way I can speed this up? Basically I'm attempting to
get the data item on the same row as the report date for each report date
available. In reality, I have over 11k of columns, not just A, B, C, D and
I have to do that over 100 times. My solution is slow, but it works
On Mar 26, 2011, at 2:03 PM, Quan Zhou wrote:
Hi
How can I return the index of sort, when I use R function sort?
or any other sorting functions in R
For example, I sorted a vector, but R just return the sorted value
without
giving me the original index of these data.
You seem to be looking
Hi
How can I return the index of sort, when I use R function sort?
or any other sorting functions in R
For example, I sorted a vector, but R just return the sorted value without
giving me the original index of these data.
Thanks a lot.
[[alternative HTML version deleted]]
___
Marianne -
The function you're looking for is mapply:
mapply(function(one,two)one[two],x,y)
[[1]]
[1] "one"
[[2]]
[1] "four" "five"
- Phil Spector
Statistical Computing Facility
I have two lists of the same shape, like this:
x <- list()
x[[1]] <- c("one","two")
x[[2]] <- c("three","four","five")
y <- list()
y[[1]] <- c(TRUE,FALSE)
y[[2]] <- c(FALSE,TRUE,TRUE)
I would like to index x "by" y, that is, the result in this case
should be:
z
[[1]]
[1] "one"
[[2]]
[1] "four
On Jun 30, 2010, at 10:48 PM, harsh yadav wrote:
Hi,
I am a newbie to R and this may be too simple to ask.
I am trying to find out a string function in R that returns the
index of a
character.
For e.g. indexOf("Test1234", '4') would return 8.
?grep
?strsplit
> grep("4", strsplit("Test1
On Jun 30, 2010, at 10:48 PM, harsh yadav wrote:
Hi,
I am a newbie to R and this may be too simple to ask.
I am trying to find out a string function in R that returns the
index of a
character.
For e.g. indexOf("Test1234", '4') would return 8.
Is there a similar function in R.
I tried sea
Hello,
This does what you are looking for:
> regexpr("4", "Test1234")
[1] 8
attr(,"match.length")
[1] 1
see ?regexpr also ?regexp for more details on regular expressions in R.
HTH,
Josh
On Wed, Jun 30, 2010 at 7:48 PM, harsh yadav wrote:
> Hi,
>
> I am a newbie to R and this may be too simp
harsh yadav wrote:
Hi,
I am a newbie to R and this may be too simple to ask.
I am trying to find out a string function in R that returns the index of a
character.
For e.g. indexOf("Test1234", '4') would return 8.
> regexpr("4", "Test1234")
[1] 8
attr(,"match.length")
[1] 1
_
Hi,
I am a newbie to R and this may be too simple to ask.
I am trying to find out a string function in R that returns the index of a
character.
For e.g. indexOf("Test1234", '4') would return 8.
Is there a similar function in R.
I tried searching the documentation and could find other useful str
Ah.
Close to what David suggested...
Try:
?which.max
Contact
Details:---
Contact me: tal.gal...@gmail.com | 972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English
On Apr 22, 2010, at 3:45 PM, tamas barjak wrote:
Hi All!
I have a problem that I do not know it how it is necessary to query
an index
belonging to a given value.
I bit hard to tell without an example but suspect you want:
?which
--
David Winsemius, MD
West Hartford, CT
___
Hi All!
I have a problem that I do not know it how it is necessary to query an index
belonging to a given value.
Somebody would help?
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listin
Thanks for all your help. Yes, it's very helpful.
Annie
On Thu, Sep 10, 2009 at 11:42 AM, Marc Schwartz wrote:
> On Sep 10, 2009, at 1:34 PM, annie Zhang wrote:
>
> Hi, All,
>>
>> How can I get the indices of the minimum elements in a matrix without
>> using
>> a loop?
>>
>> For example, if the
On Sep 10, 2009, at 1:34 PM, annie Zhang wrote:
Hi, All,
How can I get the indices of the minimum elements in a matrix
without using
a loop?
For example, if the matrix is
4 5 2
2 8 9
5 2 3
Then I want to output (1,3), (2,1), (3,2).
Thanks,
Annie
mat <- matrix(c(4, 2, 5, 5, 8, 2, 2, 9
Try this:
m <- rbind(c(4,5,2), c(2,8,9), c(5,2,3))
cbind(1:NROW(m), apply(m, 1, which.min))
On Thu, Sep 10, 2009 at 3:34 PM, annie Zhang wrote:
> Hi, All,
>
> How can I get the indices of the minimum elements in a matrix without using
> a loop?
>
> For example, if the matrix is
>
> 4 5 2
> 2 8
Hi, All,
How can I get the indices of the minimum elements in a matrix without using
a loop?
For example, if the matrix is
4 5 2
2 8 9
5 2 3
Then I want to output (1,3), (2,1), (3,2).
Thanks,
Annie
[[alternative HTML version deleted]]
__
R
Is this what you want:
> set.seed(1)
> x <- sample(letters,15)
> y <- sample(letters,15)
> z <- intersect(x,y)
> # find index in x
> match(z, x)
[1] 1 4 5 8 9 12 13 15
> # index in y
> match(z,y)
[1] 11 10 7 1 14 9 5 3
>
> z
[1] "g" "u" "e" "m" "l" "c" "y" "x"
> x
[1] "g" "j" "n" "u" "e
Hi all,
Is there a way to get the index of elements in intersect(x,y) where x and y
are vectors with few common elements.
Appreciate your response.
Praveen Surendran.
[[alternative HTML version deleted]]
__
R-help@r-project.org m
On Sun, Jul 19, 2009 at 11:32 PM, Marujo A. wrote:
> Dear R-helpers
> I have 2 variables
> x1=rgamma(6000, 2, 1) and x2=rgamma(6000, 3,2). I have to sort (descending)
> each one and split it into groups. After this each two groups must be merged
> into one until all population becomes one group.
Dear R-helpers
I have 2 variables
x1=rgamma(6000, 2, 1) and x2=rgamma(6000, 3,2). I have to sort (descending)
each one and split it into groups. After this each two groups must be merged
into one until all population becomes one group. A dummy vector must be created
for each group (8, 4, 2, 1)
Dear all,
I found the answer:
intersect()
- John
On Thu, May 21, 2009 at 7:32 PM, tsunhin wong wrote:
> Dear Jim,
> Thanks for your suggestion.
>
> I have a follow-up question for fellow R Users that have followed this thread:
>
> *I used to create two lists by some very flexible criteria to co
Dear Jim,
Thanks for your suggestion.
I have a follow-up question for fellow R Users that have followed this thread:
*I used to create two lists by some very flexible criteria to compare
from "iData" and pass the two lists to *ANOTHER FUNCTION* that further
decompose the two lists and do some cas
Assuming that you get the list of indices into iData for the criteria, then
you can use that to get the appropriate rows:
indx <- which(iData >5) # or whatever your criteria is
DataSeq[indx,, drop=FALSE] # gives you a subset matrix of just the rows you
are interested in.
On Thu, May 21, 2009 at
Dear R Users,
I have created a 1500 x 2 data frame - DataSeq. Each of the 1500
rows represents a data sequence.
I have another data frame iData that stores the information of these
1500 data sequences in the same order, for example, condition, gender,
etc.
If I use "subset" to select certain
I am using some functions from package clusterSim to evaluate the best clusters
layout.
Here is the features vector I am using to cluater 12 signals:
> alpha.vec
[1] 0.8540039 0.8558350 0.8006592 0.8066406 0.8322754 0.8991699 0.8212891
[8] 0.8815918 0.9050293 0.9174194 0.8613281 0.8425293
In t
On Wed, Aug 06, 2008 at 05:42:21PM +, zack holden wrote:
>
> Dear R wizards,
>
> I have a folder containing 1000 files. For each file, I need to extract the
> first row of each file, paste it to a new file, then write out that file.
> Then I need to repeat this operation for each additiona
On Wed, 6 Aug 2008, zack holden wrote:
Dear R wizards,
I have a folder containing 1000 files. For each file, I need to extract the
first row of each file, paste it to a new file, then write out that file. Then
I need to repeat this operation for each additional row (row 2, then row 3,
etc)
Dear R wizards,
I have a folder containing 1000 files. For each file, I need to extract the
first row of each file, paste it to a new file, then write out that file. Then
I need to repeat this operation for each additional row (row 2, then row 3,
etc) for 23 rows in each file.
I can do this
Or see the "Oarray" package (note that's
a letter O, not a zero!)
Ben Bolker
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provid
On Feb 18, 2008 6:52 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> You can define origin 0 objects yourself if you like.
> Here is a partial implementation:
>
> "[.orig0" <- function(x, i)
The 0 should be a 1.
>if (is.numeric(i)) .subset(x, i+0) else .subset(x, i)
> orig0 <- function(x)
You can define origin 0 objects yourself if you like.
Here is a partial implementation:
"[.orig0" <- function(x, i)
if (is.numeric(i)) .subset(x, i+0) else .subset(x, i)
orig0 <- function(x)
structure(x, class = c("orig0", setdiff(class(x), "orig0")))
x <- orig0(1:5)
x[0:3] # 1:4
Note tha
It looks to me like the index range starts at 1 in R.
Is this true?
If so, is there a way to change it to start at 0?
That way, I wouldn't have to make so many
changes when I translate a function from
another language.
--
View this message in context:
http://www.nabble.com/index-range-tp15550797
> I would like to know if it?s possible to create an index for a
> variable/vector that specifies the value in the n position before
> the actual value.
>
> For example, if X <- c(letters[1:10]), x[10] is ?j?. I would like to
> create an index exp3 (the third position before) such as if z <-
>
Is exp3 <- c(rep(NA, 3), seq_along(x)) what you are looking for?
> x[exp3][10]
[1] "g"
(I presume you meant x <- letters[1:10]: R is case-sensitive and you don't
need c() to concatenate a single vector.)
On Wed, 2 Jan 2008, Antonio Gasparrini wrote:
> Dear all,
>
> I would like to know if it's
Dear all,
I would like to know if it’s possible to create an index for a variable/vector
that specifies the value in the n position before the actual value.
For example, if X <- c(letters[1:10]), x[10] is “j”. I would like to create an
index exp3 (the third position before) such as if z <- x[ex
> From a dataframe there are 27 variables of interest, with the
> prefix of "pre".
>
> [7] "Decision" "MHCDate" "pre01" "pre0" "pre012" "pre013"
> [13] "pre02" "pre02111" "pre02114" "pre0211" "pre0212" "pre029"
> [19] "pre03a""pre0311" "pre0312" "pre03" "pre04"
I was hoping for some advice regarding indexing,
From a dataframe there are 27 variables of interest, with the prefix of "pre".
[7] "Decision" "MHCDate" "pre01" "pre0" "pre012""pre013"
[13] "pre02" "pre02111" "pre02114" "pre0211" "pre0212" "pre029"
[19] "pre03a""p
70 matches
Mail list logo