Re: [R] Nodes edges with similarity matrix
Hello, sorry that I interfer, but I tried to do this The SymTest matrix: A B C D E F G A 0.3 0.1 0.5 0.7 0.2 0.8 0.1 B 0.1 0.5 0.4 0.6 0.7 0.3 0.7 C 0.5 0.4 0.3 0.5 0.1 0.1 0.5 D 0.7 0.6 0.5 0.4 0.3 0.5 0.7 E 0.2 0.7 0.1 0.3 0.5 0.2 0.1 F 0.8 0.3 0.1 0.5 0.2 0.3 0.5 G 0.1 0.7 0.5 0.7 0.1 0.5 0.1 g A graphAM graph with undirected edges Number of Nodes = 7 Number of Edges = 28 g - new(graphAM, adjMat=SymTest, values=list(weight=0)) plot(g) Fehler in as.vector(x, double) : kann nicht nach Vektor umwandeln (Error in as.vector(x, double) : can not convert to vector) what goes wrong? Thanks in advance Birgit Am 29.08.2007 um 07:19 schrieb Gabor Grothendieck: Try this: # test data mat - structure(c(1, 0.325141612, 0.002109751, 0.250153137, 0.0223676, 1, 0.342654, 0.1987485, 0.9723831, 0.9644216, 1, 0.7391222, 0.394331, 0.5460461, 0.7080224, 1), .Dim = c(4L, 4L), .Dimnames = list( c(a, b, c, d), c(a, b, c, d))) library(sna) # draw edges according to value gplot(mat, edge.lwd = mat, label = rownames(mat)) # thresholding at 0.5 gplot(mat .5, label = rownames(mat)) On 8/28/07, H. Paul Benton [EMAIL PROTECTED] wrote: Hello, I apologise if someone has already answered this but I searched and googled but didn't find anything. I have a matrix which gives me the similarity of each item to each other. I would like to turn this matrix into something like what they have in the graph package with the nodes and edges. http://cran.r-project.org/doc/packages/graph.pdf . However I cannot find a method to convert my matrix to an object that graph can use. my similarity matrix looks like: sim[1:4,] a b c d [a] 1.0 0.0223676 0.9723831 0.3943310 [b] 0.325141612 1.000 0.9644216 0.5460461 [c] 0.002109751 0.3426540 1.000 0.7080224 [d] 0.250153137 0.1987485 0.7391222 1.000 please don't get caught up with the numbers I simple made this to show. I have not produce the code yet to make my similitary matrix. Does anyone know a method to do this or do I have to write something. :( If I do any starter code :D jj. If I've read something wrong or misunderstood my apologies. cheers, Paul -- Research Technician Mass Spectrometry o The / o Scripps \ o Research / o Institute __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Sequential Rank Test
I looked for the same topic today and found ?wilcox.test in the stats package. B Am 27.08.2007 um 17:33 schrieb Bernardo Rangel Tura: Hi R-Masters I need use a sequential approach in serie of cases, but may data is not normal. If data is normal distribution is very easy create analysis using likelihood ratio like of Wald test. But in my case I need use a non-parametric test (Mann-Whitney). I was use: RSiteSearch(sequential rank test) but not solve my problem. Do you know routine or package implement sequential rank test in R? Thanks in advance -- Bernardo Rangel Tura, M.D,Ph.D National Institute of Cardiology Brazil __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] ordered factors in data.frame
Thanks a lot Greg for your help. This works fine. Normally I use a vector to set the classes for the variables: Classe-cclasses - c(rep(factor, 14), rep(numeric, 4)) Table1-read.table(Name, sep = ;, colClasses = Classe) How can I implement to set colClasses as ordererd factor here. Following works not: Classe-cclasses - c(rep(factor, 61), rep(numeric, 14), rep (odered, 10)) Thanks in advance Birgit Am 23.08.2007 um 21:21 schrieb Greg Snow: The attach function only attachs a copy of the data (changes to the data don't show up in the attached copy). Also you need to tell R what to do with the result of as.ordered (where to save it). Try something like: table$V3 - as.ordered(table$V3) Or table - transform(table, V3=as.ordered(V3) ) Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke Sent: Thursday, August 23, 2007 11:28 AM To: R Hilfe Subject: [R] ordered factors in data.frame Hello I need a tiny peace of help. (PPC Mac Os X 10.4.10; R 2.5.1) I have a data.frame with numeric and factor variables. I would like to convert same of the factors to ordered factors. I tried with: attach (table) as.ordered (V3) but this gives me only the V3 Vector as ordred back but in the data.frame (str(Table)) it is still not ordered. How can I do that? Thanks for your help. I am still a beginner. Greetings Birgit Now I would like to Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] ordered factors in data.frame
Hello I need a tiny peace of help. (PPC Mac Os X 10.4.10; R 2.5.1) I have a data.frame with numeric and factor variables. I would like to convert same of the factors to ordered factors. I tried with: attach (table) as.ordered (V3) but this gives me only the V3 Vector as ordred back but in the data.frame (str(Table)) it is still not ordered. How can I do that? Thanks for your help. I am still a beginner. Greetings Birgit Now I would like to Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] plot3d labels
19.07.2007 um 18:48 schrieb jim holtman: The documentation has: text3d(x, y = NULL, z = NULL, texts, adj = 0.5, justify, ...) Do this do it for you? On 7/19/07, Birgit Lemcke [EMAIL PROTECTED] wrote: Hello R users, I am a newby using R 2.5.0 on a Apple Power Book G4 with Mac OS X 10.4.10. Sorry that I ask again such stupid questions, but I haven´t found how to label the points created with plot3d (rgl). Hope somebody can help me. Thanks in advance. Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] plot3d labels
Thanks a lot for this really time saving method compared to mine. Greetings Birgit Am 20.07.2007 um 11:53 schrieb Duncan Murdoch: On 20/07/2007 5:23 AM, Birgit Lemcke wrote: Hello Jim, thanks for your answer but I still have problems with the labels. Perhaps you can help me a second time. I have the output of cmdscale and it looks like this: [,1] [,2] [,3] Anth_cap -0.011833788 -0.1091355289 -0.0222467839 Anth_crin -0.008178993 -0.0219545815 -0.0076695878 Anth_eck 0.026900827 -0.0422055677 -0.1340542844 Anth_gram -0.010860990 0.0080112322 0.0201743866. In the next step I created 3 vectors out of the three columns PCoA1-PCoA[,1] PCoA2-PCoA[,2] PCoA3-PCoA[,3] After that I plotted the 3 vectors plot3d(PCoA1,PCoA2,PCoA3, type=p, col=rainbow(1000),size=5) There's no need to extract the 3 columns: you could just use plot3d(PCoA, type=p, col=rainbow(1000),size=5) with the data above. and now I try to handle this text3d function and label the points in the graphic with the names in the first column. But I am a beginner and don´t know the syntax for this in the text3d. I tried to make vectors out of every row like this: Anth_cap- PCoA[1,] Anth_crin- PCoA[2,] Anth_eck- PCoA[3,] Anth_gram- PCoA[4,] Anth_insi- PCoA[5,] Anth_laxi- PCoA[6,]. and than tried to implement this in the text3d: text3d( c(Anth_cap, Anth_crin, I think all you need is text3d(PCoA, text=Nam) but you might want to set the adj argument if you want the labels offset from the points, and you might want type=n in the original plot3d call if you don't want the points to interfere with the labels. Duncan Murdoch Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] write.table linebreaks
Hello R users, I am a newby using R 2.5.0 on a Apple Power Book G4 with Mac OS X 10.4.10. when I use the write.table function, I always get the output in Unix linebreaks that I have to change to McIntosh linebreaks to be able to Import the data in Excel 2004 for Mac. Is there a possibility to do this automatically in R and respectively in the write.table function? Thanks in advance. Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] plot3d labels
Hello R users, I am a newby using R 2.5.0 on a Apple Power Book G4 with Mac OS X 10.4.10. Sorry that I ask again such stupid questions, but I haven´t found how to label the points created with plot3d (rgl). Hope somebody can help me. Thanks in advance. Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] 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 11 0 0 0 1 1 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 21 1 0 0 1 1 0 0 1 0 1 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 1 0 0 1 0 0 1 1 0 0 31 1 0 0 1 1 1 1 0 0 1 0 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 40 1 0 0 1 1 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 50 1 0 0 1 1 0 0 1 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 61 1 0 0 1 1 0 1 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 As i know I did the same 2 weeks ago and it worked properly. Here are my codes: Table1-read.table(Alle_DatenFemBeschr4a.csv, sep = ;) Table0-read.table(Alle_DatenMalBeschr4a.csv, sep = ;) Dist.Gower- distance(Table1 ,Table0 ,method =mixed, weights = c (0.333, 0.333, 0.333, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.250, 0.250, 0.250, 0.250, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.333, 0.333, 0.333, 0.200, 0.200, 0.200, 0.200, 0.200, 0.111, 0.111, 0.111, 0.111, 0.111, 0.111, 0.111, 0.111, 0.111, 0.200, 0.200, 0.200, 0.200, 0.200, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.1428571, 0.200, 0.200, 0.200, 0.200, 0.200, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500, 0.500)) This produces the following massage: Fehler in distance(Table1, Table0, method = mixed, weights = c (0.333, : Different columns (species) are coded as factors in 'x' and 'y' I thought that the data format in the tables were not congruent in the same columns but I checked this and it is not the case. I also tried to convert the data into a matrix (as.matrix) or a dataframe (as.data.frame) but the result was the same. Perhaps it is only a small syntax error but I am R beginner. I hope somebody wil help me and thank you all in advance. Kind regards Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Hello Jim, thanks for your answer. At the moment I am using this code: Range0-sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= and it works really fine. The code you sent me is also fine but how can I implement, that missing values are TRUE? Thanks a lot for your help Birgit Am 28.06.2007 um 13:01 schrieb Jim Lemon: Birgit Lemcke wrote: Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Hi Birgit, This may be what you want: for(i in 1:85) print(do.call(range,list(as.name(paste(V,i,sep=) Jim Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] Repeat if
Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Thanks in advance Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Thanks that was really a quick answer. It works but I get this warning message anyway: 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None not- lacking argument for min; give Inf back) 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück what does this mean? Greeting and thanks for your help! Birgit Am 28.06.2007 um 12:05 schrieb Jacques VESLOT: sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21 84 Birgit Lemcke a écrit : Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Thanks in advance Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] - --- __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Thats not the case. I have two vectosr with a lot of NAs, but not only NAs. But nevertheless as i saw the results are accurate. Birgit Am 28.06.2007 um 15:17 schrieb Jacques VESLOT: you may have a vector with only NA values in it... max(c(NA,NA), na.rm=T) [1] -Inf Warning message: aucun argument pour max ; -Inf est renvoyé Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21 84 Birgit Lemcke a écrit : Thanks that was really a quick answer. It works but I get this warning message anyway: 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None not-lacking argument for min; give Inf back) 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück what does this mean? Greeting and thanks for your help! Birgit Am 28.06.2007 um 12:05 schrieb Jacques VESLOT: sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21 84 Birgit Lemcke a écrit : Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Thanks in advance Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [[alternative HTML version deleted]] --- - __ R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Hello John, I tried this code. But I got only the ranges of V1 and V2 what is easily understandable. Do I have to write in all 85 vectors in the first line? V-list(a=c(V1), b=c(V2)) for ( i in 1:85 ) { # 2 vectors (replace with 85 ...) + print(range (V[i], na.rm = TRUE)) + } sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= But thanks anyway. Greetings Birgit Am 28.06.2007 um 12:23 schrieb john seers ((IFR)): Hi I think a for loop would be more what you want. Something along the lines of: V-list(a=c(1,2,3), b=c(2,3,4)) # list of 2 vectors for ( i in 1:2 ) { # 2 vectors (replace with 85 ...) print(range (V[i], na.rm = TRUE)) } Regards JS --- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Birgit Lemcke Sent: 28 June 2007 10:48 To: R Hilfe Subject: [R] Repeat if Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Thanks Christophe, I received already an answer with a similar suggestion. But thanks for your answer. Birgit Am 28.06.2007 um 12:34 schrieb Christophe Pallier: Your V1 to V85 are probably coming from a data.frame, aren't they? If yes, and if this data.frame is named 'a', you can use 'sapply (a,range)' Otherwise, see ?get (get(paste(V,1,sep=)) returns V1) Christophe On 6/28/07, Birgit Lemcke [EMAIL PROTECTED] wrote: Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Thanks in advance Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. -- Christophe Pallier (http://www.pallier.org) Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Hello Patrick, this does not work and gives following warning message: for(i in 1:85) range(get(paste(V, i, sep=)), na.rm=TRUE) Warning messages: 1: kein nicht-fehlendes Argument für min; gebe Inf zurück 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück This works but also with the warning message: Vranges - array(NA, c(85, 2)) for(i in 1:85) Vranges[i,] - range(get(paste(V, i, sep=)), na.rm=TRUE) Greetings Birgit Am 28.06.2007 um 12:27 schrieb Patrick Burns: In your code the 'range' call is only seen when i is 85. I think the following is what you want: for(i in 1:85) range(get(paste(V, i, sep=)), na.rm=TRUE) Except that nothing is done with the results of 'range'. More likely is: Vranges - array(NA, c(85, 2)) for(i in 1:85) Vranges[i,] - range(get(paste(V, i, sep=)), na.rm=TRUE) See S Poetry for details. Patrick Burns [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and A Guide for the Unwilling S User) Birgit Lemcke wrote: Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Thanks in advance Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] - --- __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Repeat if
Sorry Jacques and all the other helpful people! I made a mistake because I didn´t realize that I have a vector only containing NAs. That happened during standardization and i didn´t check this. I apologize for that. Greetings Birgit Am 28.06.2007 um 15:17 schrieb Jacques VESLOT: you may have a vector with only NA values in it... max(c(NA,NA), na.rm=T) [1] -Inf Warning message: aucun argument pour max ; -Inf est renvoyé Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21 84 Birgit Lemcke a écrit : Thanks that was really a quick answer. It works but I get this warning message anyway: 1: kein nicht-fehlendes Argument für min; gebe Inf zurück (None not-lacking argument for min; give Inf back) 2: kein nicht-fehlendes Argument für max; gebe -Inf zurück what does this mean? Greeting and thanks for your help! Birgit Am 28.06.2007 um 12:05 schrieb Jacques VESLOT: sapply(1:85, function(i) eval(parse(text=paste(range(V, i, , na.rm=T), sep= Jacques VESLOT INRA - Biostatistique Processus Spatiaux Site Agroparc 84914 Avignon Cedex 9, France Tel: +33 (0) 4 32 72 21 58 Fax: +33 (0) 4 32 72 21 84 Birgit Lemcke a écrit : Hello, (Power Book G4, Mac OS X, R 2.5.0) I would like to repeat the function range for 85 Vectors (V1-V85). I tried with this code: i-0 repeat { + i-i+1 + if (i85) next + range (Vi, na.rm = TRUE) + if (i==85) break + } I presume that the Vi is wrong, because in this syntax i is not known as a variable. But I don´t know how to say that it is a variable here. Would be nice if somebody could help me. Perhaps I´m thinking too complicated and there is an easier way to do this. Thanks in advance Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [[alternative HTML version deleted]] --- - __ R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Distance function
Hello Gavin, I am sorry that I haven´t read the posting guide properly. This signs ^ were not in my originally email and for sure not in my code. Thank you for your offering. I will send you the data. Greetings Birgit Am 21.06.2007 um 20:22 schrieb Gavin Simpson: On Thu, 2007-06-21 at 19:56 +0200, Birgit Lemcke wrote: Hello you all from the R Help mailing list! I am working on a PowerBook with Mac Os X and use R 2.5.0. I used the distance function from the analogue package to perform a similarity analysis using the Gowers Index and weighted Variables. My variables are bivariate data and measurements as well as interval data transformed into minimum and maximum variables. I used this Code: Dist.Gowa-distance(Table1a ,Table0a ,method =mixed, weights (weighting),R = NULL ) ^^^ Something is not right there () is this exactly what you typed? You should not send questions about contributed packages to the list --- as detailed in the posting guide. Without seeing Table1a and Table0a, it is hard to say why this is failing - I suspect something about the structure of the two data frames is throwing the function off. If you can, send me that data ***off-list*** and I will take a look for you, but as I'm teaching all day tomorrow, it won't happen till after the weekend now. HTH G weighting is a vector created by this code: (weighting- c (1/3,1/3,1/3,1/2,1/2,1/2,1/2,1/2,1/2,1/4,1/4,1/4,1/4,1/7,1/7,1/7,1/7, 1/7 , 1/7,1/7,1/3,1/3,1/3,1/5,1/5,1/5,1/5,1/5,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1 /9, 1/9,1/5,1/5,1/5,1/5,1/5,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1 /7, 1/7,1/7,1/5,1/5,1/5,1/5,1/5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ,1, 1,1)) It contains the weightings for the variables of the two data tables. My data tables look like this: Anth_cap18.0 NA NA 4.0 5.0 1 1 3.0 5.0 2.4 4.5 5 5 2 2 2 3 1 1 1 1 Anth_crin1 5.0 NA NA 3.5 11.0 1 1 3.0 10.0 2.0 4.5 3 4 2 2 3 3 1 1 2 3 Anth_eck17.0 NA NA 6.0 12.0 1 1 6.0 11.0 2.0 3.0 3 5 2 2 3 3 1 1 1 2 At the end of the analysis I get always this message: 1: $ operator is deprecated for atomic vectors, returning NULL in: object$na.action 2: $ operator is deprecated for atomic vectors, returning NULL in: object$weights Can anybody explain me what this means? Does anybody know if I have to standardize my measurements. As I understood this is included in Gowers Index. If not is there a function with different options of standardization more than rescaler from the reshape package provides? Thanks for your help in advance. Greetings Birgit Birgit Lemcke Institut fr Systematische Botanik Zollikerstrasse 107 CH-8008 Zrich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Dissimilarity
Hello Mark, thank you for your additional advices. I had already a short look at the vegan package but I think I have to look closer and also at the ade4 package. Unfortunately I am basically from Germany and my French is perhaps only a rudimental school french but anyway, I would like to have a look at this lecture notes, but I can not open the link you wrote me. Ah sorry now the link works. Greetings and thanks a lot. Birgit Hey Gavin, I found it funny that your institute is in the Gower Street. Am 20.06.2007 um 21:49 schrieb Mark Difford: Hi Birgit, Just to add to what Gavin has said. There are two other very powerful packages in R that handle this kind of thing: ade4 and vegan. Have a thorough look at both of them. You should be looking at Principal Coordinate Analysis (Classical Scaling) and Non Metric Multidimensional Scaling (NMDS)---with, as Gavin has said, your species as rows. At least the first of these methods goes hand-in-glove with cluster analysis. Given that you are based in Switzerland, and perhaps are Swiss, you probably therefore read and speak French as a second/third language. You may therefore find the ade4 package more useful, since its authors are French, and its principal authors, Prof. Daniel Chessel c., have made publicly available some exceptionally useful documentation on these methods on their ade4 website. These are mainly Prof. Chessel's lecture notes: http://pbil.univ-lyon1.fr/R/enseignement.html I hope that speeds you on your way. Regards, Mark. PS: Apropos of the Legendre Legendre text: It's well worth buying if you work in this area; one of its authors, Pierre Legendre, now collaborates with Jari Oksanen on some functions of the vegan package. Gavin Simpson wrote: On Wed, 2007-06-20 at 16:13 +0200, Birgit Lemcke wrote: Hello Stephen, I am happy that you help me. Thanks a million. It is a good feeling that you confirm my assumption that dsvdis is not able to deal with missing data, because it says me that I am not completely incapable. Okay now I have the problem what to do. I used this function cause there is an option to weight columns differently what I havent found in other functions. But now I dont understand why I have to transpose the species as columns? As I read in the help manual of dsvdis this function calculates dissimilarities between rows. I have to calculate the dissimilarities between species that are in rows by the use of morphological characters that are in columns. If you really what to measure the associations between species then leave them as you had them as the rows. But make sure you are choosing a dissimilarity coefficient that works well for species associations. There is a whole section in Legendre and Legendre 1998 Numerical Ecology 2nd English Edition Elsevier which may help here. HTH G Am I completely wrong with my thoughts? Birgit Am 20.06.2007 um 15:52 schrieb Stephen B. Cox: Hi Birgit - looks like you have a few issues here. Birgit Lemcke birgit.lemcke at systbot.uzh.ch writes: Hello you all! I am a completely new user of R and I have a problem to solve. I am using Mac OS X on a PowerBook. I have a table that looks like this: species X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 1Anth_cap1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 2 Anth_crin1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 3Anth_eck1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 4 Anth_gram1 1 0 0 1 0 1 0 0 1 NA NA NA NA 0 0 0 0 1 0 0 0 5 Anth_insi1 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 All columns are binary coded characters. The Import was done by this Test-read.table(TestRFemMalBivariat1.csv,header = TRUE, sep = ;) First - you need to transpose the matrix to have species as columns. You can do this with: d2 = data.frame(t(Test[,-1])) colnames(d2) = Test[,1] #now use d2 Now I try to perform a similarity analysis with the dsvdis function of the labdsv package with the sorensen-Index. My first question is if all zeros in my table are seen as missing values and if it islike that how can I change without turning zero into other numbers? no - the zeros are valid observations. the na's are missing data. DisTest-dsvdis(Test, index = sorensen) But I always get back this error message: Warnung in symbol.For(dsvdis) :'symbol.For' is not needed: please remove it Fehler in dsvdis(Test, index = sorensen) : NA/NaN/Inf in externem Funktionsaufruf (arg 1) Zustzlich: Warning message: NAs durch Umwandlung erzeugt Second - you have an issue with missing data. It looks like dsvdis does not like the NA's - so you must make a decision about what to do. Delete that species
[R] Warning message!!
Hello, I just received a warning message and I don´t understand what it means: 2007-06-21 13:37:17.623 R[201] -[NSTextStorage attributesAtIndex:effectiveRange:] called with out-of-bounds index. For apps linked on Tiger this will raise an exception. For earlier apps it will produce this one-time warning and continue with existing behavior (which is undefined). I am working on a PowerBook with Mac OSX and R 2.5.0. Regards Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Dissimilarity
Thanks Mark, but anyway I will try to read it in French first. Birgit Am 21.06.2007 um 10:14 schrieb Mark Difford: Hi Birgit, If French is a problem, then you will unfortunately (because you miss out on Chessel's marvellous insights) have to do with the terser, more formal stuff (publications), on the Links page of the ade4 site. Most of this is in English: http://pbil.univ-lyon1.fr/ADE-4/links.php?lang=eng ## Chessel's stuff http://pbil.univ-lyon1.fr/R/perso/pagechessel.html Hope that helps. PS: There is also a brief overview of the one-table methods provided by the ade4 package in an R Newsletter: http://cran.r-project.org/doc/Rnews/Rnews_2004-1.pdf Birgit Lemcke wrote: Hello Mark, thank you for your additional advices. I had already a short look at the vegan package but I think I have to look closer and also at the ade4 package. Unfortunately I am basically from Germany and my French is perhaps only a rudimental school french but anyway, I would like to have a look at this lecture notes, but I can not open the link you wrote me. Ah sorry now the link works. Greetings and thanks a lot. Birgit Hey Gavin, I found it funny that your institute is in the Gower Street. Am 20.06.2007 um 21:49 schrieb Mark Difford: Hi Birgit, Just to add to what Gavin has said. There are two other very powerful packages in R that handle this kind of thing: ade4 and vegan. Have a thorough look at both of them. You should be looking at Principal Coordinate Analysis (Classical Scaling) and Non Metric Multidimensional Scaling (NMDS)---with, as Gavin has said, your species as rows. At least the first of these methods goes hand-in-glove with cluster analysis. Given that you are based in Switzerland, and perhaps are Swiss, you probably therefore read and speak French as a second/third language. You may therefore find the ade4 package more useful, since its authors are French, and its principal authors, Prof. Daniel Chessel c., have made publicly available some exceptionally useful documentation on these methods on their ade4 website. These are mainly Prof. Chessel's lecture notes: http://pbil.univ-lyon1.fr/R/enseignement.html I hope that speeds you on your way. Regards, Mark. PS: Apropos of the Legendre Legendre text: It's well worth buying if you work in this area; one of its authors, Pierre Legendre, now collaborates with Jari Oksanen on some functions of the vegan package. Gavin Simpson wrote: On Wed, 2007-06-20 at 16:13 +0200, Birgit Lemcke wrote: Hello Stephen, I am happy that you help me. Thanks a million. It is a good feeling that you confirm my assumption that dsvdis is not able to deal with missing data, because it says me that I am not completely incapable. Okay now I have the problem what to do. I used this function cause there is an option to weight columns differently what I havent found in other functions. But now I dont understand why I have to transpose the species as columns? As I read in the help manual of dsvdis this function calculates dissimilarities between rows. I have to calculate the dissimilarities between species that are in rows by the use of morphological characters that are in columns. If you really what to measure the associations between species then leave them as you had them as the rows. But make sure you are choosing a dissimilarity coefficient that works well for species associations. There is a whole section in Legendre and Legendre 1998 Numerical Ecology 2nd English Edition Elsevier which may help here. HTH G Am I completely wrong with my thoughts? Birgit Am 20.06.2007 um 15:52 schrieb Stephen B. Cox: Hi Birgit - looks like you have a few issues here. Birgit Lemcke birgit.lemcke at systbot.uzh.ch writes: Hello you all! I am a completely new user of R and I have a problem to solve. I am using Mac OS X on a PowerBook. I have a table that looks like this: species X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 1Anth_cap1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 2 Anth_crin1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 3Anth_eck1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 4 Anth_gram1 1 0 0 1 0 1 0 0 1 NA NA NA NA 0 0 0 0 1 0 0 0 5 Anth_insi1 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 All columns are binary coded characters. The Import was done by this Test-read.table(TestRFemMalBivariat1.csv,header = TRUE, sep = ;) First - you need to transpose the matrix to have species as columns. You can do this with: d2 = data.frame(t(Test[,-1])) colnames(d2) = Test[,1] #now use d2 Now I try to perform a similarity analysis with the dsvdis function of the labdsv package
[R] Distance function
Hello you all from the R Help mailing list! I am working on a PowerBook with Mac Os X and use R 2.5.0. I used the distance function from the analogue package to perform a similarity analysis using the Gowers Index and weighted Variables. My variables are bivariate data and measurements as well as interval data transformed into minimum and maximum variables. I used this Code: Dist.Gowa-distance(Table1a ,Table0a ,method =mixed, weights (weighting),R = NULL ) weighting is a vector created by this code: (weighting- c (1/3,1/3,1/3,1/2,1/2,1/2,1/2,1/2,1/2,1/4,1/4,1/4,1/4,1/7,1/7,1/7,1/7,1/7 , 1/7,1/7,1/3,1/3,1/3,1/5,1/5,1/5,1/5,1/5,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9, 1/9,1/5,1/5,1/5,1/5,1/5,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7,1/7, 1/7,1/7,1/5,1/5,1/5,1/5,1/5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1)) It contains the weightings for the variables of the two data tables. My data tables look like this: Anth_cap18.0 NA NA 4.0 5.0 1 1 3.0 5.0 2.4 4.5 5 5 2 2 2 3 1 1 1 1 Anth_crin1 5.0 NA NA 3.5 11.0 1 1 3.0 10.0 2.0 4.5 3 4 2 2 3 3 1 1 2 3 Anth_eck17.0 NA NA 6.0 12.0 1 1 6.0 11.0 2.0 3.0 3 5 2 2 3 3 1 1 1 2 At the end of the analysis I get always this message: 1: $ operator is deprecated for atomic vectors, returning NULL in: object$na.action 2: $ operator is deprecated for atomic vectors, returning NULL in: object$weights Can anybody explain me what this means? Does anybody know if I have to standardize my measurements. As I understood this is included in Gowers Index. If not is there a function with different options of standardization more than rescaler from the reshape package provides? Thanks for your help in advance. Greetings Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] How to extract diagonals
Hello, I am using Mac OS X on a power book and R 2.5.0 I try to extract a diagonal from a dissimilarity matrix made with dsvdis, with this code: diag(DiTestRR) But I get this error message: Fehler in array(0, c(n, p)) : 'dim' spezifiziert ein zu großes Array english: Error in array(0, c(n, p)) : 'dim' specifies a too big array. Is there a limit to extract diagonals? I hope somebody will help me! Greetings Birgit Lemcke Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] How to extract diagonals
Hello Gavin and thanks for your answer. Your completely right I don´t need the diagonal that is the bisecting line of the angle. I need another diagonal of the (now) matrix. A1 A2 A3 A4 B1 B2 B3 B4 A1 A2 A3 A4 B1 X B2 X B3X B4 X I need for example the diagonal that compares A1 with B1. Do you have an idea how I can handle this? What is the effect of this code? all.equal(diags, diag(as.matrix(dis.bc))) Thanks a lot and sorry for my inability to solve my problems on my own. Am 20.06.2007 um 14:11 schrieb Gavin Simpson: On Wed, 2007-06-20 at 13:26 +0200, Birgit Lemcke wrote: Hello, I am using Mac OS X on a power book and R 2.5.0 I try to extract a diagonal from a dissimilarity matrix made with dsvdis, with this code: diag(DiTestRR) But I get this error message: Fehler in array(0, c(n, p)) : 'dim' spezifiziert ein zu groes Array english: Error in array(0, c(n, p)) : 'dim' specifies a too big array. Is there a limit to extract diagonals? The returned object is not a matrix, but an object of class dist which doesn't store the diagonals or the upper triangle of the dissimilarity matrix to save memory. You need to convert the dist object to a matrix first, then extract the diagonal. But, as this shows: require(labdsv) ?dsvdis data(bryceveg) ?dsvdis dis.bc - dsvdis(bryceveg,index=bray/curtis) Warning in symbol.For(dsvdis) : 'symbol.For' is not needed: please remove it diag(as.matrix(dis.bc)) This is meaningless as the diagonals are all zero, as they should be; this is the distance between a site and itself. I hope somebody will help me! So perhaps you could explain why you want the diagonal. It would be easier to just do: diags - rep(0, length = nrow(bryceveg)) That will be without the sample labels, but that is easily rectified names(diags) - rownames(bryceveg) all.equal(diags, diag(as.matrix(dis.bc))) [1] TRUE So you'll have to reformulate your question if this is not what you wanted. A word of warning, do not do diag(dis.bc)) on the above as it brought my Linux box to it's knees trying to do something silly - easily recoverable, but beware. HTH G Greetings Birgit Lemcke -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] Dissimilarity
Hello Stephen, I am happy that you help me. Thanks a million. It is a good feeling that you confirm my assumption that dsvdis is not able to deal with missing data, because it says me that I am not completely incapable. Okay now I have the problem what to do. I used this function ´cause there is an option to weight columns differently what I haven´t found in other functions. But now I don´t understand why I have to transpose the species as columns? As I read in the help manual of dsvdis this function calculates dissimilarities between rows. I have to calculate the dissimilarities between species that are in rows by the use of morphological characters that are in columns. Am I completely wrong with my thoughts? Birgit Am 20.06.2007 um 15:52 schrieb Stephen B. Cox: Hi Birgit - looks like you have a few issues here. Birgit Lemcke birgit.lemcke at systbot.uzh.ch writes: Hello you all! I am a completely new user of R and I have a problem to solve. I am using Mac OS X on a PowerBook. I have a table that looks like this: species X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 1Anth_cap1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 2 Anth_crin1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 3Anth_eck1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 4 Anth_gram1 1 0 0 1 0 1 0 0 1 NA NA NA NA 0 0 0 0 1 0 0 0 5 Anth_insi1 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 All columns are binary coded characters. The Import was done by this Test-read.table(TestRFemMalBivariat1.csv,header = TRUE, sep = ;) First - you need to transpose the matrix to have species as columns. You can do this with: d2 = data.frame(t(Test[,-1])) colnames(d2) = Test[,1] #now use d2 Now I try to perform a similarity analysis with the dsvdis function of the labdsv package with the sorensen-Index. My first question is if all zeros in my table are seen as missing values and if it islike that how can I change without turning zero into other numbers? no - the zeros are valid observations. the na's are missing data. DisTest-dsvdis(Test, index = sorensen) But I always get back this error message: Warnung in symbol.For(dsvdis) :'symbol.For' is not needed: please remove it Fehler in dsvdis(Test, index = sorensen) : NA/NaN/Inf in externem Funktionsaufruf (arg 1) Zusätzlich: Warning message: NAs durch Umwandlung erzeugt Second - you have an issue with missing data. It looks like dsvdis does not like the NA's - so you must make a decision about what to do. Delete that species, delete that site, or whatever... Finally - the warning over symbol.For is an issue with the labdsv library itself - nothing you are doing wrong. The results will still be valid - but the use of symbol.For is something that will eventually need to be changed in the labdsv library. hth, stephen Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
Re: [R] How to extract diagonals
Hello Gavin! I thank you so much that you help me here. Only to answer your questions there are 452 samples (species) in A and the same number in B. Unfortunately I will get the book from Legendre Legendre only in 2 days (small library) but I think for the moment I am busy to try and learn with the codes you gave me here. For me it seems that this will solve all the problems I have at the moment. Now it is my turn to learn about it. Once again: thanks Greetings Birgit Am 20.06.2007 um 18:02 schrieb Gavin Simpson: On Wed, 2007-06-20 at 15:09 +0200, Birgit Lemcke wrote: Hello Gavin and thanks for your answer. Your completely right I dont need the diagonal that is the bisecting line of the angle. I need another diagonal of the (now) matrix. A1 A2 A3 A4 B1 B2 B3 B4 A1 A2 A3 A4 B1 X B2 X B3X B4 X Not easily, especially without knowing how many samples are in A or B, although all that is really needed is some careful subsetting of the dist object and a minor amount of programming - unfortunately after close to two weeks intensive teaching my brain isn't up to doing that just now. One simple way to do this is to use the distance() function in my analogue package (on CRAN). distance() can calculate the dissimilarities between one group of samples and another. Here is a simple example using some dummy data, from ?distance: ## simple example using dummy data train - data.frame(matrix(abs(runif(200)), ncol = 10)) rownames(train) - LETTERS[1:20] colnames(train) - as.character(1:10) fossil - data.frame(matrix(abs(runif(100)), ncol = 10)) colnames(fossil) - as.character(1:10) rownames(fossil) - letters[1:10] ## calculate distances/dissimilarities between train and fossil ## samples test - distance(train, fossil) test is now a matrix, the diagonal elements of which are the values that you appear to want: diag(test) if I'm reading your diagram correctly. Note that for this, you need to be comparing row 1 from matrix A with row 1 from matrix B - if they are in some other order, then this won't work. distance() has a version of Gower's coefficient for mixed that allows you to specify weights. The function is just about clever enough to allow missing values if you use method = mixed in distance(). Be sure to read up about Gower's mixed coefficient in his 1971 paper (Gower, 1971, Biometrics 23; 623--637) and the use that weights and the range parameter Rj are put to, or see the relevant section in Legendre Legendre (1998). I need for example the diagonal that compares A1 with B1. Do you have an idea how I can handle this? What is the effect of this code? all.equal(diags, diag(as.matrix(dis.bc))) This was showing you that the diagonals of the dissimilarity matrix are just a vector of zeroes. all.equal tests equality of its arguments. Thanks a lot and sorry for my inability to solve my problems on my own. You're welcome. Using R is a learning experience. You only need to grovel and apologise if you have not done your homework before posting and not read the FAQ, the documentation or searched the archives, or followed the posting guide. Which is not the case here. HTH G Am 20.06.2007 um 14:11 schrieb Gavin Simpson: On Wed, 2007-06-20 at 13:26 +0200, Birgit Lemcke wrote: Hello, I am using Mac OS X on a power book and R 2.5.0 I try to extract a diagonal from a dissimilarity matrix made with dsvdis, with this code: diag(DiTestRR) But I get this error message: Fehler in array(0, c(n, p)) : 'dim' spezifiziert ein zu groes Array english: Error in array(0, c(n, p)) : 'dim' specifies a too big array. Is there a limit to extract diagonals? The returned object is not a matrix, but an object of class dist which doesn't store the diagonals or the upper triangle of the dissimilarity matrix to save memory. You need to convert the dist object to a matrix first, then extract the diagonal. But, as this shows: require(labdsv) ?dsvdis data(bryceveg) ?dsvdis dis.bc - dsvdis(bryceveg,index=bray/curtis) Warning in symbol.For(dsvdis) : 'symbol.For' is not needed: please remove it diag(as.matrix(dis.bc)) This is meaningless as the diagonals are all zero, as they should be; this is the distance between a site and itself. I hope somebody will help me! So perhaps you could explain why you want the diagonal. It would be easier to just do: diags - rep(0, length = nrow(bryceveg)) That will be without the sample labels, but that is easily rectified names(diags) - rownames(bryceveg) all.equal(diags, diag(as.matrix(dis.bc))) [1] TRUE So you'll have to reformulate your question if this is not what you wanted. A word of warning, do not do diag(dis.bc)) on the above as it brought my Linux box to it's knees trying to do something silly - easily
[R] Dissimilarity Analysis
Hello you all! I am a completely new user of R and I have a problem to solve. I am using Mac OS X on a PowerBook. I have a table that looks like this: species X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 X21 1Anth_cap1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 1 0 0 0 1 2 Anth_crin1 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 3Anth_eck1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 4 Anth_gram1 1 0 0 1 0 1 0 0 1 NA NA NA NA 0 0 0 0 1 0 0 0 5 Anth_insi1 1 0 0 1 0 1 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 All columns are binary coded characters. The Import was done by this Test-read.table(TestRFemMalBivariat1.csv,header = TRUE, sep = ;) Now I try to perform a similarity analysis with the dsvdis function of the labdsv package with the sorensen-Index. My first question is if all zeros in my table are seen as missing values and if it islike that how can I change without turning zero into other numbers? Secondly I tried to perform the analysis as simple as possible, after changing the characterstates into 1 and 2 with this code: DisTest-dsvdis(Test, index = sorensen) But I always get back this error message: Warnung in symbol.For(dsvdis) :'symbol.For' is not needed: please remove it Fehler in dsvdis(Test, index = sorensen) : NA/NaN/Inf in externem Funktionsaufruf (arg 1) Zusätzlich: Warning message: NAs durch Umwandlung erzeugt By the way I tried to import my table with the scan function because I didn´t really understand what I have to fill in in the what Argument if I want to define it as a list. scan(file = , what = double(0), nmax = -1, n = -1, sep = , quote = if(identical(sep, \n)) else '\, dec = ., skip = 0, nlines = 0, na.strings = NA, flush = FALSE, fill = FALSE, strip.white = FALSE, quiet = FALSE, blank.lines.skip = TRUE, multi.line = TRUE, comment.char = , allowEscapes = FALSE, encoding = unknown) I hope somedody can help me with my problem and thanks in advance. Best regards Birgit Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.
[R] similarity
Hello I have a question about performing a similarity analysis using R. I will perform a similarity analysis comparing species. I have a datamatrix that looks like the Pictures you can see in the mail. It contains bivariate data and data in this Min Max mode. I had to alter the multivariate data into min max, because I had more than one number in one species and also I had to alter the unordered multivariate data into bivariate data for the same reason. Now I am looking for a similarity algorithm or approach in R that is able to deal with this data and further gives the possibility to weight the variables differently. By the way it would be fine if this approach would be also able to treat numerical data. I hope somebody can help me. Best regards Birgit   Birgit Lemcke Institut für Systematische Botanik Zollikerstrasse 107 CH-8008 Zürich Switzerland Ph: +41 (0)44 634 8351 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch 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 commented, minimal, self-contained, reproducible code.