Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
al Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of S Ellison > Sent: Friday, May 26, 2017 8:28 AM > To: A M Lavezzi ; r-help > Subject: Re: [R] organizing data in a matrix avoiding loop > > > -Original Message- > > From: A M > Lavezzi

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Thanks a lot for your suggestion. I followed the suggestion of Sarah (the first on the thread) and solved my problem I will keep into account you suggestion anyway Mario On Fri, May 26, 2017 at 3:28 PM, S Ellison wrote: > > -Original Message- > > From: A M > Lavezzi >

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Hi Duncan thanks a lot for your suggestion. I followed the suggestion of Sarah (the first on the thread) and solved my problem I will keep into account you suggestion anyway Mario On Fri, May 26, 2017 at 2:20 PM, Duncan Murdoch wrote: > On 26/05/2017 7:46 AM, A M Lavezzi wrote: > >

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
kage help? > > dfa<- data.frame(iso_o = letters[c(1, 1:4)], iso_d = letters[6:10], year = > c(1985, 1985, 1986, 1987, 1988), flow = c(1,2,3,4, NA)) > reshape2::acast(dfa, iso_o ~ iso_d, fun.aggregate = sum, value.var = > "flow") > > HTH > Ulrik > > On Fri,

Re: [R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
n't take forever as a loop, > with only 215 entries. > > I find crosstab() from the ecodist package helpful. The current version is > on GitHub, but not yet CRAN (soon!). > > Sarah > > On Fri, May 26, 2017 at 7:47 AM A M Lavezzi > wrote: > >> Dear R-User

[R] organizing data in a matrix avoiding loop

2017-05-26 Thread A M Lavezzi
Dear R-Users I have data on bilateral trade flows among countries in the following form: > head(dataTrade) iso_o iso_d year FLOW 1 ABW AFG 1985 NA 2 ABW AFG 1986 NA 3 ABW AFG 1987 NA 4 ABW AFG 1988 NA 5 ABW AFG 1989 NA 6 ABW AFG 1990 NA where: iso_o: co

Re: [R] building a spatial matrix

2016-05-16 Thread A M Lavezzi
id_cell$f_cell & f_cell_neigh %in% > id_cell$f_cell) > result.m <- matrix(NA, nrow=nrow(id_cell), ncol=nrow(id_cell)) > result.m[cbind(factor(result$f_cell), factor(result$f_cell_neigh))] <- > result$distance > }) > > user system elapsed > 0.361 0.0

Re: [R] building a spatial matrix

2016-05-13 Thread A M Lavezzi
to "result" with the id of the firms. On Fri, May 13, 2016 at 3:26 PM, A M Lavezzi wrote: > > Hello Sarah > thanks a lot for your advice. > > I followed your suggestions unitl the creation of "result" > > The allocation of the values of result$distance t

Re: [R] building a spatial matrix

2016-05-13 Thread A M Lavezzi
neigh=seq_len(100)) > censDist$distance <- runif(nrow(censDist)) > > # assemble the non-symmetric distance matrix > result <- subset(censDist, fcell %in% idcell$fcell & cellneigh %in% > idcell$fcell) > result.m <- matrix(NA, nrow=nrow(idcell), ncol=nrow(idcell)) > res

[R] building a spatial matrix

2016-05-12 Thread A M Lavezzi
Hello, I have a sample of 1327 locations, each one idetified by an id and a numerical code. I need to build a spatial matrix, say, M, i.e. a 1327x1327 matrix collecting distances among the locations. M(i,i) should be 0, M(i,j) should contain the distance among location i and j I shoud use data

Re: [R] matching similar character strings

2013-07-09 Thread A M Lavezzi
ot;,"0","1","1","0"), SECTION = c(1288, 1261, 1287, 1264, 1287, 1262,1500,1505,1510,1520,1530,1610,1615)), .Names = c("CODICE","STRADA", "AREADICIRCOLAZIONE", "NUMBER1", "BARRATO1", "NUMBER2","BA

Re: [R] matching similar character strings

2013-07-06 Thread A M Lavezzi
;,F1_ex[,2]))),word,c(1,3,4,2)),paste,collapse=" > ") > vec2<- as.numeric(gsub("\\D+","",F1_ex[,2])) > F1_ex[,1]<-F2_ex[sapply(vec2,function(x) which((x>F2_ex[,4] & x< F2_ex[,6]) > & paste(F2_ex[,2],F2_ex[,3])%in%vec1)),"SECTION"

Re: [R] matching similar character strings

2013-07-02 Thread A M Lavezzi
the > name is slightly different, element A15 should be added to row 1) of F1, > producing an output such as: > > 1) Street | J.F. Kennedy | 30 | A15 > > > hope this clarifies the issue. > > thanks a lot! Mario > > > > Il 21/06/2013 15:29, arun ha scritto:

[R] matching similar character strings

2013-06-21 Thread A M Lavezzi
Hello everybody I have this problem: I need to match an addresses database F1 with the information contained in a toponymic database F2. The format of F1 is given by three columns and 800 rows, with the columns being: A1. Street/Road/Avenue A2. Name A3. Number Consider for instance Avenue J. Ke

Re: [R] loading data frames and rbind them

2013-03-13 Thread A M Lavezzi
ou should be able to make > > the modifications. > > > > HTH, > > Ivan > > > > -- > > Ivan CALANDRA > > Université de Bourgogne > > UMR CNRS/uB 6282 Biogéosciences > > 6 Boulevard Gabriel > > 21000 Dijon, FRANCE > > +33(0)3.80.39.63.06

[R] loading data frames and rbind them

2013-03-12 Thread A M Lavezzi
Hello everybody I have the following problem. I have to load a number of xls files from different folders (each xls file has the same number of columns, and different numbers of rows). Each xls file is named with a number, i.e. 12345.xls and is contained in a folder with same name, say 12345) Onc

Re: [R] selecting elements in vector

2011-01-14 Thread A M Lavezzi
it works! thank you so much Mario On Fri, Jan 14, 2011 at 1:29 PM, Henrique Dallazuanna wrote: > Try this: > > !list %in% c("aa", "bb") > > On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote: > >> Hi everybody, >> >> I have the

[R] selecting elements in vector

2011-01-14 Thread A M Lavezzi
Hi everybody, I have the following problem. I have a vector containing character elements, such as: list = c("aa","bb","cc","dd","ee") I want to create an index which identifies the elements that are different from, e.g. "aa" and "bb". When I do the following: jj = list!="aa" & list!="bb" > j

[R] evaluating partitions in CLUE

2009-05-20 Thread A M Lavezzi
Hello, I'm starting to use CLUE to compare clusterings. I have some cluster structures obtained outside R, which are simlply vectors of lenght N (N: number of objects), which contain a number indicating the cluster to which each object belongs. I report below a portion of one of these: --

Re: [R] counting strings of identical values in a matrix

2007-11-16 Thread A M Lavezzi
[1:11] 2 2 2 2 3 3 5 4 2 1 ... > > values : int [1:11] 3 1 3 1 3 1 3 1 3 1 ... > > > > > table(res$lengths[res$values == 1]) > > > > 1 2 3 4 > > 1 2 1 1 > > > > > > HTH, > > > > Marc > > > > > > > > On Thu,

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread A M Lavezzi
ncoding > lengths: int [1:11] 2 2 2 2 3 3 5 4 2 1 ... > values : int [1:11] 3 1 3 1 3 1 3 1 3 1 ... > > > table(res$lengths[res$values == 1]) > >1 2 3 4 >1 2 1 1 > > >HTH, > >Marc > > >On Thu, 2007-11-15 at 17:18 +0100, A M Lavezzi wrote: > > Dea

Re: [R] counting strings of identical values in a matrix

2007-11-15 Thread A M Lavezzi
ask how to do this? Thanks again Mario At 16.48 15/11/2007, you wrote: >On Thu, 2007-11-15 at 15:51 +0100, A M Lavezzi wrote: > > Hello > > > > I have this problem. I have a large matrix of this sort: > > > > > prova > > [,1] [,2] [,3] [,4] >

[R] counting strings of identical values in a matrix

2007-11-15 Thread A M Lavezzi
Hello I have this problem. I have a large matrix of this sort: > prova [,1] [,2] [,3] [,4] [1,]3333 [2,]3331 [3,]1333 [4,]1113 [5,]3113 [6,]3113 [7,]1313 [8,]1333