Re: [R] command line interface
Lana Schaffer wrote: How can plots (histograms) be implemented with the command line interface to R? I don't understand this question. There's a chance that you are looking for the function hist(). Please read the posting guides beeing added at the end of your posting. Uwe Ligges Lana Schaffer __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] text editor for R - summary on R-WinEdt
Dear all, let me try to summarize this thread's R-WinEdt related messages and give a few comments: Murray Jorgensen wrote: I tried R-WinEdt a few years ago, but as I remember it interfered with my usual use of WinEdt which is as a front end to MiKTeX. Is there a way to use WinEdt both ways? Yes, as already answered by some others ... There are plans to be able to have an R mode in the usual WinEdt setting, so R's highlighting will adapt to the current document settings, but I don't know when there will be time to implement that in a clean manner. David Scott wrote [in response to Murray Jorgensen]: This problem annoyed me for a while too. My solution (which is not perhaps ideal) is this. You want two different incarnations of WinEdt, one for TeX, the other for R. On the desktop I have a shortcut to WinEdt which is the one for TeX stuff. I open the other one with R syntax highlighting etc by starting R and using library(RWinEdt). To do this you have to install the RWinEdt package and SWinRegistry. This is all well explained in the ReadMe.txt for RWinEdt. I think with the right additions to the Target field in a shortcut to WinEdt you can call up the incarnation of WinEdt that is suitable for R. I haven't done that. You would then have two shortcuts to WinEdt, one for your TeX stuff, one for R. Thanks for this detailed and accurate description. Liaw, Andy wrote: Uwe would be the authority on this 8-), but my impression is that if you keep two separate shortcuts, you should be fine. The one for R-WinEdt has flags that sets it up for R, which should not be used in the one for MikTeX. Indeed. Kevin Wang wrote: I think Andy is correct. A few years ago (back in the dark ages -- before I discovered Emacs/ESS), I had two short cuts, one calls R-WinEdt (i.e. with flags...etc) and the other with just a normal WinEdt icon. However, I *think* now you can interact R-WinEdt within R directly (I tried the new version about 2 ~ 3 months ago just for fun, and that seemed to be the case, but I can't quite remember *_*). You can fire up R-WinEdt from R, but I would not call it interact within R directly. Peter Flom wrote: I use WinEdt for both. I simply installed it twice, and set up one version for R and one for LaTeX, I have seperate icons on the desktop, with different names, and it works fine. It is not necessary to have two installations. Uwe Ligges __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Importing an Excel file
I use very much Excel in my job and often I've to read Excel data in R. Usually I save Excel file as a .txt file and then I read it in R with read.table(). I find really interesting the suggest of using the function read.xls() in the 'gregmisc' package. I work also with R in Excel sheets by R-Com/R-Interface (see: http://www.sciviews.org/_rgui/projects/RDcom.html) It has several limits, but for some analysis is helpfull. Bye Vito Ricci Park, Kyong H Mr. RDECOM kyong.ho.park at us.army.mil Wed Jul 7 20:21:42 CEST 2004 Hello, R users, I am a very beginner of R and tried read.csv to import an excel file after saving an excel file as csv. But it added alternating rows of fictitious NA values after row number 16. When I applied read.delim, there were trailing several commas at the end of each row after row number 16 instead of NA values. Appreciate your help. Kyong = Diventare costruttori di soluzioni Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Problem with the grep function
Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] read.frame
For E: e - e[,1] ; uni - union(c[,1],union(s[,1],h[,1])) Then e[!match(e, uni, 0)] should get you there. Alec Alec Stephenson Department of Statistics Macquarie University NSW 2109, Australia S Peri [EMAIL PROTECTED] 07/08/04 02:41pm Dear Alec, Thank you for your response and it worked. Further, I have another mathematical problem. I apologize ahead as this question is not apt for this list. I am a biologist working at Johns Hopkins School of Medicine. As I listed in my previous e-mail (attached below)I mentioned I have 4 protein sets. I am now trying to calculate the combinatorics of these sets. My ultimate aim is to draw a venn diagram and find out the proteins that are unique to set C,S,E and H. I drew a venn diagram graph and I am banging my head to deduce the combinations. It is easy for me to deduce the intersections - that means the protein entries that are present in common. However, it proved very difficult to deduce the following: I could calculate the following: NP_*** present in both C and E (C intersection E) NP_*** present in both C and H (C intersection H) NP_*** present in both C and S (C ^ S) NP_*** present in both E and H (E ^ H) NP_*** present in both E and S (E ^ S) NP_*** present in both H and S (H ^ S) NP_*** present in C, E and H (C^E^H) NP_*** present in C, H and S (C^H^S) NP_*** present in E, H and S (E^H^S) NP_*** present in E, S and C (E^S^C) It is very difficult for me to deduce the following: NP_ entries specific to E NP_ entries specific to H NP_ entries specific to S I waster many pages but could not derive some solution to get unique elements for sets, s,e,h,and C. Can any one help me by suggesting some way to get these. Thank you and I apologise again for posting the wrong question. SP --- S Peri [EMAIL PROTECTED] wrote: Hello group, I am learning R and I am new to many concepts.I face the following errors when I am trying to execute the following. I have 4 text files with protein accession numbers. I wanted to represent them in a venn diagram and for that I using intersect and setdiff functions. My data looks like this: file1.txt (c): NP_05 NP_20 NP_30 NP_53 file2.txt(e): NP_05 NP_20 NP_30 NP_31 NP_53 NP_55 NP_87 file3.txt(h): NP_05 NP_20 NP_30 NP_53 NP_55 NP_57 NP_87 file4.txt (s): NP_05 NP_20 NP_30 NP_33 NP_53 NP_55 NP_87 NP_000168 Now I did the following FIRST time: c=read.table(file1.txt) e=read.table(file2.txt) s=read.table(file4.txt) h=read.table(file3.txt) class(c) [1] data.frame class(s) [1] data.frame CiS=intersect(c,s) CiS NULL data frame with 0 rows # Why am I getting NULL data error. I know there are common elements between c and S. ## CiS-intersect(read.matrix(c,s)) Error in unique(y[match(x, y, 0)]) : Argument y is missing, with no default CiS-intersect(read.frame(c,s)) Error in unique(y[match(x, y, 0)]) : Argument y is missing, with no default # Why am I getting this error. Second thing I did: I loaded the data as data.frame instead read.table(). Again I never get intersection of C,E and S,H. Can any one please help me. thank you SP __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
Hi! For exact matches you can use == or is.element. To get the indices use which. e.g. == x-c(a,b,ab) x==a [1] TRUE FALSE FALSE which((x==a)==T) [1] 1 or e.g. is.element is.element(x,a) [1] TRUE FALSE FALSE which(is.element(x,a)==TRUE) [1] 1 Sincerely Eryk *** REPLY SEPARATOR *** On 7/8/2004 at 9:20 AM [EMAIL PROTECTED] wrote: Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Dipl. bio-chem. Eryk Witold Wolski@MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: [EMAIL PROTECTED]---W-Whttp://www.molgen.mpg.de/~wolski __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
grep(^b$,nom) will match b only. Alec Alec Stephenson Department of Statistics Macquarie University NSW 2109, Australia [EMAIL PROTECTED] [EMAIL PROTECTED] 07/08/04 05:20pm Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
Hi Christian, It works better now. Thanks a lot. Julie At 09:32 08/07/2004 +0200, you wrote: Hi Julie, as I understand your question you only want indices for exact matches to b. This can be achieved using regular expressions (see ?regex) nom - c(a,b,ab) grep(^b$,nom) I hope this helps? Christian __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Importing an Excel file
Hi, I'm trying to use read.xls() function to import Excel data, but I've this error: Error in system(cmd, intern = !verbose) : perl not found R is running under Win2000; This function works translating the named Microsoft Excel file into a temporary .csv file, using Greg Warnes' xls2csv perl script (installed as part of the gregmisc package). What happens? Cordially Vito Ricci = Diventare costruttori di soluzioni Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
Hi Julie, match is not exactly what you need, as it works with regular expressions and takes anything what includes a letter b. For your case, there is perfectly suitable which(nom==b) nom - c(a,b,ab, b) which(nom==b) [1] 2 4 Jan - - - Original message: - - - From: [EMAIL PROTECTED] Send: 8.7.2004 9:24:58 To: [EMAIL PROTECTED] Subject: [R] Problem with the grep function Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
Or you must mark the word beginning with ^ and the end $ if you like to use grep. grep(^b$,nom) Sincerely Eryk *** REPLY SEPARATOR *** On 7/8/2004 at 9:20 AM [EMAIL PROTECTED] wrote: Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Dipl. bio-chem. Eryk Witold Wolski@MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: [EMAIL PROTECTED]---W-Whttp://www.molgen.mpg.de/~wolski __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
Wolski wrote: Hi! For exact matches you can use == or is.element. To get the indices use which. e.g. == x-c(a,b,ab) x==a [1] TRUE FALSE FALSE which((x==a)==T) Note, the ==T part is superflously (same below). In grep()'s regular expression, you can also use: grep(^b$, nom) or similar stuff. Uwe Ligges [1] 1 or e.g. is.element is.element(x,a) [1] TRUE FALSE FALSE which(is.element(x,a)==TRUE) [1] 1 Sincerely Eryk *** REPLY SEPARATOR *** On 7/8/2004 at 9:20 AM [EMAIL PROTECTED] wrote: Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Dipl. bio-chem. Eryk Witold Wolski@MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: [EMAIL PROTECTED]---W-Whttp://www.molgen.mpg.de/~wolski __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Importing an Excel file
Hi, On Thu, 8 Jul 2004, [iso-8859-1] Vito Ricci wrote: Hi, I'm trying to use read.xls() function to import Excel data, but I've this error: Error in system(cmd, intern = !verbose) : perl not found What happens? It means it cannot find Perl. You need Perl installed (and in your Path) in your system. Kev Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7411 Ph (M): +61-40-451-8301 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Importing an Excel file
Vito Ricci wrote: Hi, I'm trying to use read.xls() function to import Excel data, but I've this error: Error in system(cmd, intern = !verbose) : perl not found R is running under Win2000; This function works translating the named Microsoft Excel file into a temporary .csv file, using Greg Warnes' xls2csv perl script (installed as part of the gregmisc package). What happens? You already told us that there is a perl script, and the error message says that perl has not been found. So what about installing perl and adding it to your path? Uwe Ligges Cordially Vito Ricci = Diventare costruttori di soluzioni Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to pass strings to functions?
__ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to pass strings to functions?
Please do not use the subject to ask a question without clarifying it! So what exactly do you want? Can you give some more descriptions? Kev Ko-Kang Kevin Wang PhD Student Centre for Mathematics and its Applications Building 27, Room 1004 Mathematical Sciences Institute (MSI) Australian National University Canberra, ACT 0200 Australia Homepage: http://wwwmaths.anu.edu.au/~wangk/ Ph (W): +61-2-6125-2431 Ph (H): +61-2-6125-7411 Ph (M): +61-40-451-8301 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lost messages
Aaron == Aaron J Mackey [EMAIL PROTECTED] on Wed, 7 Jul 2004 16:31:25 -0400 writes: Aaron The second two resends did go through (I checked on Aaron the web archive), but the first did not; Aaron additionally, the second two resends both came Aaron through with the exact same timestamp, even though I Aaron resent them over the space of 4 hours or so (and only Aaron after I had sent the lost messages message, which Aaron did come through to me just fine). So there was Aaron something stuck, but seems to be unstuck now. Aaron Thanks to all, yes, and please all do learn from this: Just because *you* may not have got your message back in time, don't jump to wrong conclusions. At least look into the mailing list archives first. If you still see a problem, check with your local IT E-mail support and then send mail to [EMAIL PROTECTED] (or me directly) rather than the whole list ^^ Please don't spam the 2500 R-help readers with such things in the future. Martin Maechler __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to pass strings to functions? [once more, now With content I hope...]
__ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] building packages with NAMESPACE
hi! I tried to build a very simple package with NAMESPACE file, such that datasets are loaded only dynamically. a2 - function(x=a1) x+4 a1 - 1:10 package.skeleton(aaa, list=c(a1, a2)) Then I modified the help files and added the file NAMESPACE with these 2 lines: useDynLib(aaa) export(a1, a2) Then R CMD BUILD aaa works fine, but R CMD CHECK aaa gives: . * checking R files for syntax errors ... OK * checking R files for library.dynam ... OK * checking S3 generic/method consistency ... WARNING Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed Execution halted * checking for replacement functions with final arg not named 'value' ... WARNING Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed Execution halted Without NAMESPACE file there wasn't any error, so anybody could help me? Thanks Meinhard Ploner PS: version _ platform powerpc-apple-darwin7.2.0 arch powerpc os darwin7.2.0 system powerpc, darwin7.2.0 status major1 minor8.1 year 2003 month11 day 21 language R __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] loding *.o file in windows environment
Hi, Assuming that I dont have the source C file, is it anyhow possible for me to load the object file (*.o) in R under windows environment. I tried using dyn.load(), but obviously it didnt worked. Thanks, Utsav __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Getting elements of a matrix by a vector of column indices
I have e.g. t - matrix( nrow=2, ncol=3, byrow=TRUE, c('a1','a2','a3','b1','b2','b3') ) and i - c( 3, 2) Is it possible to formulate a simple expression that gets c( t[ 1, i[1] ], t[ 2, i[2] ] ) (and so on for longer matrices)? The result would be: [1] a3 b2 Thanks - Wolfram __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to pass strings to functions? [once once more, now With content I hope...]
Dear expeRts, I fail to succesfully pass strings to functions. It comes down to the observation that plot(someVariable,anotherVariable) works fine, but x - someVariable y - anotherVariable plot(x,y) does not. Does this have something to do with the returned value of x being /someVariable/ and not /someVariable/, i.e. without the quotation marks? Is there any way to work around this? Ultimately I'd like to make multiple graphs by looping throught the values in vectors. Something like: var-c(var1,var2...n) for (v in var) { plot(var, x)) } I've looked around for help on this but am stuck. Hope you can help, Gijs Plomp __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] loding *.o file in windows environment
Utsav Boobna wrote: Hi, Assuming that I dont have the source C file, is it anyhow possible for me to load the object file (*.o) Well, the sources must be compiled under Windows (or at least cross-compiled on another platform). Most probably, an .o file has been compiled under Unix-alikes. You do need the sources in this case. Uwe Ligges in R under windows environment. I tried using dyn.load(), but obviously it didnt worked. Thanks, Utsav __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Statistics::R
Hello I am looking (possibly in vain!) for the Author of the Statistics::R perl package - I believe he announced the package on this mailing list some months ago. The name is Graciliano Monteiro Passos, and his e-mail address, [EMAIL PROTECTED], is giving permanent errors. Can anyone help? Does anyone use this perl package with R? I am having a few problems with it. Sorry to everyone whom this message is irrelevant to. Thanks Mick __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to pass strings to functions? [once once more, now With content I hope...]
Gijs Plomp wrote: Dear expeRts, I fail to succesfully pass strings to functions. It comes down to the observation that plot(someVariable,anotherVariable) works fine, but x - someVariable y - anotherVariable plot(x,y) Do you mean x - someVariable y - anotherVariable plot(x,y) Why are you not calling plot(someVariable, anotherVariable) does not. Does this have something to do with the returned value of x being /someVariable/ and not /someVariable/, i.e. without the quotation marks? Is there any way to work around this? Ultimately I'd like to make multiple graphs by looping throught the values in vectors. Something like: var-c(var1,var2...n) for (v in var) { plot(var, x)) } Does not make sense. You need to use v within the loop. But I don't know what you are intending? You still need to be more specific! Uwe Ligges I've looked around for help on this but am stuck. Hope you can help, Gijs Plomp __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to pass strings to functions? [once once more, now With content I hope...]
Dear expeRts, I fail to succesfully pass strings to functions. It comes down to the observation that plot(someVariable,anotherVariable) works fine, but x - someVariable y - anotherVariable plot(x,y) does not. Does this have something to do with the returned value of x being /someVariable/ and not /someVariable/, i.e. without the quotation marks? Is there any way to work around this? Ultimately I'd like to make multiple graphs by looping throught the values in vectors. Something like: var-c(var1,var2...n) for (v in var) { plot(var, x)) } what about plot(get(v), x)? I've looked around for help on this but am stuck. Hope you can help, Gijs Plomp __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Getting elements of a matrix by a vector of column indices
Wolfram Fischer wrote: I have e.g. t - matrix( nrow=2, ncol=3, byrow=TRUE, c('a1','a2','a3','b1','b2','b3') ) and i - c( 3, 2) Is it possible to formulate a simple expression that gets c( t[ 1, i[1] ], t[ 2, i[2] ] ) (and so on for longer matrices)? The result would be: [1] a3 b2 Two solutions are (there might be better ones): a) mapply(function(x,y) t[x,y], 1:nrow(t), i) b) t(t)[i + (1:nrow(t) - 1) * (ncol(t))] Note that calling the matrix t is not the best idea. Uwe Ligges Thanks - Wolfram __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Getting elements of a matrix by a vector of column indice s
See if the following helps: m - outer(letters[1:5], 1:4, paste, sep=) m [,1] [,2] [,3] [,4] [1,] a1 a2 a3 a4 [2,] b1 b2 b3 b4 [3,] c1 c2 c3 c4 [4,] d1 d2 d3 d4 [5,] e1 e2 e3 e4 idx - c(2, 1, 3, 4, 2) m[cbind(1:5, idx)] [1] a2 b1 c3 d4 e2 Andy From: Wolfram Fischer I have e.g. t - matrix( nrow=2, ncol=3, byrow=TRUE, c('a1','a2','a3','b1','b2','b3') ) and i - c( 3, 2) Is it possible to formulate a simple expression that gets c( t[ 1, i[1] ], t[ 2, i[2] ] ) (and so on for longer matrices)? The result would be: [1] a3 b2 Thanks - Wolfram __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Problem with the grep function
Hi You can use %in% nom%in%b [1] FALSE TRUE FALSE which gives you a logical vector of exact matches (1:3)[nom%in%b] [1] 2 or charmatch charmatch(b,nom) [1] 2 charmatch(ab,nom) [1] 3 if you expect only one exact match. But I expect someone can give you better answer. Cheers Petr On 8 Jul 2004 at 9:20, [EMAIL PROTECTED] wrote: Let me present to you my problem : I have a character vector x and I would like to obtain the indices of the elements of this vector that yielded exactly a match. For example, x=nom, pattern=b, I would to obtain 2 because b is on the second position. First program : nom - c(a,b,ab) grep(b,nom) 2 3 Then I try the option extended =FALSE (instead of TRUE by default) and I obtain '2 3' a second time. Please can you help me : How can I obtain only 2 in using the grep function (without using the match function). Thanks you Julie AUBERT __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Importing an Excel file
Hi If you do not have complicated items with spaces and special characters and you want some easy copiing on fly just issue in R read.delim(clipboard) after selecting an area in Excel file and pressing Ctrl-C Cheers Petr On 8 Jul 2004 at 9:15, Vito Ricci wrote: I use very much Excel in my job and often I've to read Excel data in R. Usually I save Excel file as a .txt file and then I read it in R with read.table(). I find really interesting the suggest of using the function read.xls() in the 'gregmisc' package. I work also with R in Excel sheets by R-Com/R-Interface (see: http://www.sciviews.org/_rgui/projects/RDcom.html) It has several limits, but for some analysis is helpfull. Bye Vito Ricci Park, Kyong H Mr. RDECOM kyong.ho.park at us.army.mil Wed Jul 7 20:21:42 CEST 2004 Hello, R users, I am a very beginner of R and tried read.csv to import an excel file after saving an excel file as csv. But it added alternating rows of fictitious NA values after row number 16. When I applied read.delim, there were trailing several commas at the end of each row after row number 16 instead of NA values. Appreciate your help. Kyong = Diventare costruttori di soluzioni Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Petr Pikal [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] building packages with NAMESPACE
Meinhard Ploner wrote: hi! I tried to build a very simple package with NAMESPACE file, such that datasets are loaded only dynamically. a2 - function(x=a1) x+4 a1 - 1:10 package.skeleton(aaa, list=c(a1, a2)) Then I modified the help files and added the file NAMESPACE with these 2 lines: useDynLib(aaa) export(a1, a2) a) Don't export data frames. b) Don't useDynLib, if there is no library to be used. = The correct NAMESPACE file contains not more than the single line export(a2) Uwe Ligges Then R CMD BUILD aaa works fine, but R CMD CHECK aaa gives: . * checking R files for syntax errors ... OK * checking R files for library.dynam ... OK * checking S3 generic/method consistency ... WARNING Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed Execution halted * checking for replacement functions with final arg not named 'value' ... WARNING Error in .tryQuietly({ : Error in library(package, lib.loc = lib.loc, character.only = TRUE, verbose = FALSE) : package/namespace load failed Execution halted Without NAMESPACE file there wasn't any error, so anybody could help me? Thanks Meinhard Ploner PS: version _ platform powerpc-apple-darwin7.2.0 arch powerpc os darwin7.2.0 system powerpc, darwin7.2.0 status major1 minor8.1 year 2003 month11 day 21 language R __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Replies for Importing Excel File
I really appreciate all the helpful answers from Richard Müller, Marc Schwartz, Adaikalavan Ramasamy, Vito Ricci. I tried Marc's simple suggestion which was to copy only the data area and paste to a new excel sheet, and that solved my problem. I'll try other suggestions while I'm learning more about R. Unedited answers are provided below followed by my question. Thanks again. Kyong -- From Richard Müller: I import my OpenOffice calc files as follows (OOo or Excel won't make any difference, the csv-format is the same): inp - (scan(file, sep=;, dec=,, list(0,0), skip = 13, nlines = 58) x - inp[[1]]; y - inp [[2]] sep=;: column separator ; dec=, decimal separator , list(0,0): first two columns skip: no of lines to skip (these lines contain comments etc.) nlines=58: 58 lines of values to plot -- From Marc Schwartz Yep. This is one of the behaviors that I had seen with Excel when I was running Windows XP. Seemingly empty cells outside the data range would get exported in the CSV file causing a data integrity problem. It is one of the reasons that I installed OpenOffice under Windows and used Calc to open the Excel files and then do the CSV exports before I switched to Linux :-) Depending upon the version of Excel you are using, you might try to highlight and copy only the rectangular range of cells in the sheet that actually have data to a new sheet and then export the new sheet to a CSV file. Do not just click on the upper left hand corner of the sheet to highlight the entire sheet to copy it. Only highlight the range of cells you actually need for copying. Another option is to use the read.xls() function in the 'gregmisc' package on CRAN or install OpenOffice. -- From Adaikalavan Ramasamy: Are all you data numerical or does it contain characters as well ? Check for the common culprits - the hash (#) which is the comment character in R, unbalanced single and double quotes and other suspicious characters around line 16 and in general. If that does not work, open in Excel and just delete all the unwanted columns (and rows) even if they appear empty. Then save as csv and try again. read.delim() will not work properly in your case because it recognises tab as separator. From Vito Ricci: I use very much Excel in my job and often I've to read Excel data in R. Usually I save Excel file as a .txt file and then I read it in R with read.table(). I find really interesting the suggest of using the function read.xls() in the 'gregmisc' package. I work also with R in Excel sheets by R-Com/R-Interface (see: http://www.sciviews.org/_rgui/projects/RDcom.html) It has several limits, but for some analysis is helpfull. --- My original question: Hello, R users, I am a very beginner of R and tried read.csv to import an excel file after saving an excel file as csv. But it added alternating rows of fictitious NA values after row number 16. When I applied read.delim, there were trailing several commas at the end of each row after row number 16 instead of NA values. Appreciate your help. [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] parallel mle/optim and instability
I have a MLE task that for a small number of parameters finishes in a reasonable amount of time, but for my real case (with 17 parameters to be estimated) either takes far too long (over a day), or fails with computationally singular errors. So a) are there any parallel implementations of optim() (in R or otherwise) and b) how can I make my function more robust? (I've already resorted to using bounded parameters and log transformations, which has helped to some degree) Thanks, -Aaron library(stats4); d - data.frame( ix=c(0,1,2,3,4,5,6,7), ct=c(1000,9609,18403,2617,8237,3619,5520,18908), A=c(0,1,0,1,0,1,0,1), B=c(0,0,1,1,0,0,1,1), C=c(0,0,0,0,1,1,1,1) ); ct - round(logb(length(d$ix), 2)) ll - function( th=0.5, a1=log(0.5), a2=log(0.5), a3=log(0.5), b1=log(0.5), b2=log(0.5), b3=log(0.5) ) { a - exp(sapply(1:ct, function (x) { get(paste(a, x, sep=)) })); b - exp(sapply(1:ct, function (x) { get(paste(b, x, sep=)) })); s - -sum( d$ct * log( sapply( d$ix, function (ix, th, a, b) { x - d[ix+1,3:(ct+2)] (th * prod((b ^ (1-x)) * ((1-b) ^ x))) + ((1-th) * prod((a ^ x) * ((1-a) ^ (1-x }, th, a, b ) ) ); if (!is.finite(s)) stop(cat(th, a, b, s, sep=\n)); s; } ml - mle(ll, lower=c(1e-10, rep(log(1e-10), 2*ct)), upper=c(1 - 1e-10, rep(log(1 - 1e-10), 2*ct)), method=L-BFGS-B, ); __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Importing an Excel file
Hi Vito: You may consider obtaining ActivePerl from the following site and install it in Windows: http://www.activestate.com/Products/ActivePerl/ and then retry. HTH, Arin On Thu, 08 Jul 2004 Vito Ricci wrote : Hi, I'm trying to use read.xls() function to import Excel data, but I've this error: Error in system(cmd, intern = !verbose) : perl not found R is running under Win2000; This function works translating the named Microsoft Excel file into a temporary .csv file, using Greg Warnes' xls2csv perl script (installed as part of the gregmisc package). What happens? Cordially Vito Ricci = Diventare costruttori di soluzioni Visitate il portale http://www.modugno.it/ e in particolare la sezione su Palese http://www.modugno.it/archivio/cat_palese.shtml __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Arindam Basu MD MPH DBI Assistant Director Fogarty International Program on Environmental Health in India IPGMER 244 AJC Bose Road, Kolkata 700027 India [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Parsing protein sequences
Dear All, I have two files with peptide sequences. These two have peptide sequences(obtained from tryptic and semi-tryptic digestion using Mass spec analysis). There are two columns :peptide sequence and protein name. File 2 has both tryptic and semi-tryptic peptides and File 1 has only semi-tryptic peptides. Is there a way out that I can filter semi-tryptic peptides from typtic ones. There are ~30,000 peptides in each file. Please suggest if this can be done in R. I want to do further analysis involving some statistics using R. Thank you in advance. SP File 1 (is a comma seperated file): pepseq proteinname FENGAFT NP_065081.1 SLLEDIR NP_062571.1 VCCEGMLIQ NP_064583 NWGLSVYADKPETTK NP_000598 MLAFDVNDEK NP_000598 File 2 (comma seperated file): SLLEDIR NP_062571 TYMLAFDVNDEKNP_000598 ASSLSESSPPK NP_057441 LSIVVSLGTGR NP_003551 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Predicting X from Y in four-parameter fit (SSfpl)
While analyzing titration-data using four parameter fit, I need to predict single values from the model: I need to predict both ways (ie: X-Y Y-X): Example: library(nls) cramp-c(33,100,300,900,2700,8100,24300,72900) myo-c(2.7130,2.6790,1.5255,0.7675,0.3670,0.2150,0.1575,0.1400) titration-data.frame(cramp,myo) nls(myo~SSfpl(log(cramp),A,B,xmid,scal),data=titration) SSfpl(log(2000), coef(sm)[1],coef(sm)[2],coef(sm)[3],coef(sm)[4]) - [1] 1.060424 This is an example of predicting single values X-Y Here is my question: How do I predict the other way around Y-X ?? Any help is appreciated Best regards, Klaus State Serum Institute, Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R-pkgs] randomForest 4.3-0 released
Dear all, Version 4.3-0 of the randomForest package is now available on CRAN (in source; binaries will follow in due course). There are some interface changes and a few new features, as well as bug fixes. For those who had used previous versions, the important things to note are: 1. there's a namespace now, and 2. some functions have been renamed. The list of changes since 4.0-7 (last public release) is shown below. As many changes were made to the package, it's very likely that new bugs have crept in. I'd very much appreciate bug reports or even patches! The plan is still to add features to the package so that it matches the features in Breiman and Cutler's latest Fortran version. There is also plan to add some functions so that the package will work with Adele Cutler's Java visualization program (RAFT). Best, Andy Changes in 4.3-0: * Thanks to Adele Cutler, there's now casewise variable importance measures in classification. Similar feature is also added for regression. Use the new localImp option in randomForest(). * The `importance' component of randomForest object has been changed: The permutation-based measures are not divided by their `standard errors'. Instead, the `standard errors' are stored in the `importanceSD' component. One should use the importance() extractor function rather than something like rf.obj$importance for extracting the importance measures. * The importance() extractor function has been updated: If the permutation-based measures are available, calling importance() with only a randomForest object returns the matrix of variable importance measures. There is the `scale' argument, which defaults to TRUE. * In predict.randomForest, there is a new argument `nodes' (default to FALSE). For classification, if nodes=TRUE, the returned object has an attribute `nodes', which is an n by ntree matrix of terminal node indicators. This is ignored for regression. Changes in 4.2-1: * There is now a package name space. Only generics are exported. * Some function names have been changed: partial.plot - partialPlot var.imp.plot - varImpPlot var.used - varUsed * There is a new option `replace' in randomForest() (default to TRUE) indicating whether the sampling of cases is with or without replacement. * In randomForest(), the `sampsize' option now works for both classification and regression, and indicate the number of cases to be drawn to grow each tree. For classification, if sampsize is a vector of length the number of classes, then sampling is stratified by class. * With the formula interface for randomForest(), the default na.action, na.fail, is effective. I.e., an error is given if there are NAs present in the data. If na.omit is desired, it must be given explicitly. * For classification, the err.rate component of the randomForest object (and the corresponding one for test set) now is a ntree by (nclass + 1) matrix, the first column of which contains the overall error rate, and the remaining columns the class error rates. The running output now also prints class error rates. The plot method for randomForest will plot the class error rates as well. * The predict() method now checks whether the variable names in newdata match those from the training data (if the randomForest object is not created from the formula interface). * partialPlot() and varImpPlot() now have optional arguments xlab, ylab and main for more flexible labelling. Also, if a factor is given as the variable, a real bar plot is produced. * partialPlot() will now remove rows with NAs from the data frame given. * For regression, if proximity=FALSE, an n by n array of integers is erroneously allocated but not used (it's only used for proximity calculation, so not needed otherwise). * Updated combine() to conform to the new randomForest object. * na.roughfix() was not working correctly for matrices, which in turns causes problem in rfImpute(). Changes in 4.1-0: * In randomForest(), if sampsize is given, the sampling is now done without replacement, in addition to stratified by class. Therefore sampsize can not be larger than the class frequencies. * In classification randomForest, checks are added to avoid trees with only the root node. * Fixed a bug in the Fortran code for classification that caused segfault on some system when encountering a tree with only root node. * The help page for predict.randomForest() now states the fact that when newdata is not specified, the OOB predictions from the randomForest object is returned. * plot.randomForest() and print.randomForest() were not checking for existence of performance (err.rate or mse) on test data correctly. ___ R-packages mailing list [EMAIL PROTECTED] https://www.stat.math.ethz.ch/mailman/listinfo/r-packages
Re: [R] Creating Binary Outcomes from a continuous variable
Marc Schwartz wrote: On Wed, 2004-07-07 at 07:57, Doran, Harold wrote: Dear List: I have searched the archives and my R books and cannot find a method to transform a continuous variable into a binary variable. For example, I have test score data along a continuous scale. I want to create a new variable in my dataset that is 1=above a cutpoint (or passed the test) and 0=otherwise. My instinct tells me that this will require a combination of the transform command along with a conditional selection. Any help is much appreciated. Example: a - rnorm(20) b - ifelse(a 0, 0, 1) a [1] -1.0735800 -0.6788456 1.9979801 -0.4026760 0.1781791 -1.1540434 [7] -1.0842728 1.6042602 -0.7950492 -0.1194323 0.4450296 1.9269333 [13] -0.4456181 -0.8374677 -1.1898772 1.7353067 1.8619422 -0.1679996 [19] -0.2656138 -1.5529884 b [1] 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 1 1 0 0 0 HTH, Marc Schwartz For your application Harold I would consider converting the response to a factor while dichotomizing it so that summary will give a meaningful table b - factor(ifelse(a 0, Neg, Pos)) BTW, there are many examples like this in the notes for the short course that you took last summer :-) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Code OK - Predicting X from Y in four-parameter fit (SSfpl) -
[Sorry for any inconvenience - Code is OK now] While analyzing titration-data using four parameter fit, I need to predict single values from the model: I need to predict both ways (ie: X-Y Y-X): Example: library(nls) cramp-c(33,100,300,900,2700,8100,24300,72900) myo-c(2.7130,2.6790,1.5255,0.7675,0.3670,0.2150,0.1575,0.1400) titration-data.frame(cramp,myo) fi-nls(myo~SSfpl(log(cramp),A,B,xmid,scal),data=titration) SSfpl(log(2000), coef(fi)[1],coef(fi)[2],coef(fi)[3],coef(fi)[4]) - 0.3689212 This is an example of predicting single values X-Y Here is my question: How do I predict the other way around Y-X ?? Any help is appreciated Best regards, Klaus State Serum Institute, Copenhagen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Getting elements of a matrix by a vector of column indice s
Thanks for you answer! It works. m - outer(letters[1:5], 1:4, paste, sep=) The following works with the help of your proposition: rowidx.n - c( 2, 3, 4) colidx.n - c( 1, 3, 2) idx.n - cbind( rowidx.n, colidx.n ) m[idx.n] [1] b1 c3 d2 In my real data there was an additional difficulty: I had names of rows and columns as indices: rownames(m) - paste('R', 1:nrow(m), sep=) colnames(m) - paste('C', 1:ncol(m), sep= ) And the following did not work anymore: rowidx - c( 'R2', 'R3', 'R4' ) colidx - c( 'C1', 'C3', 'C2' ) idx - cbind( rowidx, colidx ) m[idx] NA NA NA NA NA NA NA NA NA NA NA NA Do you have another suggestion? - Thanks! Wolfram --- In reply to: --- Date:08.07.04 08:21 (-0400) From:Liaw, Andy [EMAIL PROTECTED] Subject: RE: [R] Getting elements of a matrix by a vector of column indice s See if the following helps: m - outer(letters[1:5], 1:4, paste, sep=) m [,1] [,2] [,3] [,4] [1,] a1 a2 a3 a4 [2,] b1 b2 b3 b4 [3,] c1 c2 c3 c4 [4,] d1 d2 d3 d4 [5,] e1 e2 e3 e4 idx - c(2, 1, 3, 4, 2) m[cbind(1:5, idx)] [1] a2 b1 c3 d4 e2 Andy From: Wolfram Fischer I have e.g. t - matrix( nrow=2, ncol=3, byrow=TRUE, c('a1','a2','a3','b1','b2','b3') ) and i - c( 3, 2) Is it possible to formulate a simple expression that gets c( t[ 1, i[1] ], t[ 2, i[2] ] ) (and so on for longer matrices)? The result would be: [1] a3 b2 Thanks - Wolfram __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Re: errors in randomization test
Dear Rolf, I tried using you code, however i have found that the whole routine is still stopped by the call to GLM.nb fro certain datasets before it enters the if statement. is there anyway to ensure that this does not occur. cheers, colin --On Tuesday, July 6, 2004 9:23 am -0300 Rolf Turner [EMAIL PROTECTED] wrote: Colin Bleay wrote: last week i sent an e-mail about dealing with errors thrown up from a glm.nb model carried out on multiple random datasets. every so often a dataset is created which results in the following error after a call to glm.nb: Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: Step size truncated due to divergence I am at a loss as to how to deal with this. firstly because the dataset that is generated, although throwing an error when the glm.nb model is applied, is a valid dataset. so how do i incorporate this dataset in my results (results being descriptive stats on the coefficients from the multiple datasets) i.e. shoould coefficients be set to zero? Almost surely, setting the coefficients equal to 0 is the wrong thing to do. What the right thing is depends on the answer to ``lastly''. Setting the coefficients to be NA in this case (i.e. effectively throwing away such cases) is also wrong, but not quite as wrong as setting them equal to 0. secondly, how do i capture and deal with the error. is it possible to construct an if statement so that if error, do this, if not continue This should be do-able using try(). Something like: c.list - list() save.bummers - list() K - 0 for(i in 1:42) { repeat { X - generate.random.data.set() Y - try(glm.nb(X,whatever)) if(inherits(Y,try-error)) { K - K+1 save.bummers[[K]] - X } else break } c.list[[i]] - coeff(Y) } This should give you a sample of 42 coefficient vectors from the ``successful'' data sets, and a list of all the (a random number of) data sets that yielded a lack of success. You can then take the data sets stored in save.bummers and experiment with them to see what is causing the problem. lastly, i am unsure as to what characteristics of a dataset would result in these errors in the glm.nb? Here I have to heed the advice (attributed to a ``great art historian'') from George F. Simmons' wonderful book on elementary differential equations: ``A fool he who gives more than he has.'' cheers, Rolf Turner [EMAIL PROTECTED] -- Dr Colin Bleay Dept. Biological Sciences, University of Bristol, Woodlands rd., Bristol, BS8 1UG. UK Tel: 44 (0)117 928 7470 Fax: 44 (0)117 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Getting elements of a matrix by a vector of column indice s
This should work: idx - cbind(match(rowidx, rownames(m)), match(colidx, colnames(m))) m[idx] [1] b1 c3 d2 Andy From: Wolfram Fischer Thanks for you answer! It works. m - outer(letters[1:5], 1:4, paste, sep=) The following works with the help of your proposition: rowidx.n - c( 2, 3, 4) colidx.n - c( 1, 3, 2) idx.n - cbind( rowidx.n, colidx.n ) m[idx.n] [1] b1 c3 d2 In my real data there was an additional difficulty: I had names of rows and columns as indices: rownames(m) - paste('R', 1:nrow(m), sep=) colnames(m) - paste('C', 1:ncol(m), sep= ) And the following did not work anymore: rowidx - c( 'R2', 'R3', 'R4' ) colidx - c( 'C1', 'C3', 'C2' ) idx - cbind( rowidx, colidx ) m[idx] NA NA NA NA NA NA NA NA NA NA NA NA Do you have another suggestion? - Thanks! Wolfram --- In reply to: --- Date:08.07.04 08:21 (-0400) From:Liaw, Andy [EMAIL PROTECTED] Subject: RE: [R] Getting elements of a matrix by a vector of column indice s See if the following helps: m - outer(letters[1:5], 1:4, paste, sep=) m [,1] [,2] [,3] [,4] [1,] a1 a2 a3 a4 [2,] b1 b2 b3 b4 [3,] c1 c2 c3 c4 [4,] d1 d2 d3 d4 [5,] e1 e2 e3 e4 idx - c(2, 1, 3, 4, 2) m[cbind(1:5, idx)] [1] a2 b1 c3 d4 e2 Andy From: Wolfram Fischer I have e.g. t - matrix( nrow=2, ncol=3, byrow=TRUE, c('a1','a2','a3','b1','b2','b3') ) and i - c( 3, 2) Is it possible to formulate a simple expression that gets c( t[ 1, i[1] ], t[ 2, i[2] ] ) (and so on for longer matrices)? The result would be: [1] a3 b2 Thanks - Wolfram __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] k nearest neighbor prediction
Hi there fellow R-users, Does anyone know if there is a package for k nearest neighbours prediction as opposed to classification? I have found the package knncat but can't see a way to adjust it to predict a continuous variable. Any help would be great, Regards Wayne Jones KSS Ltd Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:[EMAIL PROTECTED]http://www.kssg.com The information in this Internet email is confidential and m...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Statistics::R
On Thu, 8 Jul 2004, michael watson (IAH-C) wrote: I am looking (possibly in vain!) for the Author of the Statistics::R perl package - I believe he announced the package on this mailing list some months ago. The name is Graciliano Monteiro Passos, and his e-mail address, [EMAIL PROTECTED], is giving permanent errors. Can anyone help? Does anyone use this perl package with R? I am having a few problems with it. I used it for one of my projects and also tried unsuccessfully to contact the author. I forgot to follow-up on that failure so if you find him, let me know too. Can't help without a description of the problem you are having though... -- SIGSIG -- signature too long (core dumped) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] parallel mle/optim and instability
Does optim give you computationally singular errors? I've had similar problems with nls, but optim have given me answers even in such cases. Do your numbers have substantially different orders of magnitude? Is it feasible to rescale everything to mean 0, standard deviation of 1, and then write your model in terms of these rescaled variables? If yes, this can help. I suggest you reparameterize the problem to move the constraints to +/-Inf. If you can't do that, add penalty function corresponding to the constraints, while making sure your objective function will never give NA nor +/-Inf. Find the conditions that generate that and eliminate them. Without box constraints, optim has 4 methods. I'd try the first 3; the fourth is simulated annealing, which may be wonderful for objective functions with many local minima but otherwise takes forever and produces answers that are inferior to the other three methods, in the few cases I've tried. Also, with a problem with many parameters, I've written a function that allows me to pass as a ... argument the subset of parameters I want to estimate. Then I can try different subsets until I isolate the problem. hope this helps. spencer graves Aaron J. Mackey wrote: I have a MLE task that for a small number of parameters finishes in a reasonable amount of time, but for my real case (with 17 parameters to be estimated) either takes far too long (over a day), or fails with computationally singular errors. So a) are there any parallel implementations of optim() (in R or otherwise) and b) how can I make my function more robust? (I've already resorted to using bounded parameters and log transformations, which has helped to some degree) Thanks, -Aaron library(stats4); d - data.frame( ix=c(0,1,2,3,4,5,6,7), ct=c(1000,9609,18403,2617,8237,3619,5520,18908), A=c(0,1,0,1,0,1,0,1), B=c(0,0,1,1,0,0,1,1), C=c(0,0,0,0,1,1,1,1) ); ct - round(logb(length(d$ix), 2)) ll - function( th=0.5, a1=log(0.5), a2=log(0.5), a3=log(0.5), b1=log(0.5), b2=log(0.5), b3=log(0.5) ) { a - exp(sapply(1:ct, function (x) { get(paste(a, x, sep=)) })); b - exp(sapply(1:ct, function (x) { get(paste(b, x, sep=)) })); s - -sum( d$ct * log( sapply( d$ix, function (ix, th, a, b) { x - d[ix+1,3:(ct+2)] (th * prod((b ^ (1-x)) * ((1-b) ^ x))) + ((1-th) * prod((a ^ x) * ((1-a) ^ (1-x }, th, a, b ) ) ); if (!is.finite(s)) stop(cat(th, a, b, s, sep=\n)); s; } ml - mle(ll, lower=c(1e-10, rep(log(1e-10), 2*ct)), upper=c(1 - 1e-10, rep(log(1 - 1e-10), 2*ct)), method=L-BFGS-B, ); __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] New user
Hi all R users. I'm just starting to use R, and I'm still a little lost. I'd like to analyse some data following the path analysis aproach. I'd like to know if there is some package for implement this kind of analysis. Many thanks Rodrigo Sala Posgrado en Producción Vegetal E.E.A. INTA Balcarce Ruta Nacional 226 km 73.5 (7620) Balcarce, Buenos Aires, Argentina 100mb gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo ¡Tenelo ya! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] New user
Have you considered sem = structural equation models, which you may know is another name for path analysis? hope this helps. spencer graves p.s. PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html. It might help you answer questions like this yourself. Rodrigo Sala wrote: Hi all R users. I'm just starting to use R, and I'm still a little lost. I'd like to analyse some data following the path analysis aproach. I'd like to know if there is some package for implement this kind of analysis. Many thanks Rodrigo Sala Posgrado en Producción Vegetal E.E.A. INTA Balcarce Ruta Nacional 226 km 73.5 (7620) Balcarce, Buenos Aires, Argentina 100mb gratis, Antivirus y Antispam Correo Yahoo!, el mejor correo web del mundo ¡Tenelo ya! [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lme: extract variance estimate
I'm actually replying to Stephen's message but I had already deleted it before I read Spencer's message. (I'm on a slow connection and I am simultaneously downloading a big file so I am trying to optimize bandwidth, sometimes with unfortunate results.) In the previous message the author showed the slots [EMAIL PROTECTED] (a numeric scalar), [EMAIL PROTECTED] (a list of corrmatrix objects), and [EMAIL PROTECTED] (logical). The quantity that you are looking for is calculated as unlist(lapply([EMAIL PROTECTED], function(x, scal) [EMAIL PROTECTED], scal = ifelse([EMAIL PROTECTED], [EMAIL PROTECTED], 1.))) plus-or-minus a parenthesis or two. The reSumry contains the relative variance-covariance matrices in the form of correlations and standard deviations. Some models, such as lme models, use a scale parameter. Others, such as binomial generalized linear mixed models, do not. That is why the estimate of the scale parameter is stored separately along with a flag indicating whether scaling should be used. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to pass strings to functions? [once once more, now With content I hope...]
On Thu, 8 Jul 2004, Gijs Plomp wrote: Dear expeRts, I fail to succesfully pass strings to functions. It comes down to the observation that plot(someVariable,anotherVariable) works fine, but x - someVariable y - anotherVariable plot(x,y) does not. Does this have something to do with the returned value of x being /someVariable/ and not /someVariable/, i.e. without the quotation marks? Is there any way to work around this? This is in the FAQ. -thomas __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html