[R] problems in limma
Dear list members, I am analysing my microarray data using limma package. Now I encounter several problems. Looking forward to your suggestions! Question 1: During the process of background correction using method=normexp, four warning messages appeared as NaNs produced in: log(x) (as you can see in the program posted below). What does that mean? How will it effect the final result? How could it be settled? Question 2: On my microarray, every probe has two replicates.During the process of duplicateCorrelation, two warnings appear as Too much damping - convergence tolerance not achievable (as you also can see in the program posted below). What does it mean? Is there anything wrong with my data? Question 3: How to construct the design matrix is a puzzle to me. Here I constructed the design matrix using the function modelMatrix and the object targets. However, I am not sure whether it is constructed appropriately. Looking forward to your suggestions. (Additional info about my experimental design. Uppercase and lowercase words in the R object targets (see below in the posted program) have different meanings. The locusts on the plain [PLAIN] was treated [plain] in a simulated plateau environment while the locusts on the plateau [PLATEAU] was treated [plateau] in a simulated plain environment. They experienced different treatments. I think it is not a complete factorial design. Therefore I did not choose the design matrix for factorial designs. However, I do not know whether what I chose is appropriate.) Question 4: All in all, I wonder whether the differentially expressed genes produced via the posted program are convincing. Will the above-mentioned warnings affect the reliability of the final result? Can I continue to the next step? Thanks! Dejian Zhao ++ Program Starts + library(limma) library(statmod) #duplicateCorrelation requires this package. targets-readTargets() targets Cy3 Cy5 FileName Date 1PLAIN PLATEAU Locust 186.gpr 2006-5-31 2PLAIN PLATEAU Locust 187.gpr 2006-5-31 3PLAIN PLATEAU Locust 188.gpr 2006-5-31 4PLAIN PLATEAU Locust 189.gpr 2006-5-31 5PLAIN PLATEAU Locust 190.gpr 2006-5-31 6PLAIN PLATEAU Locust 191.gpr 2006-5-31 7plain PLAIN Locust 192.gpr 2006-6-6 8plain PLAIN Locust 193.gpr 2006-6-6 9plain PLAIN Locust 194.gpr 2006-6-6 10 plain PLAIN Locust 195.gpr 2006-6-6 11 plain PLAIN Locust 196.gpr 2006-6-6 12 plain PLAIN Locust 197.gpr 2006-6-6 13 plateau PLATEAU Locust 198.gpr 2006-6-8 14 plateau PLATEAU Locust 199.gpr 2006-6-8 15 plateau PLATEAU Locust 200.gpr 2006-6-8 16 plateau PLATEAU Locust 201.gpr 2006-6-8 17 plateau PLATEAU Locust 202.gpr 2006-6-8 18 plateau PLATEAU Locust 203.gpr 2006-6-8 RG-read.maimages(targets,source=genepix,wt.fun=wtflags(0.1)) Read Locust 186.gpr Read Locust 187.gpr Read Locust 188.gpr Read Locust 189.gpr Read Locust 190.gpr Read Locust 191.gpr Read Locust 192.gpr Read Locust 193.gpr Read Locust 194.gpr Read Locust 195.gpr Read Locust 196.gpr Read Locust 197.gpr Read Locust 198.gpr Read Locust 199.gpr Read Locust 200.gpr Read Locust 201.gpr Read Locust 202.gpr Read Locust 203.gpr RG$genes-readGAL() spottypes-readSpotTypes() spottypes SpotType ID Name Color 1 gene ** black 2 blank Blank* brown 3 buffer*sc* blue 4 rice Os026** green 5 beta-actin Beta**red 618S 18S** yellow 7 GAPDH GAPDH** purple RG$genes$Status-controlStatus(spottypes,RG) Matching patterns for: ID Name Found 19200 gene Found 96 blank Found 220 buffer Found 192 rice Found 192 beta-actin Found 96 18S Found 96 GAPDH Setting attributes: values Color RG.b-backgroundCorrect(RG,method=normexp,offset=0) Corrected array 1 Corrected array 2 Corrected array 3 Corrected array 4 Corrected array 5 Corrected array 6 Corrected array 7 Corrected array 8 Corrected array 9 Corrected array 10 Corrected array 11 Corrected array 12 Corrected array 13 Corrected array 14 Corrected array 15 Corrected array 16 Corrected array 17 Corrected array 18 Warning messages: 1: NaNs produced in: log(x) 2: NaNs produced in: log(x) 3: NaNs produced in: log(x) 4: NaNs produced in: log(x) w-modifyWeights(RG$weights,RG$genes$Status,c(rice,beta-actin,18S,GAPDH),c(0.1,2,2,2)) MA.p-normalizeWithinArrays(RG.b,weights=w,iterations=6) design-modelMatrix(targets,ref=PLAIN) Found unique target names: plain PLAIN plateau PLATEAU design plain plateau PLATEAU [1,] 0 0 1 [2,] 0 0 1 [3,] 0 0 1 [4,] 0 0 1 [5,] 0 0 1 [6,] 0 0 1 [7,]-1 0 0 [8,]-1 0 0 [9,]-1 0 0 [10,]-1 0 0 [11,]-1 0 0 [12,]-1 0 0 [13,] 0 -1 1 [14,] 0 -1 1 [15,] 0 -1 1 [16,] 0 -1 1 [17,] 0
[R] correlation and matrix
Dear everyone, I am new in R and I've got difficulties in realizing the following tasks: -I have variables (factors) with different numbers of levels, either 1, 2 or 3. -I have a matrix containing these 204 factors and I have to correlate them by groups of 4 variables. -I have to delete the factors just having one level ( because when correlating one-level factors, the output is NA) here is my code: lst-seq(1, 204, by=12) % there are 12 factors for 17 natural resources for (n in lst) { Mx- matrix(0, byrow = F, ncol = 4, nrow=nrow(dta)) % I extract the 4 factors I have to correlate and I'd like to do it for each n {if (nlevels(dta[,n+4])!=1) Mx[,1]-dta[,n+4] else Mx[,1]-NA} {if (nlevels(dta[,n+5])!=1) Mx[,2]-dta[,n+5] else Mx[,2]-NA} {if (nlevels(dta[,n+7])!=1) Mx[,3]-dta[,n+7] else Mx[,3]-NA} {if (nlevels(dta[,n+8])!=1) Mx[,4]-dta[,n+8] else Mx[,4]-NA} p-0% I compute the number of non - NA columns and I'd like to delete the Na columns from that matrix for (i in 1:4) { if(!is.na(sum(Mx[,i])0)) p-p+1 } print(p) {if (p==0 | p==1) stop(computation impossible) else { r-0 for (i in 1:4) { if(is.na(sum(Mx[,i])0)) r-i } print(r) print(cor((as.matrix(Mx[,-r])), use=complete.obs, method=spearman)) } } } %The problem is the last step doesn't work for p==2. In fact, it seems the loop for doesn't work either. I hope it is clear enough and I thank you in advance for your help. Nathalie __ 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 combine data of several csv-files
Hello, I'm looking for a solution for the following problem: 1) I have a folder with several csv files; each contains a set of measurement values 2) The measurements of each file belong to a position in a two dimensional matrix (lets say B02.csv belongs to position 2,2 3) The size of the matrix is fix 4) I cannot assure to have a csv file for each position 5) Each position belongs to one category; This information is available in a file (means 2,2 and 2,3 may belong to category c1; 3,2 and 3,3 may belong to category c2) Now, I process each available file and get a vector of 6 values or NA back. The aim is to calculate mean and sd for vectors (element wise) coming from the same category (means if vec1 - c(1,2,3,4,5,6) and vec2 - c(6,7,8,9,10,11) belong to the same category, I would like to get mean - c(3.5, 4.5, 5.5, 6.5, 7.5, 8.5)) ... but I'm not sure how to proceed. I end up with a list containing these vectors for each processed file and I don't know how to combine them easily... Does anybody have a suggestion for me? What I've got so far: folder - choose.dir(getwd(), Choose folder containing csv files) setwd(folder) rowString - LETTERS[1:8]; cols - 12 mat - outer(rowString, formatC(seq(2,length=cols), flag = 0, width = 2), paste, sep = ) mat - paste(mat, .csv, sep = _) layoutfilename - file.choose() layoutfile - read.csv(layoutfilename, sep=;, header=F, na.strings = ) classmatrix - sapply(layoutfile,as.character) classes - factor(classmatrix) colnames(classmatrix) - c(1:cols) rownames(classmatrix) - rowString ret - sapply(mat, calcHist) __ 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] Create Strings of Column Id's
Great, That did the trick,thanks. regards Tom jholtman wrote: Is this what you want: paste(-, paste(colnames(MyMatrix)[COL], collapse='-'), sep='') [1] -E-T On 7/26/07, Tom.O [EMAIL PROTECTED] wrote: Does anyone know how this is don? I have a large matrix where I extract specific columns into txt files for further use. To be able to keep track of which txt files contain which columns I want to name the filenames with the column Id's. The most basic example would be to use an for() loop together with paste(), but the result is blank. Not even NULL. this is the concept of thecode i use: for example MyMatrix - matrix(NA,ncol=4,nrow=1,dimnames=list(NULL,c(E,R,T,Y))) COL - c(1,3) # a vector of columns I want to extract, Filename - NULL # the starting variable, so I can use paste Filename - for(i in colnames(MyMatrix)[COL]) {paste(Filename,-,i,sep=)} The result is -T, but I want it to be -E-T Anyone have a clue? Thanks Tom -- View this message in context: http://www.nabble.com/Create-Strings-of-Column-Id%27s-tf4153354.html#a11816439 Sent from the R help mailing list archive at Nabble.com. __ 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? __ 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. -- View this message in context: http://www.nabble.com/Create-Strings-of-Column-Id%27s-tf4153354.html#a11859539 Sent from the R help mailing list archive at Nabble.com. __ 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] apply, lapply and data.frame in R 2.5
Hello everyone, A recent (in 2.5 I suspect) change in R is giving me trouble. I want to apply a function (tolower) to all the columns of a data.frame and get a data.frame in return. Currently, on a data.frame, both apply (for arrays) and lapply (for lists) work, but each returns its native class (resp. matrix and list): apply(mydat,2,tolower) # gives a matrix lapply(mydat,tolower) # gives a list and sapply(mydat,tolower) # gives a matrix If I remember well, apply did not used to work on data.frames and lapply returned a data.frame when it was provided with one, with the same properties (columns classes etc). At least this is what my code written with R 2.4.* suggests. The solution would be: as.data.frame(apply(mydat,2,tolower)) or as.data.frame(lapply(mydat,tolower)) But this does not keep columns attributes (all columns are reinterpreted, for example strings are converted to factors etc). For my particular use stringsAsFactors=FALSE does what I need, but I am wondering wether there is a more general solution to apply a function on all elements of a data.frame and get a similar data.frame in return. Indeed data.frames are probably the most common object in R and applying a function to each of its columns/variables appears to me as something one would want to do quite often. Thank you in advance. JiHO --- http://jo.irisson.free.fr/ __ 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] Slightly OT - use of R
I am trying to get a measure of how R compares in usage as a statistical platform compared to other software. I would guess it is the most widely used among statisticians at least by virtue of it being open source. But is there any study to which I can refer? By asking this list I am not exactly adopting a rigorous approach! Best wishes John John Logsdon Try to make things as simple Quantex Research Ltd, Manchester UK as possible but not simpler [EMAIL PROTECTED] [EMAIL PROTECTED] +44(0)161 445 4951/G:+44(0)7717758675 www.quantex-research.com __ 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] Call R program from C++ code
Writing R Extensions manual contains chapters dedicated to parsing and evaluating of the R extensions from C. Also, I vaguely remember I've seen something like Embedding R somewhere in manuals. R can be compiled as a shared library object, that you can dynamically load from your application and use its functions. R doesn't have a compiler, it's the interpreted language. However, it can parse a character string representing an expresstion and transform it into the internal form, ready for evaluation. Feng Qiu wrote: Hi All: I'm developing an application program using C++. From my C++ code, I would call some R program I have written. I' wondering if R provide some compiler that can compile R program into executable program. I searched R-help, there are a lot of posts talking about writing C++ code in R program, but few about calling R from C++. I might be wrong that R doesn't have complier. What I'm trying to do is to call R program from C++ code. Any help is highly appreciated! -- View this message in context: http://www.nabble.com/Call-R-program-from-C%2B%2B-code-tf4167083.html#a11860280 Sent from the R help mailing list archive at Nabble.com. __ 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] Slightly OT - use of R
On 30-Jul-07 08:28:15, John Logsdon wrote: I am trying to get a measure of how R compares in usage as a statistical platform compared to other software. I would guess it is the most widely used among statisticians at least by virtue of it being open source. But is there any study to which I can refer? By asking this list I am not exactly adopting a rigorous approach! I don't know about that -- my own expectation would be that serious users of R are likely to be subscribers to the list. So maybe a good answer to your question would be the number of subscribers (which I'm sure Martin Maechler can find out). Of course, some people will have subscribed under more than one email address, so that would somewhat over-estimate the number of people who subscribe. But it can be traded off (to a somewhat unknown extent) against R users who do not subscribe. More to the point, though, is what you mean by usage. If you simply mean people who use, that's a matter of counting (one way or another). But there's use and use. There's a lot of what I call SatNav Statistics being done, and I would guess that SatNav statisticians tend to go for the commercial products, since these have bigger and brighter displays, and the more mellifluous and reassuring voice-overs. (And never mind that the voice instructs you to turn left, at the level-crossing, onto the railway line). Most serious R users, I tend to think, are more likely to pull into a layby and unfold large-scale maps. And, when the need arises, they will get out and push. So, in widely used among statisticians, it depends on what you mean by statisticians. Where you will will probably get extra value from the R list is that many of our people will have extensive and very professional experience, not only with R, but with many of the other available packages, and be best placed to provide serious and thoughtful comparisons. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 30-Jul-07 Time: 10:18:21 -- XFMail -- __ 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] Matrix nesting (was Re: Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset.)
Hi !-- @page { size: 21cm 29.7cm; margin: 2cm } P { margin-bottom: 0.21cm } -- I would like to nest matrices, is there a way of doing so, I am getting “number of items to replace is not a multiple of replacement length” errors (probably R is trying to flatten the matrix into a vector and complains if the vector is larger than 1 element during the insert) I have a matrix (see below) in which I would like to place one other matrices in to each k[2,i] position (where i is value between 1 to 4) Why – each value in k[1,i] may represent several (1or more) key-value results which I would like to capture in the corresponding k[2,i] element. k [,1] [,2] [,3] [,4] myVariableNames PR10 PR11 PR12 PR13 x2 00 00 Allan. - Original Message From: Allan Kamau [EMAIL PROTECTED] To: jim holtman [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Saturday, July 28, 2007 2:48:47 PM Subject: Re: [R] Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset. Hi Jim, The problem description. I am trying to identify mutations in a given gene from a particular genome (biological genome sequence). I have two CSV files consisting of sequences. One file consists of reference (documented,curated accepted as standard) sequences. The other consists of sample sequences I am trying to identify mutations within. In both files the an individual sequence is contained in a single record, it’s amino acid residues ( the actual sequence of alphabets each representing a given amino acid for example “A” stands for “Alanine”, “C” for Cysteine and so on) are each allocated a single field in the CSV file. The sequences in both files have been well aligned, each contain 115 residues with the first residue is contained in the field 5. The fields 1 to 4 are allocated for metadata (name of sequence and so on). My task is to compile a residue occurrence count for each residue present in a given field in the reference sequence dataset and use this information when reading each sequence in the sample dataset to identify a mutation. For example for position 9 of the sample sequence “bb” a “P” is found and according to our reference sequence dataset of summaries, at position 9 “P” may not even exist or may have an occurrence of 10% or so will be classified as mutation, (I could employ a cut of parameter for mutation classification). Allan. --- jim holtman [EMAIL PROTECTED] wrote: results=()#character() myVariableNames=names(x.val) results[length(myVariableNames)]-NA for (i in myVariableNames){ results[i]-names(x.val[[i]])# this does not work it returns a NULL (how can i convert this to x.val$somevalue ? ) } On 7/27/07, Allan Kamau [EMAIL PROTECTED] wrote: Hi All, I am having difficulties finding a way to find a substitute to the command names(v.val$PR14) so that I could generate the command on the fly for all PR14 to PR200 (please see the previous discussion below to understand what the object x.val contains) . I have tried the following results=()#character() myVariableNames=names(x.val) results[length(myVariableNames)]-NA for as.vector(unlist(strsplit(str,,)),mode=list) +results[i]-names(x.val$i)# this does not work it returns a NULL (how can i convert this to x.val$somevalue ? ) } Allan. - Original Message From: Allan Kamau [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Thursday, July 26, 2007 10:03:17 AM Subject: Re: [R] Obtaining summary of frequencies of value occurrences for a variable in a multivariate dataset. Thanks so much Jim, Andaikalavan, Gabor and others for the help and suggestions. The solution will result in a matrix containing nested matrices to enable each variable name, each variables distinct value and the count of the distinct value to be accessible individually. The main matrix will contain the variable names, the first level nested matrices will consist of the variables unique values, and each such variable entry will contain a one element vector to contain the count or occurrence frequency. This matrix can now be used in comparing other similar datasets for variable values and their frequencies. Building on the input received so far, a probable solution in building the matrix will include the following. 1)I reading the csv file (containing column headers) my_data=read.table(path/to/my/data.csv,header=TRUE,sep=,,dec=.,fill=TRUE) 2)I group the values in each variable producing an occurrence count(frequency) x.val-apply(my_data,2,table) 3)I obtain a vector of the names of the variables in the table names(x.val) 4)Now I make use of the names (obtained in step 3) to obtain a vector of distinct values in a given variable (in the example below the variable name
Re: [R] g++ verfsion
Hi, Li, Thanks for reply. It is strange that I used RBGL_1.6.0 successfully on the same linux system with R 2.3.1 before! After trying to install R 2.5.1, the RBGL_1.12.0 failed to be installed. Then, I uninstalled R. Delete the directory R/lib/. Installed R.2.3.1 again. And run getBioC1.8.5 for R 2.3.1 to download the three packages graph_1.10.6, RBGL_1.12.0 and Ruuid_1.10.0. But still failed as: .. boost::vec_adj_list_vertex_id_mapboost::propertyboost::vertex_color_t, boost::default_color_type, boost::no_property, size_t)' make: *** [interfaces.o] Error 1 chmod: failed to get attributes of `/usr/local/lib/R/library/RBGL/libs/*': No such file or directory ERROR: compilation failed for package 'RBGL' ** Removing '/usr/local/lib/R/library/RBGL' % Is it maybe because I use redhat9 with libxml2-2.5.4-1, which doesn't neet the not meets the requirment of RBGL_1.12.0 ? But I do not know how to updata them, even after downloading the file libxml2-2.5.4-3.rh9.i386.rpm, I failed to install it: [EMAIL PROTECTED] software]# rpm -i libxml2-2.5.4-3.rh9.i386.rpm file /usr/bin/xmlcatalog from install of libxml2-2.5.4-3.rh9 conflicts with file from package libxml2-2.5.4-1 file /usr/bin/xmllint from install of libxml2-2.5.4-3.rh9 conflicts with file from package libxml2-2.5.4-1 file /usr/lib/libxml2.so.2.5.4 from install of libxml2-2.5.4-3.rh9 conflicts with file from package libxml2-2.5.4-1 file /usr/share/man/man1/xmlcatalog.1.gz from install of libxml2-2.5.4-3.rh9 conflicts with file from package libxml2-2.5.4-1 file /usr/share/man/man1/xmllint.1.gz from install of libxml2-2.5.4-3.rh9 conflicts with file from package libxml2-2.5.4-1 file /usr/share/man/man3/libxml.3.gz from install of libxml2-2.5.4-3.rh9 conflicts with file from package libxml2-2.5.4-1 % FOr redhat9, Is it possible to updat gcc? Thanks, Xinan [EMAIL PROTECTED] wrote: This gcc is VERY old, we saw some problems in template handling with different version of g++. I would suggest to try a newer version of g++ and see what happens. Li and, [EMAIL PROTECTED] getBioC2.5-R2.5.1]# g++ --version g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) Copyright (C) 2002 Free Software Foundation, Inc. tks, xinan __ 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 with ROC curve
Hi I'm new to stats and R, so can you please help me or guide me building ROC curve in an elaborate way with codes I loaded ROCR package, but I'm not sure how to use it. Requirement To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. It would be really great if you could help me with this. Thanks Rithesh M Mohan [[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] random number generator in batch jobs
Dear sir, I want to submit R batch jobs (e.g. 5) under the linux cluster by the script file do_mul. The script file do_mul #!/bin/bash export var for var in $(seq 1 5) do qsub -v var do_test done exit 0 Through do_mul, 5 do_test script files are submitted to the cluster. The script file do_test: #!/bin/bash -l #PBS -l ncpus=1 #PBS -l walltime=0:05:00 cd $PBS_O_WORKDIR mkdir test$var cd test$var module load R/2.5.0 R --vanilla test exit 0 The content in R file test is : rm(list=ls(all=TRUE)) sample(10) I expect to have different samples each time. However, for these 5 replications, the first 3 jobs giving me the same samples and the last 2 are the same. I'm confused because I already used R --vanilla to avoid loading same workspace each time and rm(list=ls(all=TRUE)) to remove the same random seed each time. Why do same samples still happen among 5 replications? Does anybody have some ideas to solve this problem? Looking forward to your reply, thanks. Regards, Jiqiu Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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] correlation and matrix
it should be smth like that: apply(sapply(seq(1, 204, by=12), seq, length=4), 2, function(x) { M - dta[,x] z - sapply(M, nlevels) # if dta is a dataframe if (sum(z==1)3) cor(as.matrix(M[,z!=0]), use=comp, method=spear) else NA }) 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 [EMAIL PROTECTED] a écrit : Dear everyone, I am new in R and I've got difficulties in realizing the following tasks: -I have variables (factors) with different numbers of levels, either 1, 2 or 3. -I have a matrix containing these 204 factors and I have to correlate them by groups of 4 variables. -I have to delete the factors just having one level ( because when correlating one-level factors, the output is NA) here is my code: lst-seq(1, 204, by=12) % there are 12 factors for 17 natural resources for (n in lst) { Mx- matrix(0, byrow = F, ncol = 4, nrow=nrow(dta)) % I extract the 4 factors I have to correlate and I'd like to do it for each n {if (nlevels(dta[,n+4])!=1) Mx[,1]-dta[,n+4] else Mx[,1]-NA} {if (nlevels(dta[,n+5])!=1) Mx[,2]-dta[,n+5] else Mx[,2]-NA} {if (nlevels(dta[,n+7])!=1) Mx[,3]-dta[,n+7] else Mx[,3]-NA} {if (nlevels(dta[,n+8])!=1) Mx[,4]-dta[,n+8] else Mx[,4]-NA} p-0% I compute the number of non - NA columns and I'd like to delete the Na columns from that matrix for (i in 1:4) { if(!is.na(sum(Mx[,i])0)) p-p+1 } print(p) {if (p==0 | p==1) stop(computation impossible) else { r-0 for (i in 1:4) { if(is.na(sum(Mx[,i])0)) r-i } print(r) print(cor((as.matrix(Mx[,-r])), use=complete.obs, method=spearman)) } } } %The problem is the last step doesn't work for p==2. In fact, it seems the loop for doesn't work either. I hope it is clear enough and I thank you in advance for your help. Nathalie __ 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.
[R] Bind together two vectors of different length...
Dear everyone, I've got difficulties in realizing the following task: I have two vectors: A - c(1:10) B- seq(1,10,2) Now I want to make a table form vectors A and B as rows, and if a value of A isn't present B, then I want to put a N/A symbol in it: Output should look like this: 1 2 3 4 5 6 7 8 9 10 1 0 3 0 5 0 7 0 9 0 How can I do this in R? Thank you. -- Andris Jankevics Assistant Department of Medicinal Chemistry Latvian Institute of Organic Synthesis Aizkraukles 21, LV-1006, Riga, Latvia __ 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] Slightly OT - use of R
On Mon, 30 Jul 2007, [EMAIL PROTECTED] wrote: On 30-Jul-07 08:28:15, John Logsdon wrote: I am trying to get a measure of how R compares in usage as a statistical platform compared to other software. I would guess it is the most widely used among statisticians at least by virtue of it being open source. I don't think that is the main reason. Most of the R users I know migrated from commercial statistical software for reasons other than cost. (Cross-platform availability has been one major reason.) But is there any study to which I can refer? By asking this list I am not exactly adopting a rigorous approach! I don't know about that -- my own expectation would be that serious users of R are likely to be subscribers to the list. So maybe a good answer to your question would be the number of subscribers (which I'm sure Martin Maechler can find out). Of course, some people will have subscribed under more than one email address, so that would somewhat over-estimate the number of people who subscribe. But it can be traded off (to a somewhat unknown extent) against R users who do not subscribe. I think it would be a seriously biased estimate. Few of our hundreds of student users will be subscribed to R-help (since their first port of call for help is local). Also, we get quite a lot of postings via the gmane and nabble gateways. More to the point, though, is what you mean by usage. If you simply mean people who use, that's a matter of counting (one way or another). But there's use and use. Indeed. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] apply, lapply and data.frame in R 2.5
On Mon, 30 Jul 2007, jiho wrote: Hello everyone, A recent (in 2.5 I suspect) change in R is giving me trouble. I want to apply a function (tolower) to all the columns of a data.frame and get a data.frame in return. Currently, on a data.frame, both apply (for arrays) and lapply (for lists) work, but each returns its native class (resp. matrix and list): apply(mydat,2,tolower)# gives a matrix lapply(mydat,tolower) # gives a list and sapply(mydat,tolower) # gives a matrix which is exactly what R 2.0.0 did, so no recent(ish) change at all. If I remember well, apply did not used to work on data.frames and lapply returned a data.frame when it was provided with one, with the same properties (columns classes etc). At least this is what my code written with R 2.4.* suggests. apply has coerced data frames for many years and lapply always returned a list. The solution has always been mydat[] - lapply(mydat,tolower) The solution would be: as.data.frame(apply(mydat,2,tolower)) or as.data.frame(lapply(mydat,tolower)) But this does not keep columns attributes (all columns are reinterpreted, for example strings are converted to factors etc). For my particular use stringsAsFactors=FALSE does what I need, but I am wondering wether there is a more general solution to apply a function on all elements of a data.frame and get a similar data.frame in return. Indeed data.frames are probably the most common object in R and applying a function to each of its columns/variables appears to me as something one would want to do quite often. Thank you in advance. JiHO --- http://jo.irisson.free.fr/ __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Odp: Bind together two vectors of different length...
Hi [EMAIL PROTECTED] napsal dne 30.07.2007 12:09:59: Dear everyone, I've got difficulties in realizing the following task: I have two vectors: A - c(1:10) B- seq(1,10,2) Now I want to make a table form vectors A and B as rows, and if a value of A isn't present B, then I want to put a N/A symbol in it: Output should look like this: 1 2 3 4 5 6 7 8 9 10 1 0 3 0 5 0 7 0 9 0 How can I do this in R? in your particular case rbind(A,A*(A %in% B)) will give you such output, but 0 is not NA thereofore AO-A*(A %in% B) AO[!(A %in% B)]-NA rbind(A, AO) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] A 12345678910 AO1 NA3 NA5 NA7 NA9NA gives you such output but with NA values instead of zeroes Regards Petr Thank you. -- Andris Jankevics Assistant Department of Medicinal Chemistry Latvian Institute of Organic Synthesis Aizkraukles 21, LV-1006, Riga, Latvia __ 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.
Re: [R] random number generator in batch jobs
Have you read the help page? Initially, there is no seed; a new one is created from the current time when one is required. Hence, different sessions will give different simulation results, by default. Thus if you choose to launch processes on different machines at the same time you will get the same random number stream. Running random number streams for parallel computation is a (very) specialized topic and you need to be aware of the literature. I will point out packages rsprng and accuracy (function runifS). On Mon, 30 Jul 2007, Jiqiu Cheng wrote: Dear sir, I want to submit R batch jobs (e.g. 5) under the linux cluster by the script file do_mul. The script file do_mul #!/bin/bash export var for var in $(seq 1 5) do qsub -v var do_test done exit 0 Through do_mul, 5 do_test script files are submitted to the cluster. The script file do_test: #!/bin/bash -l #PBS -l ncpus=1 #PBS -l walltime=0:05:00 cd $PBS_O_WORKDIR mkdir test$var cd test$var module load R/2.5.0 R --vanilla test exit 0 The content in R file test is : rm(list=ls(all=TRUE)) sample(10) I expect to have different samples each time. However, for these 5 replications, the first 3 jobs giving me the same samples and the last 2 are the same. I'm confused because I already used R --vanilla to avoid loading same workspace each time and rm(list=ls(all=TRUE)) to remove the same random seed each time. Why do same samples still happen among 5 replications? Does anybody have some ideas to solve this problem? Looking forward to your reply, thanks. Regards, Jiqiu Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] Slightly OT - use of R
John Logsdon j.logsdon at quantex-research.com writes: I am trying to get a measure of how R compares in usage as a statistical platform compared to other software. I would guess it is the most widely used among statisticians at least by virtue of it being open source. But is there any study to which I can refer? By asking this list I am not exactly adopting a rigorous approach! Not sure what your definition of usage is in this instance (user-base v's usability v's reliability/accuracy) but the following may be of interest... Kellie B. Keeling and Robert J. Pavur, A comparative study of the reliability of nine statistical software packages, Computational Statistics Data Analysis, Volume 51, Issue 8, 1 May 2007, Pages 3811-3831. (http://www.sciencedirect.com/science/article/B6V8V-4JHMGWJ-1/2/77a29a95c2071997f13fcca7267711d1) There is also some discussion in the R-help archive, and a small amount scattered around in the statalist archives (the two statistical software mailing lists to which I subscribe). Search the R-help list at http://search.r-project.org/nmz.html and statalist archives at http://www.stata.com/statalist/archvies/ HTH's Neil In mathematics you don't understand things. You just get used to them. - Johann von Neumann Email - [EMAIL PROTECTED] / [EMAIL PROTECTED] Website - http://slack.ser.man.ac.uk/ Photos - http://www.flickr.com/photos/slackline/ __ 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] ROC curve in R
Hi Ritesh ***please note Ritesh always mark a copy to the R-help mailing list :) *** Please visit this link to get help in R http://rocr.bioinf.mpi-sb.mpg.de/ROCR_Talk_Tobias_Sing.ppt#384,8,Examples (2/8): Precision/recall curves futher :) what do you mean by PSA and cohort :) after some googling i got this co·hort(khôrt) n. 1. A group or band of people. 2. A companion or associate. 3. A generational group as defined in demographics, statistics, or market research: The cohort of people aged 30 to 39 . . . were more conservative American Demographics. 4. a. One of the 10 divisions of a Roman legion, consisting of 300 to 600 men. b. A group of soldiers. and for PSA i got Prostate-specific antigen. A substance produced by the prostate that may be found in an increased amount in the blood of men who have prostate cancer, benign prostatic hyperplasia, or infection or inflammation of the prostate. Now please clarify what you want to model :) please dont take it otherwise i am not from biology field. Please clarify :) Regards, Gaurav Yadav +++ Assistant Manager, CCIL, Mumbai (India) Mob: +919821286118 Email: [EMAIL PROTECTED] Bhagavad Gita: Man is made by his Belief, as He believes, so He is Rithesh M. Mohan [EMAIL PROTECTED] 07/30/2007 01:30 PM To [EMAIL PROTECTED] cc Subject Re: [R] ROC curve in R Hi Gaurav, Need your help, Iâm relatively new to R or even stats, so can you please give me step by step details to get ROC curve in R. Requirement. To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. It would be really great if you could help me with this. Thanks and Regards Rithesh DISCLAIMER AND CONFIDENTIALITY CAUTION: This message and any attachments with it (the message) are confidential and intended solely for the addressees. Unauthorized reading, copying, dissemination, distribution or disclosure either whole or partial, is prohibited. If you receive this message in error, please delete it and immediately notify the sender. Communicating through email is not secure and capable of interception, corruption and delays. Anyone communicating with The Clearing Corporation of India Limited (CCIL) by email accepts the risks involved and their consequences. The internet can not guarantee the integrity of this message. CCIL shall (will) not therefore be liable for the message if modified. The recipient should check this email and any attachments for the presence of viruses. CCIL accepts no liability for any damage caused by any virus transmitted by this email. [[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] Bind together two vectors of different length...
[Andris Jankevics] I have two vectors: A - c(1:10) B- seq(1,10,2) Now I want to make a table form vectors A and B as rows, and if a value of A isn't present B, then I want to put a N/A symbol in it: Output should look like this: 1 2 3 4 5 6 7 8 9 10 1 0 3 0 5 0 7 0 9 0 How can I do this in R? Either of: A[!A %in% B] - NA A[!A %in% B] - 0 depending on what you want your N/A symbol to be. -- François Pinard http://pinard.progiciels-bpi.ca __ 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 combine data of several csv-files
Hello, sorry for this confusion but I don't know a better way to explain... I have no problems to read in the files and to process them. I end up with a list of results like this: ret $A02.csv [1] NA $B02.csv [1] 89.130435 8.695652 2.173913 0.00 0.00 0.00 9.892473 $C02.csv [1] 86.842105 10.526316 2.631579 0.00 0.00 0.00 10.026385 $D02.csv [1] 85.00 10.00 5.00 0.00 0.00 0.00 4.474273 $E02.csv [1] 70.786517 13.483146 7.865169 5.617978 2.247191 0.00 12.125341 $F02.csv [1] 70.8 14.16667 10.0 2.5 2.5 0.0 17.26619 $G02.csv [1] 64.772727 13.636364 7.954545 11.363636 2.272727 0.00 12.735166 $H02.csv [1] NA $A03.csv [1] NA and I have a matrix with categories like this: classmatrix 1 2 A NA NA B NA cat1 C NA cat1 D NA cat1 E NA cat2 F NA cat2 G NA cat2 H NA NA Now, I'm looking for a way to calculate the mean element wise for all results coming from the same category: in this case the mean of the elements: $B02.csv $C02.csv $D02.csv (belonging to cat1) I just don't know, how to combine the result list with the categories... Does it become clearer? Probably, I try to provide a simple example but this will take some time to prepare... Thanks anyway! Antje 8rino-Luca Pantani schrieb: I'm unclear to what it is your problem. Import files into data frame? Combine them in one dataframe? Some (written) examples of the files would help people to help you out. An example on how to get help better and faster I have several csv files in the following form V1 V2 1 4 0.3 56 V1 V2 2.5 25 4.5 45 . I would like to import them in only one dataframe, and then recode a column in order to get V1 V2 V3 1 4 file1 0.3 56 file1 2.5 25 file2 4.5 45 file2 . Antje ha scritto: Hello, I'm looking for a solution for the following problem: 1) I have a folder with several csv files; each contains a set of measurement values __ 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] [R-pkgs] New versions for the distr-family of packages and of package startupmsg
We would like to announce the availability on CRAN (with possibly a minor delay until on every mirror) of new versions of our packages in the distrXXX-family (version 1.9), i.e.; distr, distrEx, distrSim, distrTEst, and distrDoc as well as of package for managing startup messages, startupmsg (0.5). [all of them require R = 2.2.0] - * Changes *** of distr (1.9), distrEx (1.9), distrSim (1.9), distrTEst (1.9), distrDoc (1.9) * - There are major changes in distr and distrEx from this release on; the more important ones can be inspected at http://www.uni-bayreuth.de/departments/math/org/mathe7/DISTR and the pages linked to on this page. Special thanks go to Spencer Graves for spotting some errors in 1.8 (which should be fixed by now) and to G.Jay Kerns for detecting some further bugs and providing code for exact kurtosis and skewness functionals. After package installation you may also have a look at NEWS(pkg-name) for each of the packages mentioned in this mail. - * Changes *** of startupmsg (0.5) * - This may be interesting to those annoyed by our chatty startup messages ;-) - From this version on, you may use suppressPackageStartupMessages() to suppress the startup-messages issued by our packages--- compare http://tolstoy.newcastle.edu.au/R/e2/devel/07/04/3039.html - Short Descriptions - distr: distr is to provide a conceptual treatment of random variables (r.v.'s) by means of S4--classes. A virtual mother class Distribution is introduced. All distributions of the stats package are implemented as subclasses of either AbscontDistribution or DiscreteDistribution. Using these classes, we also provide (default) methods to automatically generate the image distributions under unary mathematical operations as well as a general convolution algorithm. - distrSim: Classes and methods are provided for a standardized treatment of simulations (also under contaminations) . - distrTEst: Classes and methods are provided for a standardized treatment of the evaluation of statistical procedures (up to now only estimators) at data/simulations - distrEx: This package provides some extensions to package distr like: * extreme value distribution classes, * expectations +in the form E(X) for the expectation of X where X is some distribution or +in the form E(X,f) for the expectation of f(X) where X is some distribution and f some function in X, * further functionals: var, sd, IQR, mad, median, kurtosis, skewness * truncated moments * distances between distributions (Hellinger, Kolmogorov, total variation, convex contamination) * conditional distributions in factorized form * conditional expectations in factorized form - distrDoc: distrDoc provides a common vignette to the distrXXX family - startupmsg: provides utilities for start-up messages for packages - We look forward to receiving questions, comments and suggestions Peter Ruckdeschel Matthias Kohl Thomas Stabla Florian Camphausen ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] ROC curve in R
Sorry Gaurav, I'll make sure I mark a copy to r-help also. As I have told, I'm new to R and even to statistics, so it will take some time for me to learn it. Just help me get a simple ROC curve, please give an example of your own and explain the steps, no mater if its biology or any other field, I just need to get the logic behind it. Thanks Regards Rithesh M Mohan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 4:28 PM To: Rithesh M. Mohan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] ROC curve in R Hi Ritesh ***please note Ritesh always mark a copy to the R-help mailing list :) *** Please visit this link to get help in R http://rocr.bioinf.mpi-sb.mpg.de/ROCR_Talk_Tobias_Sing.ppt#384,8,Examples (2/8): Precision/recall curves futher :) what do you mean by PSA and cohort :) after some googling i got this co·hort(khôrt) n. 1. A group or band of people. 2. A companion or associate. 3. A generational group as defined in demographics, statistics, or market research: The cohort of people aged 30 to 39 . . . were more conservative American Demographics. 4. a. One of the 10 divisions of a Roman legion, consisting of 300 to 600 men. b. A group of soldiers. and for PSA i got Prostate-specific antigen. A substance produced by the prostate that may be found in an increased amount in the blood of men who have prostate cancer, benign prostatic hyperplasia, or infection or inflammation of the prostate. Now please clarify what you want to model :) please dont take it otherwise i am not from biology field. Please clarify :) Regards, Gaurav Yadav +++ Assistant Manager, CCIL, Mumbai (India) Mob: +919821286118 Email: [EMAIL PROTECTED] Bhagavad Gita: Man is made by his Belief, as He believes, so He is Rithesh M. Mohan [EMAIL PROTECTED] 07/30/2007 01:30 PM To [EMAIL PROTECTED] cc Subject Re: [R] ROC curve in R Hi Gaurav, Need your help, I'm relatively new to R or even stats, so can you please give me step by step details to get ROC curve in R. Requirement. To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. It would be really great if you could help me with this. Thanks and Regards Rithesh DISCLAIMER AND CONFIDENTIALITY CAUTION:\ \ This message and ...{{dropped}} __ 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] apply, lapply and data.frame in R 2.5
On 2007-July-30 , at 12:20 , Prof Brian Ripley wrote: On Mon, 30 Jul 2007, jiho wrote: A recent (in 2.5 I suspect) change in R is giving me trouble. I want to apply a function (tolower) to all the columns of a data.frame and get a data.frame in return. Currently, on a data.frame, both apply (for arrays) and lapply (for lists) work, but each returns its native class (resp. matrix and list): apply(mydat,2,tolower) # gives a matrix lapply(mydat,tolower)# gives a list and sapply(mydat,tolower)# gives a matrix which is exactly what R 2.0.0 did, so no recent(ish) change at all. If I remember well, apply did not used to work on data.frames and lapply returned a data.frame when it was provided with one, with the same properties (columns classes etc). At least this is what my code written with R 2.4.* suggests. apply has coerced data frames for many years and lapply always returned a list. The solution has always been mydat[] - lapply(mydat,tolower) sorry about that, my previous code was misleading and indeed your code above does exactly what I need. I should have tested this a bit further before posting. I was just afraid to install two different R versions I guess. thank you again. JiHO --- http://jo.irisson.free.fr/ __ 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] regular expressions : extracting numbers
Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 __ 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] getting the name of variables passed to a function
Folks, I've entered into an R programming territory I'm not very familiar with, thus this probably very elementary question concerning the mechanic of a function call. I want to know from within a function the name of the variables I pass down. The function makes use of the ... to allow for multiple unknown arguments, myfun = function(...) { do something } In the body I put, { nm - names(list(...)) nm } When the function is called with two vectors x, and y myfun(x, y) It returns NULL. However, when the call made is, myfun(x=x, y=y) The result is [1] x y Question : how do i get the names of the unknown variables without explicitly saying x=x... Thanks in advance. Horace __ 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 edit L-moment Ratio Diagram
Hi Sir L-moment ratio diagram is obtained from RFA package using function plotlmrdia(lmrdia()). How can I edit thie diagram to represent the labels of curves representing the various distribtuions. I mean to say how can I use legend() function for this diagram, Thank You -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [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] reading stata files: preserving values of variables converted to factors
On Thu, 26 Jul 2007, Ben Saylor wrote: Hi, I am a Stata user new to R. I am using read.dta to read a Stata file that has variables with value labels. read.dta converts them to factors, but seems to recode them with values from 1 to number of factor levels (looking at the output of unclass(varname)), so the original numerical values are lost. Yes. The R factor type should not be used if you want the original levels. It is not a 'labelled numeric' type and the numbers are an implementation detail. Using convert.factors=FALSE preserves the values, but seems to discard the labels. It doesn't discard the labels. They are kept in the attributes of the data frame. -thomas __ 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] plot
Many thanks, Greg and Justin. The matrix is just a 26*31 matrix - 26 years, 31 regions. I am know to R, just dont know how to attach the data here yet.. As I have such matrices for nine indicators for all regions, so i could show some differences by 3D plot, which I did similar things in Excel. I am sure there is a way to do it in R On 7/27/07, Greg Snow [EMAIL PROTECTED] wrote: Graphs that rely on 3-d effects tend to distort the data rather than enlighten the viewer. If your goal is to distort the data (which I doubt), then most of us don't want to help. On the other hand, if you really do want to enlighten the viewer (even if that is just you), then tell us what your data is like and what you want to learn from it, and we will be happy to give you advice on creating useful graphs. -- 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 Dong GUO ?? Sent: Friday, July 27, 2007 8:45 AM To: r-help@stat.math.ethz.ch Subject: [R] plot Greetings to the group, I would like to know if some one could help me with plot 3-d column graph of a matrix (3-d column graph in Excel). Many thanks in advance. Regards, Dong __ 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.
[R] Looping through all possible combinations of cases
Hello! I have a regular data frame (DATA) with 10 people and 1 column ('variable'). Its cases are people with names ('a', 'b', 'c', 'd', 'e', 'f', etc.). I would like to write a function that would sum up the values on 'variable' of all possible combinations of people, i.e. 1. I would like to write a loop - in such a way that it loops through each possible pair of cases (i.e., ab, ac, ad, etc.) and sums up their respective values on 'variable' 2. I would like to write a loop - in such a way that it loops through each possible trio of cases (i.e., abc, abd, abe, etc.) and sums up their respective values on 'variable'. 3. I would like to write a loop - in such a way that it loops through each possible quartet of cases (i.e., abcd, abce, abcf, etc.) and sums up their respective values on 'variable'. etc. Then, at the end I want to capture all possible combinations that were considered (i.e., what elements were combined in it) and get the value of the sum for each combination. How should I do it? Thanks a lot! Dimitri __ 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] 2nd R Console
Hi, I was reading a thread: [R] 2nd R console and had a similar question regarding having more than one R console open at a time. However, my question differs from that of the thread: Is it possible, or is there a wrapper that will allow one, to open an arbitrary number of R consoles which access the same R session (all objects in that session, etc.). This would be R on linux accessed through a shell - kind of like using GNU screen multi-user such that people could work collaboratively on a given session. The problem with screen is that all commands are interleaved in the same terminal, which is confusing and does not allow access to the command prompt at the same time, rather it would be sequential. I know there will be why questions but it is useful in an academic environment. Basically we have a memory machine for large genomic analysis - and we could set that up as an Rserver, but this placing R into a multi-user engine is better suited for our immediate needs. Does anybody have thoughts on this? Thanks for considering, Michael Janis UCLA Bioinformatics __ 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] error in using R2WinBUGS on Ubuntu 6.10 Linux
what version of Wine are you running? and is this the patched (1.4.1) version of WinBUGS that you're trying to run? cheers, thomas. Date: Thu, 26 Jul 2007 12:03:38 -0400 (EDT) From: [EMAIL PROTECTED] Subject: [R] error in using R2WinBUGS on Ubuntu 6.10 Linux To: r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=us-ascii I am trying to run WinBUGS 1.4 from the Ubuntu 6.10 Linux distribution. I am using the R2WinBUGS packages with the source file listed below. WinBUGS appears to run properly, but I get the following message after WinBUGS starts in WINE. Does anyone know what may be causing this error and what the correction may be? Thanks ERROR MESSAGE: fixme:ole:GetHGlobalFromILockBytes cbSize is 13824 err:ole:CoGetClassObject class {0003000a---c000-0046} not registered err:ole:CoGetClassObject class {0003000a---c000-0046} not registered err:ole:CoGetClassObject no class object {0003000a---c000-0046} could be created for context 0x3 fixme:keyboard:RegisterHotKey (0x10032,13,0x0002,3): stub fixme:ntdll:RtlNtStatusToDosErrorNoTeb no mapping for 800a err:ole:local_server_thread Failure during ConnectNamedPipe 317 R SOURCE FILE: rm(list=ls(all=TRUE)) library(R2WinBUGS) inits-function(){ list(alpha0 = 0, alpha1 = 0, alpha2 = 0, alpha12 = 0, sigma = 1) } data-list(r = c(10, 23, 23, 26, 17, 5, 53, 55, 32, 46, 10, 8, 10, 8, 23, 0, 3, 22, 15, 32, 3), n = c(39, 62, 81, 51, 39, 6, 74, 72, 51, 79, 13, 16, 30, 28, 45, 4, 12, 41, 30, 51, 7), x1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), x2 = c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1), N = 21) test-bugs(data,inits, model.file=/home/meyerjp/rasch/test.bug, parameters=c(alpha0,alpha1,alpha12,alpha2,sigma), n.chains=2,n.iter=1,n.burnin=1000, bugs.directory=/home/meyerjp/.wine/drive_c/Program Files/WinBUGS14/, working.directory=/home/meyerjp/rasch/working, debug=FALSE, WINEPATH=/usr/bin/winepath, newWINE=TRUE) __ 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] reading stata files: preserving values of variables converted to factors
Thanks for the clarification. I found the labels values in attributes(dataframe)$label.table$varname which looks the same whether convert.factors is TRUE or FALSE. Ben Thomas Lumley wrote: On Thu, 26 Jul 2007, Ben Saylor wrote: Hi, I am a Stata user new to R. I am using read.dta to read a Stata file that has variables with value labels. read.dta converts them to factors, but seems to recode them with values from 1 to number of factor levels (looking at the output of unclass(varname)), so the original numerical values are lost. Yes. The R factor type should not be used if you want the original levels. It is not a 'labelled numeric' type and the numbers are an implementation detail. Using convert.factors=FALSE preserves the values, but seems to discard the labels. It doesn't discard the labels. They are kept in the attributes of the data frame. -thomas __ 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] Package manual examples - 'unexpected$undefined' errors
Trying out an unfamiliar package, the natural thing is to use the examples given in the package's manual - hopefully, the writers of the package wouldn't include examples which didn't work! Recently, though, I've been getting 'unexpected$undefined' error messages when doing this, despite having copy/pasted the text from the manual (taking out hard breaks on the way). Moreover, I've had error messages for commands which I've previously had work fine. For instance, this from Zelig z.out zelig(vote ~ race + educate, model = logit, data = turnout) has at different times worked fine and thrown up the error message. Any help gratefully received. [[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] manipulating arrays
?append cheers, Rolf Turner On 28/07/2007, at 2:12 AM, Henrique Dallazuanna wrote: Hi, I don't know if is the more elegant way, but: X-c(1,2,3,4,5) X - c(X[1], 0, X[2:5]) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 27/07/07, Nair, Murlidharan T [EMAIL PROTECTED] wrote: Can I insert an element in an array at a particular position without destroying the already existing element? X-c(1,2,3,4,5) I want to insert an element between 1 and 2. Thanks ../Murli [[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. [[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. ## Attention:\ This e-mail message is privileged and confidenti...{{dropped}} __ 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] Creating an instance of R from MS Access?
Hi all: Does anyone know if it's at all possible to create a connection to R from MS access? For example, if I have a table and want to export it to R,generate a graph in R and import it back to MS access. I can do this with sigmaPlot and other graphic programs but just wondering if it can be done with R. Thanks Felipe D. Carrillo Fishery Biologist US Fish Wildlife Service Red Bluff, California 96080 __ 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] manipulating arrays
Try this: x - 11:15 append(x, values = 99, after = 1) [1] 11 99 12 13 14 15 On 7/27/07, Nair, Murlidharan T [EMAIL PROTECTED] wrote: Can I insert an element in an array at a particular position without destroying the already existing element? X-c(1,2,3,4,5) I want to insert an element between 1 and 2. Thanks ../Murli [[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-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] data order by different level of variables
Dear useR, I have a data matrix, it has n columns, each column is a two-level variable with entires -1 and +1. They are randomly generated, now I want to order them like (for example, 5 columns case) --- - - -- - -- . (first several rows are the samples with all variables in low level) + - -- - + - --- . - + -- - + + -- - + + + + + Is there any function in R that could let me do this order by Var1 then order by Var2 then...order by Var n Thanks very much in advance! Best, Leon [[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] Calling R functions from a Microsoft SQL Server stored procedure
Does anyone have any advice on how to call R functions from a Microsoft SQL Server stored procedure? So far, I have no problem querying and saving to the database from R using RODBC. However, I wonder whether it is possible to work in the opposite direction: calling R from SQL Server, sending the data to be analyzed, and gathering the results to save them back into the database. Any advice would be very much appreciated. Cheers, Luis [[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] generating symmetric matrices
Greetings, I have a seemingly simple task which I have not been able to solve today. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor - rnorm(p*(p-1)/2) Rmat[outer(1:p, 1:p, )] - Rmat[outer(1:p, 1:p, )] - dat.cor However, the problem is that the matrix is filled by column and so the resulting matrix is not symmetric. I'd be grateful for any adive and/or solutions. Gregory - [[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] 2nd R Console
Hi, I was reading a thread: [R] 2nd R console and had a similar question regarding having more than one R console open at a time. However, my question differs from that of the thread: Is it possible, or is there a wrapper that will allow one, to open an arbitrary number of R consoles which access the same R session (all objects in that session, etc.). This would be R on linux accessed through a shell - kind of like using GNU screen multi-user such that people could work collaboratively on a given session. The problem with screen is that all commands are interleaved in the same terminal, which is confusing and does not allow access to the command prompt at the same time, rather it would be sequential. I know there will be why questions but it is useful in an academic environment. Basically we have a memory machine for large genomic analysis - and we could set that up as an Rserver, but this placing R into a multi-user engine is better suited for our immediate needs. Does anybody have thoughts on this? Thanks for considering, Michael Janis UCLA Bioinformatics __ 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] Fitting exponential curve to data points
Sorry, just got back into town. I wonder if AIC, BIC, or cross-validation scoring couldn't also be used as criteria for model selection - I've seen it mostly in the context of variable selection rather than 'form' selection but in principle might apply here? --- Dieter Menne [EMAIL PROTECTED] wrote: Andrew Clegg andrew.clegg at gmail.com writes: ... If I want to demonstrate that a non-linear curve fits better than an exponential, what's the best measure for that? Given that neither of nls() or optim() provide R-squared. To supplement Karl's comment, try Douglas Bates' (author of nls) comments on the matter http://www.ens.gu.edu.au/ROBERTK/R/HELP/00B/0399.HTML Short summary: * ... the lack of automatic ANOVA, R^2 and adj. R^2 from nls is a feature, not a bug :-) * My best advice regarding R^2 statistics with nonlinear models is, as Nancy Reagan suggested, Just say no. Dieter __ 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.
Re: [R] manipulating arrays
I think you are looking for append(), though it won't modify the object in-place like Python [I believe that is a product of R's 'functional programming' philosophy]. might want to check this entertaining thread: http://tolstoy.newcastle.edu.au/R/help/04/11/7727.html in this example it would be like c(X[1], 0, X[2:5]) [1] 1 0 2 3 4 5 append(X,0,1) [1] 1 0 2 3 4 5 --- Henrique Dallazuanna [EMAIL PROTECTED] wrote: Hi, I don't know if is the more elegant way, but: X-c(1,2,3,4,5) X - c(X[1], 0, X[2:5]) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 27/07/07, Nair, Murlidharan T [EMAIL PROTECTED] wrote: Can I insert an element in an array at a particular position without destroying the already existing element? X-c(1,2,3,4,5) I want to insert an element between 1 and 2. Thanks ../Murli [[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. [[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. Comedy with an Edge to see what's on, when. __ 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] Q: extracting data from lm
D. R. Evans wrote: Warning: I am a complete newbie to R. I have read ISwR, but I am still finding myself completely stuck on some simple concepts. I have tried everything I can think of to solve this one, and finally decided that enough was enough and I need a pointer to a solution. I have the following summary from lm(): summary(lm(nu1~nu4)) Call: lm(formula = nu1 ~ nu4) Residuals: Min 1Q Median 3Q Max -1572.62 -150.38 -21.70 168.57 2187.84 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 29.88739 43.68881 0.6840.494 nu4 1.000360.01025 97.599 2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 470.9 on 298 degrees of freedom Multiple R-Squared: 0.9697, Adjusted R-squared: 0.9696 F-statistic: 9526 on 1 and 298 DF, p-value: 2.2e-16 But I want to access some of these numbers programmatically. I finally figured out that to get the estimate of the nu4 coefficient I need to do: lm(nu1~nu4)$coefficients[2] nu4 1.000363 which to me as a long-time C++ programmer is close to black magic (I've been programming since 1972; I have to say that R is unlike anything I've ever seen, and it's far from trivial to get my head around some of it -- for example, how I could have known a priori that the above is the way to get the nu4 coefficient is beyond me). Anyway, having figured out how to get the estimate of the coefficient, I not-unnaturally wanted also to find a way to access the std. error of the estimate (the value 0.01025 in the summary). But I am completely mystified as to how to do it :-( Any help gratefully (VERY gratefully) received, and I apologise if this is a really, really stupid question and that the answer lies somewhere in some documentation that I've obviously not properly taken on board. coef(summary(lm(nu1 ~ nu2)))[,2] Also, try the following which is often useful: str(summary(lm(nu1 ~ nu2))) __ 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. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ 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] Package manual examples - 'unexpected$undefined' errors
Trying out an unfamiliar package, the natural thing is to use the examples given in the package's manual - hopefully, the writers of the package wouldn't include examples which didn't work! Recently, though, I've been getting 'unexpected$undefined' error messages when doing this, despite having copy/pasted the text from the manual (taking out hard breaks on the way). Moreover, I've had error messages for commands which I've previously had work fine. For instance, this from Zelig z.out zelig(vote ~ race + educate, model = logit, data = turnout) has at different times worked fine and thrown up the error message. Any help gratefully received. [[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] Matrix Multiplication, Floating-Point, etc.
Hi. I recently tried the following in R 2.5.1 on Windows XP: ev2-c(0.8,-0.6) ev1-c(0.6,0.8) ev1%*%ev2 [,1] [1,] -2.664427e-17 sum(ev1*ev2) [1] 0 (I got the same result with R 2.4.1 on a different Windows XP machine.) I expect this issue is very familiar and probably has been discussed in this forum before. Can someone please point me to some documentation or discussion about this? Is there some standard way to get the correct answer from %*%? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ 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] Q: extracting data from lm
On 27/07/07, Chuck Cleland [EMAIL PROTECTED] wrote: coef(summary(lm(nu1 ~ nu2)))[,2] Also, try the following which is often useful: str(summary(lm(nu1 ~ nu2))) Oh, wow! Thank you. Incidentally, just in case anyone got the wrong end of the stick, I'm not at all complaining about R. It's good at my age to be faced with something so different. And from an architectural standpoint I appreciate its elegance and innate power. It's just the logistics of knowing exactly what to type that causes me to feel overwhelmed, and although I've become very used in the past couple of days to typing ?something I'm not much good yet at finding out how to help myself if that doesn't tell me what I want to know. __ 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] manipulating arrays
Henrique Dallazuanna wrote: Hi, I don't know if is the more elegant way, but: X-c(1,2,3,4,5) X - c(X[1], 0, X[2:5]) append(X, 0, 1) __ 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] Average plan
Nok Noy wrote: Hello, I'm looking for a method to compute an average plan from 4 or 5 point in an cartesian space. I'm sure It can be done using a less-square method but maybe it a function already exist in R system to get this plan. Can somebody help me to solve this problem (I'm looking on the net for hours but didn't find anything realy satisfiying me) Hi Nok, I haven't seen any answers to your question, and this may be due to the fact that no one knows what you are asking. Do you mean that you want to define a _plane_ that is the best fit to more than three points in a three dimensional system? Jim __ 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] About infinite value
I think that the best thing is to work in logarithmic way, to avoid the limitations of the CPU. If y = 10^400, to do y=400*log(10), to change all you formulate to the logarithmic way and the final result to apply the antilogarithm. Felipe de Mendiburu. Professor of statistic Agrarian National University -La Molina - PERU Thank you. Thanks your method. -- View this message in context: http://www.nabble.com/About-infinite-value-tf4128557.html#a11844202 Sent from the R help mailing list archive at Nabble.com. __ 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] beta regressions in R
Good morning, Does anyone know of a package or function to do a beta regression? Thanks, Walt Paczkowski _ Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 (V) 609-936-8999 (F) 609-936-3733 __ 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] xtable with vector
Hello, Is there a possibility to use xtable with a vector to generate a latex table? I always get an error, that no applicable method is available. For example: b-1:12 dim(b)-c(2,6) dimnames(b)[[2]]-paste(col,1:6) xtable(b) works fine and does not raise an error, but a-1:6 names(a)-paste(col,1:6) xtable(b) does not work. Regards, Stefan __ 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] text() and vector arguments like adj
Hello, I remarked that the function ## Default S3 method: text (x, y = NULL, labels = seq(along = x), adj = NULL,pos = NULL, offset = 0.5, vfont = NULL,cex = 1, col = NULL, font = NULL, ...) accepts vectors of arguments (of the same length) except for the parameter adj. When passing a vector of information for adjusting the labels, only the first value is taken. Any special reason for this ? btw: could a rotating argument like the 'srt' argument in mtext() be incorporated ? best Bjoern __ 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] the large dataset problem
Dear useRs, I recently began a job at a very large and heavily bureaucratic organization. We're setting up a research office and statistical analysis will form the backbone of our work. We'll be working with large datasets such the SIPP as well as our own administrative data. Due to the bureaucracy, it will take some time to get the licenses for proprietary software like Stata. Right now, R is the only statistical software package on my computer. This, of course, is a huge limitation because R loads data directly into RAM making it difficult (if not impossible) to work with large datasets. My computer only has 1000 MB of RAM, of which Microsucks Winblows devours 400 MB. To make my memory issues even worse, my computer has a virus scanner that runs everyday and I do not have the administrative rights to turn the damn thing off. I need to find some way to overcome these constraints and work with large datasets. Does anyone have any suggestions? I've read that I should carefully vectorize my code. What does that mean ??? !!! The Introduction to R manual suggests modifying input files with Perl. Any tips on how to get started? Would Perl Data Language (PDL) be a good choice? http://pdl.perl.org/index_en.html I wrote a script which loads large datasets a few lines at a time, writes the dozen or so variables of interest to a CSV file, removes the loaded data and then (via a for loop) loads the next few lines I managed to get it to work with one of the SIPP core files, but it's SLW. Worse, if I discover later that I omitted a relevant variable, then I'll have to run the whole script all over again. Any suggestions? Thanks, - Eric __ 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] Bug in TAB handling for Win32 rTerm and rGUI in 2.5.1?
Greetings. This seemed like a bug to me, but I wanted to see if this was in fact intended before reporting. Before I start, i want to first extend thanks for the big improvements in integration of command completion for the windows version. Really nice to have now. But i believe there are some issues. In getline/getline.c, the tab case of the charater handling switch statement in getline() simply break;s to the end if tab completion is not enabled, thus eating the tab. Thus, if tab completion is disabled, a tab no longer serves as a tab; it disappears. likewise, in console.c, if k == TABKEY, a return is done without adding the key to kbuf, thus TAB is always discarded, even if completion is disabled. It seems to me that this is wrong. This new TAB behavior now makes it impossible for me to copy/paste text from a text file of R expressions which use TABs. Copy paste behavior which worked in 2.4.x for rTerm now does not, since the discarded TABs mean that keyword separators may disappear, changing the meaning of pasted text. rGUI thankfully still works, since the completion/TAB processing code is bypassed when activating the paste command. I'd like to request the ability to have both --- TAB as a working separator, and the ability to configure the completion key to something other than TAB. This way one can both enjoy completion and successfully copy/paste text containing tabs. Cheers --Rick __ 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] the large dataset problem
Dear useRs, I recently began a job at a very large and heavily bureaucratic organization. We're setting up a research office and statistical analysis will form the backbone of our work. We'll be working with large datasets such the SIPP as well as our own administrative data. Due to the bureaucracy, it will take some time to get the licenses for proprietary software like Stata. Right now, R is the only statistical software package on my computer. This, of course, is a huge limitation because R loads data directly into RAM making it difficult (if not impossible) to work with large datasets. My computer only has 1000 MB of RAM, of which Microsucks Winblows devours 400 MB. To make my memory issues even worse, my computer has a virus scanner that runs everyday and I do not have the administrative rights to turn the damn thing off. I need to find some way to overcome these constraints and work with large datasets. Does anyone have any suggestions? I've read that I should carefully vectorize my code. What does that mean ??? !!! The Introduction to R manual suggests modifying input files with Perl. Any tips on how to get started? Would Perl Data Language (PDL) be a good choice? http://pdl.perl.org/index_en.html I wrote a script which loads large datasets a few lines at a time, writes the dozen or so variables of interest to a CSV file, removes the loaded data and then (via a for loop) loads the next few lines I managed to get it to work with one of the SIPP core files, but it's SLW. Worse, if I discover later that I omitted a relevant variable, then I'll have to run the whole script all over again. Any suggestions? Thanks, - Eric __ 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] lattice grayscale theme
Hi, is there a grayscale setting for lattice plots? I like the default color settings. I also like the settings that are available for setting black and white with something like this: --8---cut here---start-8--- ltheme - canonical.theme(color = FALSE) ## in-built BW theme ltheme$strip.background$col - transparent ## change strip bg lattice.options(default.theme = ltheme) ## set as default --8---cut here---end---8--- Is there a simple way of achieving something in between these settings (using grayscales for the default colors)? Thankful for any pointers, Patrick __ 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] regular expressions : extracting numbers
Bonjour David, What about one of these : R gsub( [^[:digit:]], , x ) or using perl regular expressions: R gsub( \\D, , x, perl = T ) Cheers, Romain GOUACHE David wrote: Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.3 -- Mango Solutions data analysis that delivers Tel: +44(0) 1249 467 467 Fax: +44(0) 1249 467 468 Mob: +44(0) 7813 526 123 __ 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] PCA with missing data?
Hello, I'm interested in running a PCA on a data set with lots of missing data. There're a few techniques online which suggest how I could go about doing this, but before I committed to coding them into R, I wanted to see whether anyone could recommend a currently existing package with such a procedure. Google searching for such a procedure has'nt turned much up...but I blame that on the difficulty of searcching for single letters, and the rampant use of R as a variable name. But I did attempt to do my homework before posting to the list! Cordially, -- Adam D. I. Kramer Ph.D. Student, Social Psychology University of Oregon [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.
Re: [R] regular expressions : extracting numbers
Is this what you want: x [1] lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse [7] rbrbrb 12 rb rj 30%rb [13] rbrb 25%rbrb rbrj, rb gsub([^0-9]*([0-9]*)[^0-9]*, \\1, x) [1] 2 2 3 4 3 21230 25 On 7/30/07, GOUACHE David [EMAIL PROTECTED] wrote: Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 __ 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? __ 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 combine data of several csv-files
okay, I played a bit around and now I have some kind of testcase for you: v1 - NA v2 - rnorm(6) v3 - rnorm(6) v4 - rnorm(6) v5 - rnorm(6) v6 - rnorm(6) v7 - rnorm(6) v8 - rnorm(6) v8 - NA list - list(v1,v2,v3,v4,v5,v6,v7,v8) categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA) list [[1]] [1] NA [[2]] [1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750 [[3]] [1] 0.02354036 -1.36186952 -0.42197792 1.50445971 -1.76763996 0.53722404 [[4]] [1] -1.40362589 0.13045724 -0.84651458 1.57005071 0.06961015 0.25269771 [[5]] [1] -1.1829260 2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698 [[6]] [1] 1.17099178 0.49248118 -0.18690065 1.50050976 -0.65552410 -0.01243247 [[7]] [1] -0.046778203 -0.233788840 0.443908897 -1.649740180 0.003991354 -0.228020092 [[8]] [1] NA now, I need the means (and sd) of element 1 of list[2],list[3],list[4] (because they belong to cat1) and = mean(-0.6442149, 0.02354036, -1.40362589) the same for element 2 up to element 6 (-- I would the get a vector containing the means for cat1) the same for the vectors belonging to cat2. does anybody now understand what I mean? Antje __ 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] regular expressions : extracting numbers
GOUACHE David wrote: Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) chv-scan(what=character,sep= ) #then copy the text from your message to the clipboard and paste it to the R console chv [1] lema, rb 2% rb 2% rb 3% rb 4% [5] rb 3% rb 2%,mineuse rbrb [9] rb 12 rbrj 30%rb [13] rbrb 25%rbrb [17] rbrj, rb # actual replacements : # replace non-digits with nothing chv.digits-gsub([^0-9],,chv) chv.digits [1] 2 2 3 4 3 21230 25 [16] # replace empty strings with NA chv.digits[chv.digits==]-NA chv.digits [1] 2 2 3 4 3 2 NA NA 12 NA 30 NA NA 25 NA [16] NA NA NA -- View this message in context: http://www.nabble.com/regular-expressions-%3A-extracting-numbers-tf4169660.html#a11862597 Sent from the R help mailing list archive at Nabble.com. __ 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] array writing and their filenames
Hi, I want to save a array (say, array[6,7,8]) write a cvs file. How can I do that??? can I write in one file? if I could not write in one file, i want to use a loop to save in different files (in the matrix[6,7,8], should be 8 csv files), such as the filename structure should be: file =filename +str(i) +. +csv Many thanks. Dong [[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] Mapping data with unknown dimensions?
Hi. Does anyone know of a function in R which will allow me to map data points, where the number of dimensions in the data is unknown? Thanks -- View this message in context: http://www.nabble.com/Mapping-data-with-unknown-dimensions--tf4165241.html#a11850581 Sent from the R help mailing list archive at Nabble.com. __ 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] R2WinBUGS more updates after model did not converge
After running a model for a while and seeing that it did not converge yet, how can I continue to run, ie not starting anew, the model? I know if I manually/interactively use winbugs, this is possible anytime, but how can I do this in r2winbugs, so that my existing sim$sims.array and other stuff in the object that bugs() returns gets extended? Thanks Toby __ 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] regular expressions : extracting numbers
Dear David, does the following work for you? sVec - c(lema, rb 2%, rb 2%, rb 3%, rb 4%, rb 3%, rb 2%,mineuse, rb, rb, rb 12, rb, rj 30%, rb, rb, rb 25%, rb, rb, rb, rj, rb) reVec - regexpr([[:digit:]]+, sVec) # see ?regex for details on '[:digit:]' and '+' substr(sVec ,start = reVec, stop=reVec + attr(reVec, match.length) - 1) # see ?substr for details Christian __ 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] matrix output in R, and file name creating
Hi, I want to save a matrix (say, matrix[6,7,8]) write a cvs file. How can I do that??? can I write in one file? if I could not write in one file, i want to use a loop to save in different files (in the matrix[6,7,8], should be 8 csv files), such as the filename structure should be: file =filename +str(i) +. +csv Many thanks. Dong [[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] line widths of plotting symbols in the lattice
Dear List, Sorry, this is very simple but I can't seem to find any information regarding line widths of plotting symbols in the lattice package. For instance, in traditional graphics: plot(1:10,lwd=3) points(10:1,lwd=2,col=3) 'lwd' allows control of plotting symbol line widths. I've tried looking through the documentation for xyplot, panel.points, trellis.par.set, and the R-help archives. Maybe it goes by another name? Thanks in advance, Stephen __ 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] plot
Thanks again, Greg, It really helps. Would you please let me know more reference of plot in R? how to use the image function to create the grid??? Thanks much. Dong On 7/27/07, Greg Snow [EMAIL PROTECTED] wrote: Can you really see much of the data in a 26*31 3d barplot? It seems like most info would be hidden behind the first few rows and it would be so cluttered that you would not be able to make out much of anything from it. It is true that with too much info in such a 3d graph, it would be not informative. Why not try a line plot instead (year as the x axis, each region a different year). Here is a quick example: data(votes.repub, package='cluster') matplot( t(votes.repub[1:31, 1:26]), type='l') Even better would be to group some of the regions together and use xyplot from the lattice package and have a panel for each group of regions (fewer lines per panel should be easier to see detail). You could also use the image function (or levelplot from lattice) to create a 26*31 grid with colors used for the 3rd dimension (can be good for overall patterns, not so good for looking at detail). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: Dong GUO ¹ù¶« [mailto:[EMAIL PROTECTED] Sent: Friday, July 27, 2007 12:09 PM To: Greg Snow Cc: r-help@stat.math.ethz.ch Subject: Re: [R] plot Many thanks, Greg and Justin. The matrix is just a 26*31 matrix - 26 years, 31 regions. I am know to R, just dont know how to attach the data here yet.. As I have such matrices for nine indicators for all regions, so i could show some differences by 3D plot, which I did similar things in Excel. I am sure there is a way to do it in R On 7/27/07, Greg Snow [EMAIL PROTECTED] wrote: Graphs that rely on 3-d effects tend to distort the data rather than enlighten the viewer. If your goal is to distort the data (which I doubt), then most of us don't want to help. On the other hand, if you really do want to enlighten the viewer (even if that is just you), then tell us what your data is like and what you want to learn from it, and we will be happy to give you advice on creating useful graphs. -- 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 Dong GUO ?? Sent: Friday, July 27, 2007 8:45 AM To: r-help@stat.math.ethz.ch Subject: [R] plot Greetings to the group, I would like to know if some one could help me with plot 3-d column graph of a matrix (3-d column graph in Excel). Many thanks in advance. Regards, Dong __ 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. [[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] Prompt comes too late
Hi R fans I am trying to make a program to ask the user to choose data file: print(Choose data file please !) matr=read.table(file.choose(),dec=.,header=TRUE) The problem is that the prompt Choose data file please ! comes after I have chosen the file. What am doing wrong? Thanks in advance Ralf Finne __ 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] deriv; loop
Hi, 2 questions: Question 1: example of what I currently do: for(i in 1:6){sink(temp.txt,append=TRUE) dput(i+0) sink()} x=scan(file=temp.txt) print(prod(x)) file.remove(C:/R-2.5.0/temp.txt) But how to convert the output of the loop to a vector that I can manipulate (by prod or sum etc), without having to write and append to a file? Question 2: deriv(~gamma(x),x) expression({ .expr1 - gamma(x) .value - .expr1 .grad - array(0, c(length(.value), 1), list(NULL, c(x))) .grad[, x] - .expr1 * psigamma(x) attr(.value, gradient) - .grad .value }) BUT deriv3(~gamma(x),x) Error in deriv3.formula(~gamma(x), x) : Function 'psigamma' is not in the derivatives table What I want is the expression for the second derivative (which I believe is trigamma(x), or psigamma(x,1)), how can I obtain that? Thanks -- View this message in context: http://www.nabble.com/deriv--loop-tf4166283.html#a11853456 Sent from the R help mailing list archive at Nabble.com. __ 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] Order by the columns
Dear useR, I have a data matrix, it has n columns, each column is a two-level variable with entires -1 and +1. They are randomly generated, now I want to order them like (for example, 5 columns case) --- - - -- - -- . (first several rows are the samples with all variables in low level) + - -- - + - --- . - + -- - + + -- - + + + + + Is there any function in R that could let me do this order by Var1 then order by Var2 then...order by Var n Thanks very much in advance! Best, Leon [[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.csv
Hi, I want to save an array(say, array[6,7,8]) write a cvs file. How can I do that??? can I write in one file? if I could not write in one file, i want to use a loop to save in different files (in the array[6,7,8], should be 8 csv files), such as the filename structure should be: file =filename +str(i) +. +csv Many thanks. [[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] regular expressions : extracting numbers
On Mon, 2007-07-30 at 13:58 +0200, GOUACHE David wrote: Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. Try this: Vec [1] lema, rb 2% rb 2% rb 3% rb 4% [5] rb 3% rb 2%,mineuse rbrb [9] rb 12 rbrj 30%rb [13] rbrb 25%rbrb [17] rbrj, rb gsub([^0-9], , Vec) [1] 2 2 3 4 3 21230 [14] 25 The search pattern regex here is [^0-9] which says to replace anything that is not (^) in the character range of 0 through 9. See ?regex and/or http://www.regular-expressions.info/ HTH, Marc Schwartz __ 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] Fwd: Package manual examples - 'unexpected$undefined' errors
Bounced first time! -- Forwarded message -- From: David Pain [EMAIL PROTECTED] Date: 28-Jul-2007 11:03 Subject: Package manual examples - 'unexpected$undefined' errors To: r-help@stat.math.ethz.ch Trying out an unfamiliar package, the natural thing is to use the examples given in the package's manual - hopefully, the writers of the package wouldn't include examples which didn't work! Recently, though, I've been getting 'unexpected$undefined' error messages when doing this, despite having copy/pasted the text from the manual (taking out hard breaks on the way). Moreover, I've had error messages for commands which I've previously had work fine. For instance, this from Zelig z.out zelig(vote ~ race + educate, model = logit, data = turnout) has at different times worked fine and thrown up the error message. Any help gratefully received. __ 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] Call R program from C++ code
Hi All: I'm developing an application program using C++. From my C++ code, I would call some R program I have written. I' wondering if R provide some compiler that can compile R program into executable program. I searched R-help, there are a lot of posts talking about writing C++ code in R program, but few about calling R from C++. I might be wrong that R doesn't have complier. What I'm trying to do is to call R program from C++ code. Any help is highly appreciated! Best regards, Feng [[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] Problem with code
Hi I am having the following Warning message with this code: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file- reason 'No such file or directory' in: file(file, r) The files are present on a CD and USB key- I tried opening all the files-then running the script but, it makes no difference. Basically How do I ensure that R reads my files to perform functions- I have some files on CD and other on my a USB key. Also if I am using script that was already written, for new data - how do I know which info. in the existing script should be updated? Thanks faith1 [[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] Call R program from C++ code
On Sun, Jul 29, 2007 at 04:35:51PM -0400, Feng Qiu wrote: I'm developing an application program using C++. From my C++ code, I would call some R program I have written. I' wondering if R provide some compiler that can compile R program into executable program. I searched That does not exist to the best of my knowledge. I might be wrong that R doesn't have complier. What I'm trying to do is to call R program from C++ code. Any help is highly appreciated! As you probably know, C++ can 'call' other object code that is linked to it. As for 'calling R', the easiest way is to call an R script using the system() call -- but it is also the most tedious way as you to write the inout data to file, and then read the result data back in. But it is a start, and it may be easiest to debug. A more advanced method would to use Rserve to run a 'headless' R service to which your C++ program can connect over the network. But there you need to be already somewhat familiar with the underlying C/C++ representation of R object. Rserve has simple examples. Next, you can actually embed R inside your C++ application, but that is more advanced. In any event, you may also want to consider the RcppTemplate package which has a host of examples about how to get R and C++ to work better together (without forcing you to use C). The 'Extending R' manual from your R installation is a good starting point for most of this. Hope this helps, Dirk -- Three out of two people have difficulties with fractions. __ 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] Call R program from C++ code
On Sun, Jul 29, 2007 at 07:15:21PM -0400, Feng Qiu wrote: using the system() call -- but it is also the most tedious way as you When using System() to call R program, do I need to call some R script program or my R function directly? It's system() with lower-case s, and yes, you would call some script to process the input you prepared from C++. And the script would prepare output that your C++ program would need. A more advanced method would to use Rserve to run a 'headless' R Here you mean Com? I don't know much about this com frame, so No, I did not mean Com. Rserve uses tcp/ip networking and is agnostic to the operating system of the caller, ie your (say, Windoze) program can call and exchange (binary) data with a program on a Linux box or Mac that runs Rserve. Could also be Windows, could be the same computer, or could be a different one. Rserve is quite flexible that way. Dirk -- Three out of two people have difficulties with fractions. __ 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] Constructing correlation matrices
Greetings, I have a seemingly simple task which I have not been able to solve today and I checked all of the help archives on this and have been unable to find anything useful. I want to construct a symmetric matrix of arbtriray size w/o using loops. The following I thought would do it: p - 6 Rmat - diag(p) dat.cor - rnorm(p*(p-1)/2) Rmat[outer(1:p, 1:p, )] - Rmat[outer(1:p, 1:p, )] - dat.cor However, the problem is that the matrix is filled by column and so the resulting matrix is not symmetric. I'd be grateful for any adive and/or solutions. Gregory - [[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] install error for RBGL_1.12.0 on linux
Dear all, I meet error when installing the newest Bioconductor packages 2.0 for R 2.5.1. the enviroments are as bellow: sessionInfo() R version 2.5.1 (2007-06-27) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods [7] base The error messages are partly as: . boost::vec_adj_list_vertex_id_mapboost::propertyboost::vertex_color_t, boost::default_color_type, boost::no_property, size_t)' make: *** [interfaces.o] Error 1 chmod: failed to get attributes of `/usr/local/lib/R/library/RBGL/libs/*': No such file or directory ERROR: compilation failed for package 'RBGL' but, there exists such directory /usr/local/lib/R/library/RBGL/libs/ in my computer: [EMAIL PROTECTED] getBioC2.5-R2.5.1]# ls -al /usr/local/lib/R/library/RBGL/libs/ total 17364 drwxr-xr-x2 root root 4096 Dec 23 2005 . drwxr-xr-x 17 root root 4096 Dec 23 2005 .. -rwxr-xr-x1 root root 17743886 Dec 23 2005 RBGL.so Please help me to fix it. THanks, xinan __ 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] install error for RBGL_1.12.0 on linux ---2
Hi, Li and all lists, More, I have searched the web, and found one solution as described in: https://stat.ethz.ch/pipermail/bioc-devel/2007-June/001168.html But, My condition is some how different: 1) my g++ version is: g++ (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5) 2) the SHLIB file is the same, but some difference in /usr/local/lib/R/etc/Makeconf: SHELL = /bin/sh SHLIB_CFLAGS = SHLIB_CXXFLAGS = SHLIB_CXXLD = g++ SHLIB_CXXLDFLAGS = -shared SHLIB_EXT = .so SHLIB_FCLD = g77 SHLIB_FCLDFLAGS = -shared SHLIB_FFLAGS = SHLIB_LD = gcc -std=gnu99 SHLIB_LDFLAGS = -shared SHLIB_LIBADD = SHLIB_LINK = $(SHLIB_LD) $(SHLIB_LDFLAGS) $(LDFLAGS) what should I do? thanks, xinan __ 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] Extract random part of summary nlme
Dear helpers, I'm estimating multilevel regression models, using the lme-function from the nlme-package. Let's say that I estimated a model and stored it inside the object named 'model'. The summary of that model is shown below: Using summary(model)$tTable , I receive the following output: summary(model)$tTable Value Std.Error DF t-value p-value (Intercept)0.23268607 0.09350662 3990 2.4884449 1.287080e-02 sexM -0.15338225 0.03169762 3990 -4.8389206 1.354802e-06 standLRT 0.38593558 0.01677195 3990 23.0107762 4.005182e-110 vrmid 50% 0.07606394 0.09389376 61 0.8101064 4.210281e-01 vrtop 25% 0.24561327 0.10483374 61 2.3428838 2.241317e-02 intakemid 50% -0.41469716 0.03177240 3990 -13.0521199 3.698344e-38 intaketop 25% -0.75920783 0.05357980 3990 -14.1696648 1.666780e-44 typeSngl 0.15680532 0.07173835 61 2.1857949 3.267903e-02 All looks fine to me. The output above is simply a section from the full summary shown below. Now, I want to extract from the summary (or the full model) the part stating the random parameters. More specifically, I want to extract from the summary the following: (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 How could this be done? Thanks for the effort, Rense Nieuwenhuis Linear mixed-effects model fit by REML Data: Exam AIC BIC logLik 9158.56 9234.241 -4567.28 Random effects: Formula: ~type | school Structure: General positive-definite, Log-Cholesky parametrization StdDevCorr (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 Fixed effects: normexam ~ sex + standLRT + vr + intake + type Value Std.Error DFt-value p-value (Intercept)0.2326861 0.09350662 3990 2.488445 0.0129 sexM -0.1533822 0.03169762 3990 -4.838921 0. standLRT 0.3859356 0.01677195 3990 23.010776 0. vrmid 50% 0.0760639 0.09389376 61 0.810106 0.4210 vrtop 25% 0.2456133 0.10483374 61 2.342884 0.0224 intakemid 50% -0.4146972 0.03177240 3990 -13.052120 0. intaketop 25% -0.7592078 0.05357980 3990 -14.169665 0. typeSngl 0.1568053 0.07173835 61 2.185795 0.0327 Correlation: (Intr) sexM stnLRT vrm50% vrt25% int50% int25% sexM -0.201 standLRT -0.125 0.028 vrmid 50% -0.742 0.028 -0.035 vrtop 25% -0.652 0.051 -0.065 0.649 intakemid 50% -0.246 -0.011 0.541 -0.002 0.007 intaketop 25% -0.218 -0.018 0.676 0.014 0.013 0.660 typeSngl -0.421 0.080 0.007 0.033 -0.027 -0.001 0.001 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -3.59074329 -0.63776965 0.03829878 0.67303837 3.33952680 Number of Observations: 4059 Number of Groups: 65 __ 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] Tabs in PDF documents
Colleagues, I am using R 2.5.1 on an Intel Mac (OS 10) to create PDF outputs using pdf(); same problem exists in Linux (RedHat 9) While adding text to the document with text() and mtext(), I encounter the following problem: In order to align the text, I have embedded tabs (\t) in some of the text. Each time I do so, I get the following error messages: Warning: font metrics unknown for character 0x9 Warning: font width unknown for character 0x9 and the tabs are ignored. I have tied par() with and without family=mono. Is there a work-around available for this? Dennis COMMANDS: pdf(junk.pdf) par(family=mono) plot(1,1) text(1,1, \txx) mtext(\txx) dev.off() __ 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] A simple question about summary.glm
Hello, I am new to R and have tried to search similar questions but could not find exactly what I am looking for, but I apologize if the question was already asked. I have 10 different treatments and want to know whether they affect the sex ratios of insect emergence. After running the glms I got this table: Df Deviance Resid. Df Resid. Dev F Pr(F) NULL133 9250.3 sex1481.5 132 8768.9 7.7212 0.006314 ** trt9 1099.1 123 7669.7 1.9585 0.049780 * But now I would like to know WHICH of the treatments was significant. I tried to use Tukey test but for some reason it does not work. My question is: I used the following function: summary(file.name, corr=F) and got the following table: Deviance Residuals: Min 1Q Median 3Q Max -14.118 -4.808 -1.4662.033 33.882 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 8.696e+00 1.893e+00 4.594 1.06e-05 *** sexm-3.791e+00 1.364e+00-2.779 0.00631 ** trtccc -1.050e+00 4.325e+00-0.243 0.80859 trtcga3 2.450e+00 4.325e+00 0.566 0.57211 trtcga4 -2.300e+00 4.325e+00-0.532 0.59584 trtg 1.550e+00 2.497e+00 0.621 0.53593 trtga4 -5.550e+00 4.325e+00-1.283 0.20183 trtp 5.422e+00 2.566e+00 2.113 0.03658 * trtpg -1.850e+00 2.497e+00-0.741 0.46019 trtw-3.634e-17 2.497e+00 -1.46e-17 1.0 trtwg -3.750e+00 2.497e+00-1.502 0.13573 What do the stars mean? Is it the same as Tukey test that tells me which treatment is different from which? i.e. is trtp (with *) significantly different to the control (which, by the way do not appear in this list and I do not know why)? Thanks Michal -- View this message in context: http://www.nabble.com/A-simple-question-about-summary.glm-tf4167757.html#a11857514 Sent from the R help mailing list archive at Nabble.com. __ 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] ROC curve in R
Thanks Gaurav, I'll try this and get back to you. Rithesh M Mohan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 6:01 PM To: Rithesh M. Mohan Cc: r-help@stat.math.ethz.ch Subject: RE: [R] ROC curve in R Hi Ritesh, what i understad of ROC analysis will be coming in other mail :) excellent introduction can be found at http://www.csee.usf.edu/~candamo/site/papers/ROCintro.pdf http://rocr.bioinf.mpi-sb.mpg.de/ take this zip file :) http://rocr.bioinf.mpi-sb.mpg.de/ROCR_1.0-2.zip also ROCR and analogue R manual :) they are having good examples :) please read it in english with the papers given above then it would be really easy to interpret ROC curve. Just try to grasp a simple thing that what is on x axis and what is on y axis, further whether the values are in ascending or descending order. accordingly try to visualize how the ROC space has be analogly divided to give digital classification :) code starts here and taken from manual of nanalogue library(analogue) ## continue the example from roc() example(roc) ## draw the ROC curve plot(swap.roc, 1) ## draw the four default diagnostic plots opar - par(mfrow = c(2,2)) plot(swap.roc) par(opar) #end of code snippet### R software working session## ## draw the ROC curve plot(swap.roc, 1) ## draw the four default diagnostic plots opar - par(mfrow = c(2,2)) plot(swap.roc) par(opar) ## continue the example from roc() example(roc) roc ## continue the example from join() roc example(join) join ## load the example data join data(swapdiat) join data(swappH) join data(rlgh) join ## process so common set of columns for training and test join ## number of training set samples join n.train - nrow(swapdiat) join ## merge training and test set on columns join dat - join(swapdiat, rlgh, verbose = TRUE) Summary: Rows Cols Data set 1: 167 277 Data set 2: 101 139 Merged: 268 277 join ## convert to proportions join dat - dat / 100 join ## subset data back into training and test sets join swapdiat - dat[1:n.train, ] join rlgh - dat[(n.train+1):nrow(dat), ] roc ## fit the MAT model using the squared chord distance measure roc swap.mat - mat(swapdiat, swappH, method = SQchord) roc ## fit the ROC curve to the SWAP diatom data using the MAT results roc ## Generate a grouping for the SWAP lakes roc clust - hclust(as.dist(swap.mat$Dij), method = ward) roc grps - cutree(clust, 12) roc ## fit the ROC curve roc swap.roc - roc(swap.mat, groups = grps) roc swap.roc ROC curve of dissimilarities Optimal Dissimilarity = 0.894 AUC = 0.889, p-value: 2.22e-16 No. within: 1214 No. outside: 12647 ## draw the ROC curve plot(swap.roc, 1) ## draw the four default diagnostic plots opar - par(mfrow = c(2,2)) plot(swap.roc) par(opar) ##end of demonstration session# Sorry Gaurav, I'll make sure I mark a copy to r-help also. As I have told, I'm new to R and even to statistics, so it will take some time for me to learn it. Just help me get a simple ROC curve, please give an example of your own and explain the steps, no mater if its biology or any other field, I just need to get the logic behind it. Thanks Regards Rithesh M Mohan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 4:28 PM To: Rithesh M. Mohan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] ROC curve in R Hi Ritesh ***please note Ritesh always mark a copy to the R-help mailing list :) *** Please visit this link to get help in R http://rocr.bioinf.mpi-sb.mpg.de/ROCR_Talk_Tobias_Sing.ppt#384,8,Examples (2/8): Precision/recall curves futher :) what do you mean by PSA and cohort :) after some googling i got this co·hort(khôrt) n. 1. A group or band of people. 2. A companion or associate. 3. A generational group as defined in demographics, statistics, or market research: The cohort of people aged 30 to 39 . . . were more conservative American Demographics. 4. a. One of the 10 divisions of a Roman legion, consisting of 300 to 600 men. b. A group of soldiers. and for PSA i got Prostate-specific antigen. A substance produced by the prostate that may be found in an increased amount in the blood of men who have prostate cancer, benign prostatic hyperplasia, or infection or inflammation of the prostate. Now please clarify what you want to model :) please dont take it otherwise i am not from biology field. Please clarify :) Regards, Gaurav Yadav +++ Assistant Manager, CCIL, Mumbai (India) Mob: +919821286118 Email: [EMAIL PROTECTED] Bhagavad Gita: Man is made by his Belief, as He believes, so He is Rithesh M. Mohan [EMAIL PROTECTED] 07/30/2007 01:30
Re: [R] ROC curve in R
Hi Ritesh, what i understad of ROC analysis will be coming in other mail :) excellent introduction can be found at http://www.csee.usf.edu/~candamo/site/papers/ROCintro.pdf http://rocr.bioinf.mpi-sb.mpg.de/ take this zip file :) http://rocr.bioinf.mpi-sb.mpg.de/ROCR_1.0-2.zip also ROCR and analogue R manual :) they are having good examples :) please read it in english with the papers given above then it would be really easy to interpret ROC curve. Just try to grasp a simple thing that what is on x axis and what is on y axis, further whether the values are in ascending or descending order. accordingly try to visualize how the ROC space has be analogly divided to give digital classification :) code starts here and taken from manual of nanalogue library(analogue) ## continue the example from roc() example(roc) ## draw the ROC curve plot(swap.roc, 1) ## draw the four default diagnostic plots opar - par(mfrow = c(2,2)) plot(swap.roc) par(opar) #end of code snippet### R software working session## ## draw the ROC curve plot(swap.roc, 1) ## draw the four default diagnostic plots opar - par(mfrow = c(2,2)) plot(swap.roc) par(opar) ## continue the example from roc() example(roc) roc ## continue the example from join() roc example(join) join ## load the example data join data(swapdiat) join data(swappH) join data(rlgh) join ## process so common set of columns for training and test join ## number of training set samples join n.train - nrow(swapdiat) join ## merge training and test set on columns join dat - join(swapdiat, rlgh, verbose = TRUE) Summary: Rows Cols Data set 1: 167 277 Data set 2: 101 139 Merged: 268 277 join ## convert to proportions join dat - dat / 100 join ## subset data back into training and test sets join swapdiat - dat[1:n.train, ] join rlgh - dat[(n.train+1):nrow(dat), ] roc ## fit the MAT model using the squared chord distance measure roc swap.mat - mat(swapdiat, swappH, method = SQchord) roc ## fit the ROC curve to the SWAP diatom data using the MAT results roc ## Generate a grouping for the SWAP lakes roc clust - hclust(as.dist(swap.mat$Dij), method = ward) roc grps - cutree(clust, 12) roc ## fit the ROC curve roc swap.roc - roc(swap.mat, groups = grps) roc swap.roc ROC curve of dissimilarities Optimal Dissimilarity = 0.894 AUC = 0.889, p-value: 2.22e-16 No. within: 1214 No. outside: 12647 ## draw the ROC curve plot(swap.roc, 1) ## draw the four default diagnostic plots opar - par(mfrow = c(2,2)) plot(swap.roc) par(opar) ##end of demonstration session# Sorry Gaurav, Iâll make sure I mark a copy to r-help also. As I have told, Iâm new to R and even to statistics, so it will take some time for me to learn it. Just help me get a simple ROC curve, please give an example of your own and explain the steps, no mater if its biology or any other field, I just need to get the logic behind it. Thanks Regards Rithesh M Mohan From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, July 30, 2007 4:28 PM To: Rithesh M. Mohan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] ROC curve in R Hi Ritesh ***please note Ritesh always mark a copy to the R-help mailing list :) *** Please visit this link to get help in R http://rocr.bioinf.mpi-sb.mpg.de/ROCR_Talk_Tobias_Sing.ppt#384,8,Examples (2/8): Precision/recall curves futher :) what do you mean by PSA and cohort :) after some googling i got this co·hort(khôrt) n. 1. A group or band of people. 2. A companion or associate. 3. A generational group as defined in demographics, statistics, or market research: The cohort of people aged 30 to 39 . . . were more conservative American Demographics. 4. a. One of the 10 divisions of a Roman legion, consisting of 300 to 600 men. b. A group of soldiers. and for PSA i got Prostate-specific antigen. A substance produced by the prostate that may be found in an increased amount in the blood of men who have prostate cancer, benign prostatic hyperplasia, or infection or inflammation of the prostate. Now please clarify what you want to model :) please dont take it otherwise i am not from biology field. Please clarify :) Regards, Gaurav Yadav +++ Assistant Manager, CCIL, Mumbai (India) Mob: +919821286118 Email: [EMAIL PROTECTED] Bhagavad Gita: Man is made by his Belief, as He believes, so He is Rithesh M. Mohan [EMAIL PROTECTED] 07/30/2007 01:30 PM To [EMAIL PROTECTED] cc Subject Re: [R] ROC curve in R Hi Gaurav, Need your help, Iâm relatively new to R or even stats, so can you please give me step by step details to get ROC curve in R. Requirement. To build ROC curve using only PSA(variable) alone of the original cohort against the ROC of the Model of the original cohort. It would be
Re: [R] how to combine data of several csv-files
okay, I played a bit around and now I have some kind of testcase for you: v1 - NA v2 - rnorm(6) v3 - rnorm(6) v4 - rnorm(6) v5 - rnorm(6) v6 - rnorm(6) v7 - rnorm(6) v8 - rnorm(6) v8 - NA list - list(v1,v2,v3,v4,v5,v6,v7,v8) categ - c(NA,cat1,cat1,cat1,cat2,cat2,cat2,NA) list [[1]] [1] NA [[2]] [1] -0.6442149 -0.2047012 -1.1986041 -0.2097442 -0.7343465 -1.3888750 [[3]] [1] 0.02354036 -1.36186952 -0.42197792 1.50445971 -1.76763996 0.53722404 [[4]] [1] -1.40362589 0.13045724 -0.84651458 1.57005071 0.06961015 0.25269771 [[5]] [1] -1.1829260 2.1411553 -0.1327081 -0.1053442 -0.8179396 -1.2342698 [[6]] [1] 1.17099178 0.49248118 -0.18690065 1.50050976 -0.65552410 -0.01243247 [[7]] [1] -0.046778203 -0.233788840 0.443908897 -1.649740180 0.003991354 -0.228020092 [[8]] [1] NA now, I need the means (and sd) of element 1 of list[2],list[3],list[4] (because they belong to cat1) and = mean(-0.6442149, 0.02354036, -1.40362589) the same for element 2 up to element 6 (-- I would the get a vector containing the means for cat1) the same for the vectors belonging to cat2. does anybody now understand what I mean? Antje - Die etwas anderen Infos rund um das Thema Reisen. BE A BETTER WELTENBUMMLER! [[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] Extracting random parameters from summary lme
LS, I'm estimating multilevel regression models, using the lme-function from the nlme-package. Let's say that I estimated a model and stored it inside the object named 'model'. The summary of that model is shown below: Using summary(model)$tTable , I receive the following output: summary(model)$tTable Value Std.Error DF t-value p-value (Intercept)0.23268607 0.09350662 3990 2.4884449 1.287080e-02 sexM -0.15338225 0.03169762 3990 -4.8389206 1.354802e-06 standLRT 0.38593558 0.01677195 3990 23.0107762 4.005182e-110 vrmid 50% 0.07606394 0.09389376 61 0.8101064 4.210281e-01 vrtop 25% 0.24561327 0.10483374 61 2.3428838 2.241317e-02 intakemid 50% -0.41469716 0.03177240 3990 -13.0521199 3.698344e-38 intaketop 25% -0.75920783 0.05357980 3990 -14.1696648 1.666780e-44 typeSngl 0.15680532 0.07173835 61 2.1857949 3.267903e-02 All looks fine to me. The output above is simply a section from the full summary shown below. Now, I want to extract from the summary (or the full model) the part stating the random parameters. More specifically, I want to extract from the summary the following: (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 How could this be done? Thanks for the effort, Rense Nieuwenhuis Linear mixed-effects model fit by REML Data: Exam AIC BIC logLik 9158.56 9234.241 -4567.28 Random effects: Formula: ~type | school Structure: General positive-definite, Log-Cholesky parametrization StdDevCorr (Intercept) 0.2869401 (Intr) typeSngl0.2791040 -0.617 Residual0.7302233 Fixed effects: normexam ~ sex + standLRT + vr + intake + type Value Std.Error DFt-value p-value (Intercept)0.2326861 0.09350662 3990 2.488445 0.0129 sexM -0.1533822 0.03169762 3990 -4.838921 0. standLRT 0.3859356 0.01677195 3990 23.010776 0. vrmid 50% 0.0760639 0.09389376 61 0.810106 0.4210 vrtop 25% 0.2456133 0.10483374 61 2.342884 0.0224 intakemid 50% -0.4146972 0.03177240 3990 -13.052120 0. intaketop 25% -0.7592078 0.05357980 3990 -14.169665 0. typeSngl 0.1568053 0.07173835 61 2.185795 0.0327 Correlation: (Intr) sexM stnLRT vrm50% vrt25% int50% int25% sexM -0.201 standLRT -0.125 0.028 vrmid 50% -0.742 0.028 -0.035 vrtop 25% -0.652 0.051 -0.065 0.649 intakemid 50% -0.246 -0.011 0.541 -0.002 0.007 intaketop 25% -0.218 -0.018 0.676 0.014 0.013 0.660 typeSngl -0.421 0.080 0.007 0.033 -0.027 -0.001 0.001 Standardized Within-Group Residuals: Min Q1 Med Q3 Max -3.59074329 -0.63776965 0.03829878 0.67303837 3.33952680 Number of Observations: 4059 Number of Groups: 65 [[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] getting the name of variables passed to a function
On Fri, 2007-07-27 at 09:52 -0700, Horace Tso wrote: Folks, I've entered into an R programming territory I'm not very familiar with, thus this probably very elementary question concerning the mechanic of a function call. I want to know from within a function the name of the variables I pass down. The function makes use of the ... to allow for multiple unknown arguments, myfun = function(...) { do something } In the body I put, { nm - names(list(...)) nm } When the function is called with two vectors x, and y myfun(x, y) It returns NULL. However, when the call made is, myfun(x=x, y=y) The result is [1] x y Question : how do i get the names of the unknown variables without explicitly saying x=x... Thanks in advance. Horace See ?match.call and take note of the 'expand.dots' argument, which defaults to TRUE. DotsFun - function(...) as.character(match.call())[-1] x - 1:10 y - 5:6 DotsFun(x, y) [1] x y match.call() returns the full function call. In the above, we take that result, coerce it to a character vector and remove the first element, which is the function being called, thus leaving the arguments. HTH, Marc Schwartz __ 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] getting the name of variables passed to a function
I would start from match.call(expand.dots=TRUE) which has done the hard work for you. On Fri, 27 Jul 2007, Horace Tso wrote: Folks, I've entered into an R programming territory I'm not very familiar with, thus this probably very elementary question concerning the mechanic of a function call. I want to know from within a function the name of the variables I pass down. The function makes use of the ... to allow for multiple unknown arguments, myfun = function(...) { do something } In the body I put, { nm - names(list(...)) nm } When the function is called with two vectors x, and y myfun(x, y) It returns NULL. However, when the call made is, myfun(x=x, y=y) The result is [1] x y Question : how do i get the names of the unknown variables without explicitly saying x=x... Thanks in advance. Horace __ 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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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] regular expressions : extracting numbers
I assume if you want the components to be NA then you really intend the result to be a numeric vector. The following replaces all non-digits with (thereby removing them) and then uses as.numeric to convert the result to numeric. Just omit the conversion if you want a character vector result: s - c(lema, rb 2%, rb 2%, rb 3%, rb 4%, rb 3%, rb 2%,mineuse, rb, rb, rb 12, rb, rj 30%, rb, rb, rb 25%, rb, rb, rb, rj, rb) as.numeric(gsub([^[:digit:]]+, , s)) On 7/30/07, GOUACHE David [EMAIL PROTECTED] wrote: Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 __ 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.
Re: [R] regular expressions : extracting numbers
gsub( , , gsub(%, , gsub([a-z], , c(tr3,jh40%qs dqd [1] 3 40 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 GOUACHE David a écrit : Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 __ 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.
Re: [R] regular expressions : extracting numbers
This might work: numOnly - function(x) gsub([^0-9], , x) numOnly(lema, rb 2%) [1] 2 numOnly(rb) [1] Max -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of GOUACHE David Sent: Monday, July 30, 2007 7:59 AM To: r-help@stat.math.ethz.ch Subject: [R] regular expressions : extracting numbers Hello all, I have a vector of character strings, in which I have letters, numbers, and symbols. What I wish to do is obtain a vector of the same length with just the numbers. A quick example - extract of the original vector : lema, rb 2% rb 2% rb 3% rb 4% rb 3% rb 2%,mineuse rb rb rb 12 rb rj 30% rb rb rb 25% rb rb rb rj, rb and the type of thing I wish to end up with : 2 2 3 4 3 2 12 30 25 or, instead of , NA would be acceptable (actually it would almost be better for me) Anyways, I've been battling with gsub() and things of the sort, but I'm drowning in the regular expressions, despite a few hours of looking at Perl tutorials... So if anyone can help me out, it would be greatly appreciated!! In advance, thanks very much. David Gouache Arvalis - Institut du Végétal Station de La Minière 78280 Guyancourt Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 __ 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. -- LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}} __ 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] problems saving and loading (PLMset) objects
Hi I'm running the latest R on a presumably up to date Linux server. 'Doing something silly I'm sure, but can't see why my saved PLMset objects come out all wrong. To use an example: Setting up an example PLMset (I have the same problem no matter what example I use) library(affyPLM) data(Dilution) # affybatch object Dilution = updateObject(Dilution) options(width=36) expr - fitPLM(Dilution) This works, and I'm able to get the probeset coefficients with coefs(expr). until I save and try reloading: save(expr, file=expr.RData) rm(expr) # just to be sure expr - load(expr.RData) Now, running coefs(expr) says: Error in function (classes, fdef, mtable) : unable to find an inherited method for function coefs, for signature character Trying str(exp) just gives the following: chr exp expr.Rdata appears to save properly (in that there is an actual file with notable size in my working directory). Thanks in advance, Quin [[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] Slightly OT - use of R
BDR == Prof Brian Ripley [EMAIL PROTECTED] on Mon, 30 Jul 2007 11:13:47 +0100 (BST) writes: BDR On Mon, 30 Jul 2007, [EMAIL PROTECTED] wrote: On 30-Jul-07 08:28:15, John Logsdon wrote: I am trying to get a measure of how R compares in usage as a statistical platform compared to other software. I would guess it is the most widely used among statisticians at least by virtue of it being open source. BDR I don't think that is the main reason. Most of the R users I know BDR migrated from commercial statistical software for reasons other than cost. BDR (Cross-platform availability has been one major reason.) much of this is true here (Switzerland) as well. {And some have *not* migrated because R is Free Software, but that's really another story} Note however that the (non-PhD-graduate) students we teach here would not be urged to using R if it was not the combination of its quality and its Free Software state. And I have had several acquaintances who have only started using R because they could get it so easily and quickly, and they have changed to using R as their main computational/statistical software tool. But is there any study to which I can refer? By asking this list I am not exactly adopting a rigorous approach! I don't know about that -- my own expectation would be that serious users of R are likely to be subscribers to the list. So maybe a good answer to your question would be the number of subscribers (which I'm sure Martin Maechler can find out). Of course, some people will have subscribed under more than one email address, so that would somewhat over-estimate the number of people who subscribe. But it can be traded off (to a somewhat unknown extent) against R users who do not subscribe. BDR I think it would be a seriously biased estimate. BDR Few of our hundreds of student users will be subscribed to R-help BDR (since their first port of call for help is local). BDR Also, we get quite a lot of postings via the gmane and nabble gateways. Yes, yes, yes. The exact same situation here and I'd believe in many places. And the problem with the bias ('factor' rather than 'offset' I'd say) is that it has been changing over time - I'd guess increasing pretty dramatically. My very wild subjective guess would be that #{statisticians seriously using R} / #{R-help subscribers} = = N_t / n_t is nowadays well over 20, maybe even over 100, of course depending on the definition of the numerator N_t. I could construct a very accurate time-series for n_t, but since I agree with Brian, I haven't done so for several years. Note that n_{t = 2007-07-30, 07:00} = 5559 More to the point, though, is what you mean by usage. If you simply mean people who use, that's a matter of counting (one way or another). But there's use and use. BDR Indeed. amen - Martin __ 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] Package manual examples - 'unexpected$undefined' errors
David Pain wrote: Trying out an unfamiliar package, the natural thing is to use the examples given in the package's manual - hopefully, the writers of the package wouldn't include examples which didn't work! Recently, though, I've been getting 'unexpected$undefined' error messages when doing this, despite having copy/pasted the text from the manual (taking out hard breaks on the way). Moreover, I've had error messages for commands which I've previously had work fine. For instance, this from Zelig z.out zelig(vote ~ race + educate, model = logit, data = turnout) has at different times worked fine and thrown up the error message. Any help gratefully received. [[alternative HTML version deleted]] It's hard to say exactly what's going wrong, but a guess is that in your workspace you have an object which is somehow conflicting with an object in the package. Try starting R with the --vanilla command line option and if the errors go away, that's why. I don't know whether this applies to the Zelig package, but packages that don't define namespaces are fragile in that their internal functions can be masked by same-named functions in your workspace. Even if the package does have a namespace, you can mask functions from it that you call: for example, if you had a function called zelig (perhaps because you used fix(zelig) to make a small change to the existing one), your line above would call yours, not the original. Duncan Murdoch __ 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] Odp: data order by different level of variables
Hi [EMAIL PROTECTED] napsal dne 28.07.2007 02:18:33: Dear useR, I have a data matrix, it has n columns, each column is a two-level variable with entires -1 and +1. They are randomly generated, now I want to order them like (for example, 5 columns case) --- - - -- - -- . (first several rows are the samples with all variables in low level) + - -- - + - --- . - + -- - + + -- - + + + + + Is there any function in R that could let me do this order by Var1 then order by Var2 then...order by Var n Did you try ?order Regards Petr Thanks very much in advance! Best, Leon [[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-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] Matrix Multiplication, Floating-Point, etc.
This is giving you exactly what you are asking for. The operator * does element by element multiplication. So, .48 + -.48 =0, right? Is there another mathematical possibility you were expecting? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Talbot Katz Sent: Friday, July 27, 2007 6:31 PM To: r-help@stat.math.ethz.ch Subject: [R] Matrix Multiplication, Floating-Point, etc. Hi. I recently tried the following in R 2.5.1 on Windows XP: ev2-c(0.8,-0.6) ev1-c(0.6,0.8) ev1%*%ev2 [,1] [1,] -2.664427e-17 sum(ev1*ev2) [1] 0 (I got the same result with R 2.4.1 on a different Windows XP machine.) I expect this issue is very familiar and probably has been discussed in this forum before. Can someone please point me to some documentation or discussion about this? Is there some standard way to get the correct answer from %*%? Thanks! -- TMK -- 212-460-5430 home 917-656-5351 cell __ 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.