Re: [R] Match coordinates to regional polygon

2020-03-09 Thread Bert Gunter
I believe this would be better posted on r-sig-Geo . Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Mar 9, 2020 at 3:16 PM Miluji Sb wrote: > Dear all,

[R] Match coordinates to regional polygon

2020-03-09 Thread Miluji Sb
Dear all, I am trying to match a large number of coordinates (attached) sub-national regions using GADM shapefile. Coordinates: https://drive.google.com/file/d/1PUsi4d0wP7hB6Aps6UmpXsnIPSD3I1sT/view?usp=sharing Shapefile: https://drive.google.com/drive/folders/1DxyygjQNeg2GIS9doaFM8yM2LvBYZi8E?u

Re: [R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Knut Krueger
Am 22.10.18 um 18:02 schrieb Bert Gunter: I suggest you spend a bit of time with an R tutorial or two and, in particular learn about "logical indexing," as this basic R construct seems to be mysterious to you. Hi Bert, especially the "match" help area is a little bit confusing. And additiona

Re: [R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Bert Gunter
I suggest you spend a bit of time with an R tutorial or two and, in particular learn about "logical indexing," as this basic R construct seems to be mysterious to you. Cheers, Bert On Mon, Oct 22, 2018 at 8:22 AM Knut Krueger wrote: > Am 22.10.18 um 17:01 schrieb Eric Berger: > > v <- match(

Re: [R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Knut Krueger
Am 22.10.18 um 17:01 schrieb Eric Berger: v <- match(Mydata$DATA1, needles, nomatch=NA) > found <- Mydata[ !is.na (v), ] > missing <- Mdata[ is.na (v), ] Thank you it is working, additionally as Bert suggested, it seems that Mydata[Mydata$DATA1 %in% needles,] is

Re: [R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Eric Berger
Hi Knut, You are almost done. > v <- match(Mydata$DATA1, needles, nomatch=NA) > found <- Mydata[ !is.na(v), ] > missing <- Mdata[ is.na(v), ] HTH, Eric On Mon, Oct 22, 2018 at 5:51 PM Bert Gunter wrote: > Re-read ?match and note the examples for %in% > > -- Bert > Bert Gunter > > "The trouble

Re: [R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Bert Gunter
Re-read ?match and note the examples for %in% -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Oct 22, 2018 at 7:38 AM Knut Krueger wrote: > > Hi

[R] match() question or needle haystack problem for a data.frame

2018-10-22 Thread Knut Krueger
Hi to all I would like to reduce the "Mydata" to rows, only if Mydata$Data1 are in needles needles =c(14390, 14391, 14392, 14427, 14428, 14429, 14430, 14431, 14432, 14433, 14434, 14435, 14436, 14437, 14439, 14440, 14441, 15195, 15196, 15197, 15198, 15199, 15200, 15201, 15202, 15203, 1520

Re: [R] match and new columns

2017-12-15 Thread Ek Esawi
Hi Val— Here is something similar to what Bill suggested. wainb <- which(tdat$A %in% tdat$B) tdat[c(length(tdat$D)-1,length(tdat$D)),c("D","E")] <- tdat[wainb,c("B","C")] HTH EK On Wed, Dec 13, 2017 at 4:36 PM, Val wrote: > Hi all, > > I have a data frame > tdat <- read.table(textConnection(

Re: [R] match and new columns

2017-12-13 Thread William Dunlap via R-help
Try the following (which won't work with factors): > i <- match(tdat$B, tdat$A) > newColumns <- tdat[i, c("B", "C")] > newColumns[is.na(newColumns)] <- "0" > transform(tdat, D=newColumns[["B"]], E=newColumns[["C"]]) A B CY D E 1 A12 B03 C04 0.70 0 0 2 A23 B05 C06 0.05 0 0 3

Re: [R] match and new columns

2017-12-13 Thread Val
Hi Bill, I put stringsAsFactors = FALSE still did not work. tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE ,stringsAsFactors = FALSE) tdat$D <- 0 tdat$E <- 0 tdat$D <- (ifelse(tdat$B %in% tdat$A, td

Re: [R] match and new columns

2017-12-13 Thread William Dunlap via R-help
Use the stringsAsFactors=FALSE argument to read.table when making your data.frame - factors are getting in your way here. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Dec 13, 2017 at 3:02 PM, Val wrote: > Thank you Rui, > I did not get the desired result. Here is the output from your sc

Re: [R] match and new columns

2017-12-13 Thread Val
Thank you Rui, I did not get the desired result. Here is the output from your script A B CY D E 1 A12 B03 C04 0.70 0 0 2 A23 B05 C06 0.05 0 0 3 A14 B06 C07 1.20 0 0 4 A25 A23 A12 3.51 1 1 5 A16 A25 A14 2,16 4 4 On Wed, Dec 13, 2017 at 4:36 PM, Rui Barradas wrote: > Hello, > > Here i

Re: [R] match and new columns

2017-12-13 Thread Rui Barradas
Hello, Here is one way. tdat$D <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$B], 0) tdat$E <- ifelse(tdat$B %in% tdat$A, tdat$A[tdat$C], 0) Hope this helps, Rui Barradas On 12/13/2017 9:36 PM, Val wrote: Hi all, I have a data frame tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A2

[R] match and new columns

2017-12-13 Thread Val
Hi all, I have a data frame tdat <- read.table(textConnection("A B C Y A12 B03 C04 0.70 A23 B05 C06 0.05 A14 B06 C07 1.20 A25 A23 A12 3.51 A16 A25 A14 2,16"),header = TRUE) I want match tdat$B with tdat$A and populate the column values of tdat$A ( col A and Col B) in the newly created columns

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-18 Thread Janko Thyson
Hi Steve, and thanks so much for taking the time to draft your solution! After running through it looks like it's EXACTLY what I was looking/hoping for! For those interested: I also tried to get this in as a feature request for the lubridate package >> https://github.com/hadley/lubridate/issues/5

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-18 Thread S Ellison
> -Original Message- > (yw <- format(posix, "%Y-%V")) > > # [1] "2015-52" "2015-53" "2016-53" "2016-01" > > Which, after checking back with a calendar, would give me reason to believe > that it using %V does in fact seem to work: it's an input to `format()` and R > doesn't seem to ignore

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-14 Thread peter dalgaard
d Winsemius >> Cc: r-help@r-project.org >> Subject: Re: [R] Match ISO 8601 week-of-year numbers to month-of-year >> numbers on Windows with German locale >> >> Aye, but this: >> >> some_dates <- as.POSIXct(c("2015-12-24", "2015-12-31&qu

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-13 Thread David Winsemius
> On Jan 13, 2017, at 3:20 AM, Janko Thyson wrote: > > Hi David, > > thanks for replying and sorry about the HTML/non-plain-text email (I > forgot to change that, shouldn't have happened). > > Might just be me, but reading "The documentation for R datetime format > parameters ?strptime says %V

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-13 Thread Janko Thyson
Hi David, thanks for replying and sorry about the HTML/non-plain-text email (I forgot to change that, shouldn't have happened). Might just be me, but reading "The documentation for R datetime format parameters ?strptime says %V is ignored on input." in the documentation doesn't really tell me all

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-12 Thread Nordlund, Dan (DSHS/RDA)
See comments inline. > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Bob Rudis > Sent: Thursday, January 12, 2017 12:41 PM > To: David Winsemius > Cc: r-help@r-project.org > Subject: Re: [R] Match ISO 8601 week-of-year number

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-12 Thread Bob Rudis
Aye, but this: some_dates <- as.POSIXct(c("2015-12-24", "2015-12-31", "2016-01-01", "2016-01-08")) (year_week <- format(some_dates, "%Y-%U")) ## [1] "2015-51" "2015-52" "2016-00" "2016-01" (year_week_day <- sprintf("%s-1", year_week)) ## [1] "2015-51-1" "2015-52-1" "2016-00-1" "2016-01

Re: [R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-12 Thread David Winsemius
> On Jan 12, 2017, at 8:14 AM, Janko Thyson wrote: > > Dear list, > > I'm experiencing problems with converting strings of the format > "-" (e.g. 2016-01, 2016-52) to proper POSIX dates which (I > think) I need in order to retrieve the month-of-the-year number. > > Simpler put: I'd like to

[R] Match ISO 8601 week-of-year numbers to month-of-year numbers on Windows with German locale

2017-01-12 Thread Janko Thyson
Dear list, I'm experiencing problems with converting strings of the format "-" (e.g. 2016-01, 2016-52) to proper POSIX dates which (I think) I need in order to retrieve the month-of-the-year number. Simpler put: I'd like to match week-of-the-year numbers to month-of-the-year numbers. Ideally,

Re: [R] Match Coordinates to NUTS 2 ID

2016-05-27 Thread Miluji Sb
Thank you for your reply. I am trying to use the over function - but having trouble. Asked at R-sig-geo. Thanks again! Sincerely, Milu On Fri, May 27, 2016 at 12:49 AM, MacQueen, Don wrote: > Perhaps the > over() > function in the sp package. > > (in which case, R-sig-geo might be a better p

Re: [R] Match Coordinates to NUTS 2 ID

2016-05-26 Thread MacQueen, Don
Perhaps the over() function in the sp package. (in which case, R-sig-geo might be a better place to ask). -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 5/26/16, 2:30 PM, "R-help on behalf of Miluji Sb" wrote: >Dea

[R] Match Coordinates to NUTS 2 ID

2016-05-26 Thread Miluji Sb
Dear all, I have downloaded the NUTS 2 level data from library(“rgdal”) library(“RColorBrewer”) library(“classInt”) #library(“SmarterPoland”) library(fields) # Download Administrative Level data from EuroStat temp <- tempfile(fileext = ".zip") download.file(" http://ec.europa.eu/eurostat/cache/G

Re: [R] R match - could be improved ?

2015-03-15 Thread J Robertson-Burns
I believe that you are in Circle 1 of The R Inferno. http://www.burns-stat.com/documents/books/the-r-inferno/ Pat On 15/03/2015 11:04, Jeremy Clark wrote: ​Dear All, The following gives a very unpleasant experience with apparently random NAs - probably it's my bad formatting of the coding - b

Re: [R] R match - could be improved ?

2015-03-15 Thread Michael Dewey
Dear Jeremy The NAs do not seem random to me as the gaps between successive NAs are either 3, 8 or 11. Have you considered the possibility that the finite precision of real numbers in computers may be the issue here? On 15/03/2015 11:04, Jeremy Clark wrote: ​Dear All, The following gives

Re: [R] R match - could be improved ?

2015-03-15 Thread Jeff Newmiller
This list is a plain text list. Posting in HTML frequently leads to corrupted code on the receiving end. Be sure to read the Posting Guide. In no programming language is it a good idea to assume equality with floating point values. See FAQ 7.31. In cases like this use integers to create sequence

[R] R match - could be improved ?

2015-03-15 Thread Jeremy Clark
​Dear All, The following gives a very unpleasant experience with apparently random NAs - probably it's my bad formatting of the coding - but the effect is unexpected and if undetected can lead to considerable problems: myvector1 = NULL myvector3 = NULL myvector4 = NULL myvector5 = NULL myve

Re: [R] Match beginning and end of string (grepl)

2014-09-02 Thread John McKown
On Tue, Sep 2, 2014 at 7:12 AM, Johannes Radinger wrote: > Hi, > > I'd like to match the beginning and the end of a string. E.g. I want to > extract all strings from a vector that beginn with "12" and end with > "Apples": > > a <- "2 green Apples" > b <- "12 green Apples" > c <- "12 Apples and 2 g

[R] Match beginning and end of string (grepl)

2014-09-02 Thread Johannes Radinger
Hi, I'd like to match the beginning and the end of a string. E.g. I want to extract all strings from a vector that beginn with "12" and end with "Apples": a <- "2 green Apples" b <- "12 green Apples" c <- "12 Apples and 2 green Bananas" d <- "12 yellow Bananas" fruitlist <- c(a,b,c,d) # This is

Re: [R] match from a data.frame in dependence of an ID

2014-03-29 Thread arun
Hi, Try: #dat is the dataset: library(plyr) dcast(dat,ID~Group,value.var="value",fill="") #or dcast(dat,ID~Group,value.var="value",fill=0) A.K. On Friday, March 28, 2014 4:54 AM, Mat wrote: Hello togehter, i have a litte problem. I have an output data.frame which look like this one:     ID   

Re: [R] match from a data.frame in dependence of an ID

2014-03-28 Thread Rui Barradas
Hello, Maybe there are other ways but the following works. tst2 <- matrix(nrow = dim(test)[1], ncol = dim(test)[2]) tst2[] <- test tst2 <- cbind(dimnames(test)[[1]], tst2) colnames(tst2) <- c("ID", dimnames(test)[[2]]) tst2 <- as.data.frame(tst2) tst2 Hope this helps, Rui Barradas Em 28-03-

Re: [R] match from a data.frame in dependence of an ID

2014-03-28 Thread Mat
Thanks first. Your solutions works nearly perfect, i only have one problem left. The result looks like perfect, my problem is now, that i want to convert the solution into a data.frame. If i try test<-xtabs(df2$Value~df2$ID + df2$Group) test df2$Group df2$ID 1 2 3 4 5 10 1

Re: [R] match from a data.frame in dependence of an ID

2014-03-28 Thread David Carlson
- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rui Barradas Sent: Friday, March 28, 2014 10:43 AM To: Mat; r-help@r-project.

Re: [R] match from a data.frame in dependence of an ID

2014-03-28 Thread Lisa S
Try xtabs() >> df2 = data.frame(ID = c(10,10,10,10,10,11,11,12),Group = c(1,2,3,4,5,3,4,4),Value = c(10,20,30,40,50,60,70,80)) >> xtabs(df2$Value~df2$ID + df2$Group) I think this is exactly what you want. On Fri, Mar 28, 2014 at 4:51 PM, Mat wrote: > Hello togehter, > > i have a litte problem.

[R] match from a data.frame in dependence of an ID

2014-03-28 Thread Mat
Hello togehter, i have a litte problem. I have an output data.frame which look like this one: ID 1 10 2 11 3 12 Now I have another data.frame with more than one line for each ID: IDGroupValue 1 10110 2 10220 3 103

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread William Dunlap
l Dunlap TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of PIKAL Petr > Sent: Monday, February 03, 2014 6:03 AM > To: Witold E Wolski > Cc: r-help@r-project.org > Subject:

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread PIKAL Petr
osition of test vector. There are others but only the first is returned. Regards Petr > -Original Message- > From: Witold E Wolski [mailto:wewol...@gmail.com] > Sent: Monday, February 03, 2014 3:29 PM > To: PIKAL Petr > Cc: r-help@r-project.org > Subject: Re: [R] match - ret

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Witold E Wolski
64488 > language R > version.string R Under development (unstable) (2013-12-19 r64488) > nickname Unsuffered Consequences > > Regards > Petr > > >> -Original Message- >> From: Witold E Wolski [mailto:wewol...@gmail.com] >> Sent: Monday, F

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread PIKAL Petr
r64488) nickname Unsuffered Consequences Regards Petr > -Original Message- > From: Witold E Wolski [mailto:wewol...@gmail.com] > Sent: Monday, February 03, 2014 1:07 PM > To: PIKAL Petr > Cc: r-help@r-project.org > Subject: Re: [R] match - returns a vector of the positions

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Witold E Wolski
i >> Sent: Monday, February 03, 2014 11:19 AM >> To: r-help@r-project.org >> Subject: [R] match - returns a vector of the positions of (first) >> matches - looking for All positions. >> >> Looking for a build in function whi

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread PIKAL Petr
Hi which(table == match) or which(table %in% match) Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Witold E Wolski > Sent: Monday, February 03, 2014 11:19 AM > To: r-help@r-project.org >

Re: [R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Kehl Dániel
Tárgy: [R] match - returns a vector of the positions of (first) matches - looking for All positions. Looking for a build in function which returns a vector of the positions of _ALL_ matches. -- Witold Eryk Wolski __ R-help@r-project.org mailing list

[R] match - returns a vector of the positions of (first) matches - looking for All positions.

2014-02-03 Thread Witold E Wolski
Looking for a build in function which returns a vector of the positions of _ALL_ matches. -- Witold Eryk Wolski __ 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.o

Re: [R] match values in dependence of ID and Date

2013-10-17 Thread arun
Hi, Try: dat <- read.table(text=" ID    Name 1    Andy 2    John 3    Amy",sep="",header=TRUE,stringsAsFactors=FALSE) dat2 <- read.table(text=" ID  Date    Value 1    2013-10-01    10 1    2013-10-02    15 2    2013-10-01    7 2    2013-10-03    10 2    2013-10-04    15 3    2013-10-01   

Re: [R] match values in dependence of ID and Date

2013-10-17 Thread arun
Hi, I think based on your title, the output you provided is not clear. If it depends on Date, there should be four columns. library(reshape2) res1 <- dcast(merge(dat,dat2,by="ID"),ID+Name~Date,value.var="Value")  colnames(res1)[3:6] <- c("First", "Second", "Third", "Fourth")  rownames(res1) <- 1

[R] match values in dependence of ID and Date

2013-10-17 Thread Mat
hello togehter, i have a little problem, maybe you can help me. I have a data.frame like this one: IDName 1 Andy 2 John 3 Amy and a data.frame like this: ID DateValue 12013-10-0110 12013-10-0215 22013-10-017 22013-10-0310 22013-

Re: [R] match rows of R

2013-06-26 Thread arun
  0.312   1.076 identical(res,res2) #[1] TRUE A.K. - Original Message - From: arun To: Sachinthaka Abeywardana Cc: R help Sent: Wednesday, June 26, 2013 3:26 PM Subject: Re: [R] match rows of R Hi, Try:  roweqv<- function(m,v) which(!is.na(match(interaction(as.data.fr

Re: [R] match rows of R

2013-06-26 Thread arun
  12    4 #[3,]   10   12    4 #[4,]   10   12    4 #[5,]   10   12    4 #[6,]   10   12    4 v2<- c(20,5,4) roweqv(m1,v2) #integer(0) A.K. - Original Message - From: Sachinthaka Abeywardana To: "r-help@r-project.org" Cc: Sent: Wednesday, June 26, 2013 4:03 AM Subject: [R] m

Re: [R] match rows of R

2013-06-26 Thread Berend Hasselman
On 26-06-2013, at 10:30, Yuliya Matveyeva wrote: > I suggest using vectorization : > > find_row <- function(m,v) { which(!(abs(rowSums(m - rep(v, each = nrow(m))) > )) > 0) } > > The function matroweqv mentioned above would give any row with the first > element equal to the first element in ve

Re: [R] match rows of R

2013-06-26 Thread Yuliya Matveyeva
I suggest using vectorization : find_row <- function(m,v) { which(!(abs(rowSums(m - rep(v, each = nrow(m))) )) > 0) } The function matroweqv mentioned above would give any row with the first element equal to the first element in vector v. The function find_row matches each row of the matrix as a

Re: [R] match rows of R

2013-06-26 Thread Berend Hasselman
On 26-06-2013, at 10:03, Sachinthaka Abeywardana wrote: > Hi all, > > What would be an efficient way to match rows of a matrix to a vector? > > ex: > > m<-matrix(1:9, nrow=3) > > m [,1] [,2] [,3] > [1,]147 > [2,]258 > [3,]369 > >

[R] match rows of R

2013-06-26 Thread Sachinthaka Abeywardana
Hi all, What would be an efficient way to match rows of a matrix to a vector? ex: m<-matrix(1:9, nrow=3) m [,1] [,2] [,3] [1,]147 [2,]258 [3,]369 # which(m==c(2,5,8))# I want this to return 2 ##

Re: [R] match a task No. to a few person-IDs

2013-02-15 Thread Rui Barradas
Hello, Use ?merge. tasks <- read.table(text = " Task_No Team A49397 1 B49396 1 ", header = TRUE) ids <- read.table(text = " IDTeam A 5019 1 B 472 1 C 140 1 D 5013 1 ", header = TRUE) merge(tasks, ids, all.x = TRUE) Hope this

Re: [R] match a task No. to a few person-IDs

2013-02-15 Thread arun
97    1  472 #A   49397    1  140 #A   49397    1 5013 #B   49396    1 5019 #B   49396    1  472 #B   49396    1  140 #B   49396    1 5013 A.K. - Original Message - From: Mat To: r-help@r-project.org Cc: Sent: Friday, February 15, 2013 4:45 AM Subject: [R] match a task No. to a few

Re: [R] match a task No. to a few person-IDs

2013-02-15 Thread PIKAL Petr
Hi ?merge Regards Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Mat > Sent: Friday, February 15, 2013 10:45 AM > To: r-help@r-project.org > Subject: [R] match a task No. to a few person-IDs &

[R] match a task No. to a few person-IDs

2013-02-15 Thread Mat
hello together, i have a task No. in a data.frame Task_No Team A49397 1 B49396 1 and now i want to match my Person-IDs to each Task_No. My Person Ids look like this one: IDTeam A 5019 1 B 472 1 C 140 1 D 5013 1 Th

Re: [R] match in dependence of 2 columns

2013-02-14 Thread arun
NA #2  1  Mer    80 #3  1 Pold    NA #or join(dat1,dat2[,c("cu.nr.","name")],by=c("cu.nr.","name"),type="right") A.K. - Original Message - From: Mat To: r-help@r-project.org Cc: Sent: Thursday, February 14, 2013 2:03 AM Subject

Re: [R] match in dependence of 2 columns

2013-02-14 Thread Rui Barradas
Hello, You can do something like this: join(dat1, dat2[, c("cu.nr", "name", "value")], by=c("cu.nr.","name"),type="right") Hope this helps, Rui Barradas Em 14-02-2013 07:03, Mat escreveu: thank you, this code works: library(plyr) join(dat1,dat2,by=c("cu.nr.","name"),type="right") but my

Re: [R] match in dependence of 2 columns

2013-02-13 Thread Mat
thank you, this code works: library(plyr) join(dat1,dat2,by=c("cu.nr.","name"),type="right") but my dat2 frame has a lot of columns, which i don't want to match. How can i say, that only the column "value" should be match to dat1 ? Thank you. Mat -- View this message in context: http://r.

Re: [R] match in dependence of 2 columns

2013-02-13 Thread Rui Barradas
Hello, Try the following. data.frame1 <- read.table(text = " cu.nr. name value A 1 Evo 100 B 1 Mer 80 C 2 Ford50

Re: [R] match in dependence of 2 columns

2013-02-13 Thread John Kane
-project.org > Subject: [R] match in dependence of 2 columns > > Hello, > > i want to match a column of one data.frame to another, my problem is, > that i > only want to match the data, if 2 columns are equal. > > i have a example: > > data.frame1 >

[R] match in dependence of 2 columns

2013-02-13 Thread Mat
Hello, i want to match a column of one data.frame to another, my problem is, that i only want to match the data, if 2 columns are equal. i have a example: data.frame1 cu.nr. name value A 1 Evo 100 B

Re: [R] match a complete data.frame

2013-02-12 Thread David Winsemius
On Feb 12, 2013, at 5:10 AM, Mat wrote: > hello togehter, > > how can i match a complete data.frame to another one? > > I know i can match one column with that code: > > A<-match(data$PJ_ID,project$PROJ_ID) > data$Name<-proj$Name[A] How about: data <- data[ match(data$PJ_ID,project$PROJ_ID)

[R] match a complete data.frame

2013-02-12 Thread Mat
hello togehter, how can i match a complete data.frame to another one? I know i can match one column with that code: A<-match(data$PJ_ID,project$PROJ_ID) data$Name<-proj$Name[A] but how can i match the total data.frame from project to data? indivduel matching for each column is not very producti

Re: [R] match a complete data.frame

2013-02-12 Thread Mat
i found a way :-) data<-merge(data,project,by.x="PJ_ID",by.y="PROJ_ID",all.x=TRUE) perhaps this can help someone Mat -- View this message in context: http://r.789695.n4.nabble.com/match-a-complete-data-frame-tp4658250p4658252.html Sent from the R help mailing list archive at Nabble.com. ___

Re: [R] match and substitute two variables

2012-12-03 Thread arun
ot; A.K. - Original Message - From: irene To: r-help@r-project.org Cc: Sent: Monday, December 3, 2012 10:32 AM Subject: [R] match and substitute two variables Hello, I have two variables (of different length and from two different data frames): code<- c("101001",  "

Re: [R] match and substitute two variables

2012-12-03 Thread irene
It works perfectly, thank you! -- View this message in context: http://r.789695.n4.nabble.com/match-and-substitute-two-variables-tp4651893p4651906.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list http

Re: [R] match and substitute two variables

2012-12-03 Thread Rui Barradas
Hello, Try the following. for(nm in name){ code[grep(gsub("[ [:alpha:]]+", "", nm), code)] <- nm } code Hope this helps, Rui Barradas Em 03-12-2012 15:32, irene escreveu: Hello, I have two variables (of different length and from two different data frames): code<- c("101001", "1032", "1

[R] match and substitute two variables

2012-12-03 Thread irene
Hello, I have two variables (of different length and from two different data frames): code<- c("101001", "1032", "102", "101001", "102", "1032"); name<- c("101001 Alta", "102 Bassa", "1032 Media"); and I would like to substitute the first variable with the second variable according to their sh

Re: [R] match values from data.frame and vector

2012-04-15 Thread peter dalgaard
On Apr 15, 2012, at 09:36 , Omphalodes Verna wrote: > Dear R helpers! > > I have a vector 'x1' and data.frame 'df1'. Do you have any suggestion how to > get vector x2, which will be a result of matching values from vector 'x1' and > values from 'df1'? Please, see the example: > > x1 <- c(rep(

[R] match values from data.frame and vector

2012-04-15 Thread Omphalodes Verna
Dear R helpers! I have a vector 'x1' and data.frame 'df1'. Do you have any suggestion how to get vector x2, which will be a result of matching values from vector 'x1' and values from 'df1'? Please, see the example: x1 <- c(rep(1,3), rep(NA,2), rep(2,4)) df1 <- data.frame(c1 = c(1,2), c2 = c(5,6

Re: [R] match matrices of different lengths

2012-01-05 Thread Justin Haynes
see ?merge > merge(xx,aa,by.x='x',by.y='a') x y b 1 2.00112e+11 1.0 1.2 2 2.00112e+11 1.1 1.9 making the two matricies time series does not mean that R knows that the first column is a datetime. and depending on your desired result, that may not be important. hope that helps, Ju

[R] match matrices of different lengths

2012-01-05 Thread Thijs vanden Bergh
was trying to match different matrices of different lengths with in the first collumn date and time info (yearmonthdayhourminute). the routine needs to return NA´s where data of either of the matrices is non existent. have been trying the following: x <- c(200112030003, 200112030004, 200112

Re: [R] match first consecutive list of capitalized words in string

2011-11-11 Thread Richter-Dumke, Jonas
Thank you very much for your help. I'm using the second suggestion in my program and it works very well. Jonas -Original Message- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: Thu 11/10/2011 5:58 AM To: Richter-Dumke, Jonas Cc: r-help@r-project.org Subject: R

Re: [R] match first consecutive list of capitalized words in string

2011-11-09 Thread Gabor Grothendieck
On Tue, Nov 8, 2011 at 7:48 AM, Richter-Dumke, Jonas wrote: > Dear R-Helpers, > > this is my first post ever to a mailing list, so please feel free to point > out any missunderstandings on my side regarding the conventions of this > mailing list. > > My problem: > > Assuming the following charac

Re: [R] match first consecutive list of capitalized words in string

2011-11-09 Thread Peter Alspach
call your objects 'names' since that is a function in R. HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Richter-Dumke, Jonas > Sent: Wednesday, 9 November 2011 1:49 a.m. > To: r-help@r-p

[R] match first consecutive list of capitalized words in string

2011-11-08 Thread Richter-Dumke, Jonas
Dear R-Helpers, this is my first post ever to a mailing list, so please feel free to point out any missunderstandings on my side regarding the conventions of this mailing list. My problem: Assuming the following character vector is given: names <- c("filia Maria", "vidua Joh Dirck Kleve (oo 0

Re: [R] "match" and "which" give NA for some values, but not others

2011-07-27 Thread Rolf Turner
You are failing to take account of floating point arithmetic. This is FAQ 7.31. Really, it is advisable to check the FAQ before firing off a naive inquiry to the r-help list. cheers, Rolf Turner On 27/07/11 15:50, Heemun Kwok wrote: Hello list, I am having trouble with "match" an

Re: [R] "match" and "which" give NA for some values, but not others

2011-07-27 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of Heemun Kwok > Sent: Tuesday, July 26, 2011 8:50 PM > To: r-help@r-project.org > Subject: [R] "match" and "which" give NA for some values,

[R] "match" and "which" give NA for some values, but not others

2011-07-26 Thread Heemun Kwok
Hello list, I am having trouble with "match" and "which" giving a NA result for some values, but not others. Here is a simple example: > aaa <- seq(0,1,by=0.05) > aaa [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 [16] 0.75 0.80 0.85 0.90 0.95 1.00 > match(0.5,

Re: [R] Match strings across two differently sized dataframes and copy corresponding row to dataframe

2011-06-30 Thread jim holtman
?merge On Thu, Jun 30, 2011 at 9:35 AM, Chris Beeley wrote: > Hello- > > Sorry, this is a bit of a noob question, but I can't seem to progress > it any further. > > I have two dataframes which contain a series of strings which exactly > match. The problem is one has more rows than the other (more

[R] Match strings across two differently sized dataframes and copy corresponding row to dataframe

2011-06-30 Thread Chris Beeley
Hello- Sorry, this is a bit of a noob question, but I can't seem to progress it any further. I have two dataframes which contain a series of strings which exactly match. The problem is one has more rows than the other (more cases have been added) and they have been sorted so that they are not in

Re: [R] Match numeric vector against rows in a matrix?

2011-01-11 Thread Kevin Ummel
Hi Petr, Sorry for the delay. I ended up implementing a simple and fast but not-universal or elegant solution, since it turned out that I only needed to test a rather small subset of combinations for my purposes. Nevertheless, I did go back and try the solutions posted. Bill's 'binary expansio

Re: [R] Match numeric vector against rows in a matrix?

2011-01-07 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Petr Savicky > Sent: Friday, January 07, 2011 2:11 AM > To: r-help@r-project.org > Subject: Re: [R] Match numeric vector against rows in a matrix? > > On

Re: [R] Match numeric vector against rows in a matrix?

2011-01-07 Thread Henrique Dallazuanna
Try this: which(colSums(t(combs) == x) == ncol(combs)) On Wed, Jan 5, 2011 at 5:16 PM, Kevin Ummel wrote: > Two posts in one day is not a good day...and this question seems like it > should have an obvious answer: > > I have a matrix where rows are unique combinations of 1's and 0's: > > > com

Re: [R] Match numeric vector against rows in a matrix?

2011-01-07 Thread Petr Savicky
On Wed, Jan 05, 2011 at 07:16:47PM +, Kevin Ummel wrote: > Two posts in one day is not a good day...and this question seems like it > should have an obvious answer: > > I have a matrix where rows are unique combinations of 1's and 0's: > > > combs=as.matrix(expand.grid(c(0,1),c(0,1))) > > co

Re: [R] Match numeric vector against rows in a matrix?

2011-01-05 Thread David Winsemius
On Jan 5, 2011, at 2:16 PM, Kevin Ummel wrote: Two posts in one day is not a good day...and this question seems like it should have an obvious answer: I have a matrix where rows are unique combinations of 1's and 0's: combs=as.matrix(expand.grid(c(0,1),c(0,1))) combs Var1 Var2 [1,]

[R] Match numeric vector against rows in a matrix?

2011-01-05 Thread Kevin Ummel
Two posts in one day is not a good day...and this question seems like it should have an obvious answer: I have a matrix where rows are unique combinations of 1's and 0's: > combs=as.matrix(expand.grid(c(0,1),c(0,1))) > combs Var1 Var2 [1,]00 [2,]10 [3,]01 [4,]1

Re: [R] Match() on raw objects ?

2010-07-28 Thread bruno Piguet
On Tue, 27 Jul 2010, Prof Brian Ripley wrote : > > Note that raw values in R are really intended to be passed around and not > manipulated: if you do much of the latter, coercing to integer, say, is > likely to be much more efficient. > > Indeed : I tried a minimal benchmark : a <- charToRaw(pas

Re: [R] Match() on raw objects ?

2010-07-27 Thread bruno Piguet
on 2010/7/27, Prof Brian Ripley wrote : > >OK. Had I tried "02", it would have worked, but only by chance. >> > > No, not 'by chance': that is what the help page for match() tells you > happens. Well, i mean that *I* would have typed "02" by chance. I read, but didn't fully understand the

Re: [R] Match() on raw objects ?

2010-07-27 Thread Prof Brian Ripley
On Tue, 27 Jul 2010, bruno Piguet wrote: Dear Prof Ripley, You wrote : You failed to supply a raw value to match, and if you do it works: match(as.raw(2), a) [1] 9 for the ninth value is *not* '2, indeed': it is as.raw(2). Thanks for the clarification.

Re: [R] Match() on raw objects ?

2010-07-27 Thread bruno Piguet
Dear Prof Ripley, You wrote : > You failed to supply a raw value to match, and if you do it works: > > match(as.raw(2), a) >> > [1] 9 > > for the ninth value is *not* '2, indeed': it is as.raw(2). > Thanks for the clarification. I think you are confusing R objects with their printed representa

Re: [R] Match() on raw objects ?

2010-07-27 Thread Prof Brian Ripley
You failed to supply a raw value to match, and if you do it works: match(as.raw(2), a) [1] 9 for the ninth value is *not* '2, indeed': it is as.raw(2). I think you are confusing R objects with their printed representation. (In this case values are coerced to strings, and a[9] is thus coerced

[R] Match() on raw objects ?

2010-07-27 Thread bruno Piguet
Dear all, Sorry to bother you with a question that must be a FAQ, but I'm not clever enough to have Google give me the answer. I want to filter out some bytes that I read in a file, before applying rawToChar (to prevent null character problems) So, I tried things like match("", my_raw_t

Re: [R] Match 2 vectors

2010-05-28 Thread Kang Min
That's what I wanted, thanks!! On May 28, 5:13 pm, Dennis Murphy wrote: > Hi: > > On Thu, May 27, 2010 at 10:26 PM, Kang Min wrote: > > Hi, > > > I have 2 dataframes of unequal length, and I would like to match a > > factor to them so that both dataframes will have the same number of > > rows.

Re: [R] Match 2 vectors

2010-05-28 Thread Dennis Murphy
Hi: On Thu, May 27, 2010 at 10:26 PM, Kang Min wrote: > Hi, > > I have 2 dataframes of unequal length, and I would like to match a > factor to them so that both dataframes will have the same number of > rows. > > example: > # create the 2 dataframes with unequal length > data1 <- data.frame(lett

  1   2   >