Re: [R] Definition of lag is opposite in ts and xts objects!
On Thu, 12 Apr 2012, jpm miao wrote: Example: Will ts objects be obsolete or modified? No, I don't think so. a[,1] 1983 Q1 2.747365190 1983 Q2 2.791594762 1983 Q3 -0.009953715 1983 Q4 -0.015059485 1984 Q1 -1.190061246 1984 Q2 -0.553031799 1984 Q3 0.686874720 1984 Q4 0.953911035 lag(a,4)[,1] 1983 Q1 NA 1983 Q2 NA 1983 Q3 NA 1983 Q4 NA 1984 Q1 2.747365190 1984 Q2 2.791594762 1984 Q3 -0.009953715 1984 Q4 -0.015059485 lag(as.ts(a, start=c(1983,1)),4) Qtr1 Qtr2 Qtr3 Qtr4 1982 2.747365190 2.791594762 -0.009953715 -0.015059485 1983 -1.190061246 -0.553031799 0.686874720 0.953911035 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Could dynlm function work for xts objects?
On Thu, 12 Apr 2012, jpm miao wrote: It seems to only works for zoo or ts objects? It was tested for zoo, ts, and plain numeric vectors. I tried to run it for xts objects, and error message occurs. I had a quick look if this can be avoided. But xts' merge() method is not fully compatible with zoo's, so it currently does not work. I'll investigate whether this can be improved. Once I coerce it to be an zoo object (by as.zoo), it works. Yes, that is recommended at the moment. Z Error message: Error in model.frame.default(formula = dynformula(PIh - PI ~ L(X, 0:i) + : variable lengths differ (found for 'L(X, 0:i)') In addition: Warning messages: 1: In zoo(coredata(x), order.by = index(x), ...) : some methods for ?zoo? objects do not work if the index entries in ?order.by? are not unique 2: In zoo(coredata(x), order.by = index(x), ...) : some methods for ?zoo? objects do not work if the index entries in ?order.by? are not unique __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] loess function take
Hi The function loess takes very long time if the dataset is very huge I have around 100 records and used only one independent variable. still it takes very long time Any suggestion to reduce the time - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/loess-function-take-tp4550896p4550896.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] Significant updates to medical imaging packages: TractoR and RNiftyReg
Dear all, There have been some recent major updates to the TractoR and RNiftyReg packages, which are available for medical image analysis applications. If you use R for these purposes, I hope you will find the updates useful. RNiftyReg is an image registration package, which provides a clean R-like interface to the NiftyReg library developed at University College London [1]. It is aimed at medical image registration, but could be applied to 2D or 3D coalignment of images of any type. RNiftyReg version 0.6 adds an interface to the NiftyReg nonlinear registration tool f3d, which performs fast freeform deformation-based registration based on a grid of control points. This is a fast implementation, which can perform 3D registration in under a minute for some medical images. The package is on CRAN, and development is coordinated through GitHub [2]. TractoR is a larger project for medical image analysis, particularly with magnetic resonance images [3]. It provides tools for reading, writing, visualising, manipulating and processing MR images in R. The tractor.base package is on CRAN, and forms the backbone of the project. Significant additions to this package in the 2.x series of releases include: - Extensive use of the reference classes introduced in R 2.12.0. - Coercion methods between TractoR's MriImage class and the nifti class in the oro.nifti package. - Specific support for sparse images (of any dimensionality). - The ability to read and write the MGH file format used by the Freesurfer software package. - A substantial number of other functionality and performance improvements, as well as bug fixes. The full TractoR distribution includes four other R packages, each somewhat more specialised than tractor.base, as well as a flexible command-line interface which can be used to perform common tasks quickly. Details can be found in a recent JSS paper on TractoR [4]. All the best, Jon [1] http://sourceforge.net/projects/niftyreg/ [2] https://github.com/jonclayden/RNiftyReg [3] http://www.tractor-mri.org.uk [4] http://www.jstatsoft.org/v44/i08/ -- Jonathan D Clayden, PhD Lecturer in Neuroimaging and Biophysics Imaging and Biophysics Unit UCL Institute of Child Health 30 Guilford Street LONDON WC1N 1EH United Kingdom t | +44 (0)20 7905 2708 f | +44 (0)20 7905 2358 w | www.homepages.ucl.ac.uk/~sejjjd2/ w | www.diffusion-mri.org.uk/people/1 ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot lattice fine control of axes limits and thick marks (with log scale)
ok this is these are the final results: by relation free vs sliced vs scale component function relation free http://r.789695.n4.nabble.com/file/n4551068/relation_free.png relation sliced http://r.789695.n4.nabble.com/file/n4551068/relation_sliced.png scale component function http://r.789695.n4.nabble.com/file/n4551068/scale_component_function.png at the very end (I hope) of this troubled story I think the only approach can guarantee the full accomplishment of what I need is the last one by elai dealing with the scale component function; I've been reading of something alike in Sarkaar book (page 147) but I could not make it working thank you all for spending time in this thread, I've been learning a lot! bye max -- View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4551068.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] row.names in dunes and dunes.env?
Hi see inline Hello, I've got a small dataset on box turtle shell measurements that I would like to perform a detrended correspondence analysis on. I thought that it would be interesting to examine the morphometrics for each species in the area of overlap and in areas where neither species occurs. I've taken a look at the dune and dune.env datasets in vegan. Using the str() command gives me str(dune) 'data.frame': 20 obs. of 30 variables: $ Belper: num 3 0 2 0 0 0 0 2 0 0 ... $ Empnig: num 0 0 0 0 0 0 0 0 0 0 ... $ Junbuf: num 0 3 0 0 0 0 0 0 0 0 ... $ Junart: num 0 0 0 3 0 0 4 0 0 3 ... ... However, when I try looking directly at the data frame using the edit command I see that there is a column called row.names to the left of Belper. Likewise, when I use the str() command on dune.env I get str(dune.env) 'data.frame': 20 obs. of 5 variables: $ A1: num 3.5 6 4.2 5.7 4.3 2.8 4.2 6.3 4 11.5 ... $ Moisture : Ord.factor w/ 4 levels 1245: 1 4 2 4 1 1 4 1 2 4 ... $ Management: Factor w/ 4 levels BF,HF,NM,..: 1 4 4 4 2 4 2 2 3 3 ... $ Use : Ord.factor w/ 3 levels HayfieldHaypastu..: 2 2 2 3 2 2 3 1 1 2 ... $ Manure: Ord.factor w/ 5 levels 0123..: 3 4 5 4 3 5 4 3 1 1 ... but using the edit() command shows a column named row.names. No. This is not a column but it is what it says row.names str(rosin) 'data.frame': 10 obs. of 5 variables: $ pytel: int 1 2 3 4 5 6 7 8 9 10 $ rstr : num 1.022 0.981 0.992 1.01 0.976 ... $ gama : num 1.4 1.44 1.41 1.43 1.39 ... $ cas : int 0 3 6 9 12 15 18 21 24 27 $ typ : chr anatas anatas anatas anatas head(rosin) pytel rstr gama castyp 1 1 1.0216621 1.397885 0 anatas 2 2 0.9809663 1.442439 3 anatas 3 3 0.9916211 1.411767 6 anatas ^^ these are row names I assume that the the row.names column is used to link the two files together. If you are in doubt, recommended way is to consult documentation. ?row.names All data frames have a row names attribute, a character vector of length the number of rows with no duplicates nor missing values. My turtle data is saved as a *.csv, and I've added a column called row.names, so that it looks like this row.names,CL,CCL,CW,CCW,CH,CCH 1,104.4,131.8,89.887,137.4,43.391,89.7 2,108.79,135.9,87.78,118.1,50.72,71.2 3,114.12,126.1,89.33,132.8,142.39,78.3 4,102.87,128.2,84.2,125,45.42,72.4 5,84.6,104.8,72.61,111.8,41.1,57.3 I've called this file turtles_dca.csv. I've also created a file called turtles_dca_env.csv that looks like this row.names,Species,Sex,Distribution,Concatenated,Species_overlap 1,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap 2,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap 3,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap 4,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap 5,Terrapene_ornata,Female,overlap,TO_F_Overlap,TO_Overlap However, when I read the data into R using this command turtles.env = read.csv(turtles_dca_env.csv, header = TRUE) and then using the str() command I get str(turtles) 'data.frame': 67 obs. of 7 variables: $ row.names: int 1 2 3 4 5 6 7 8 9 10 ... $ CL : num 104.4 108.8 114.1 102.9 84.6 ... $ CCL : num 132 136 126 128 105 ... $ CW : num 89.9 87.8 89.3 84.2 72.6 ... $ CCW : num 137 118 133 125 112 ... $ CH : num 43.4 50.7 142.4 45.4 41.1 ... $ CCH : num 89.7 71.2 78.3 72.4 57.3 73.4 67 57 68.8 68 ... When I run decorana() on this dataset, it appears that the column row.names is included in the analysis, which isn't what I'm looking for. Then why you added this column to your data? If I go ahead and delete the column row.names from my data frames (i.e. removing it from turtles and turtles.env), I don't believe that the analysis is performed correctly. The two species differ significantly in most of their measurements, but the ordihull() and ordispider() commands show them overlapping almost completely. I think that I'm missing something pretty basic about inputting and formatting this data for this analysis. Can anyone offer a suggestion on where I'm going astray? I can send a copy of the data if anyone wants to look at it. I am not familiar with functions you use. However you probably want to link those 2 files together. If they both are in the same order you can just do turtles.complet - cbind(turtles, turtles.env) Or if they are in different order you need to find some common column(s) and ?merge those two files. Regards Petr Best wishes, Chris University of Central Oklahoma [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,
[R] Recode Variable
Hello everybody, I know this is pretty basic stuff, but could anyone explain me how to recode a single value of a variable into a missing value? I used to do it like this: myData[myData$var1==5;var1]-NA # recode value 5 into NA But the column var1 already contains NAs, which results in the following error message: missing values are not allowed in subscripted assignments of data frames Thank you very much for any advice! David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Encoding of Sweave file error message
I also had the same problem. Being on Linux, I prefer Walmes' command line method but I found that putting \usepackage[utf8x]{inputenc} as the first instruction in the master .Rnw file also does the trick. No need to change anything after that in the file, at least not for me! Rgds, Rainer On Thursday 12 April 2012 14:13:06 Duncan Mackay wrote: At 12:03 12/04/2012, you wrote: I had the same problem! So, as I'm a linux user, I prefer use linux terminal. On terminal I type this to compile R CMD Sweave --encoding=utf-8 myfile.Rnw and the compilation is successful. Try to set the encoding option in Sweave(). Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: mailto:wal...@ufpr.brwal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/%7Ewalmeshttp://www.leg.ufpr.br/~walmes linux user number: 531218 == Hi Walmes Thank you very much. That appears to be the problem. When I typed from the DOS terminal I have exactl ParasiteComb12.Rnw it compiled the tex file without any error messages. I have not really got into font encoding and reading the Sweave manual I thought that what I had done would be sufficient. I found an old note which gave a reference to http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4725.html http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4889.html but that appears to be specific. The ?Sweave and the Sweave manual appear to be more specific about the latex side. After having a look at iconvlist() and bearing in mind Duncan Murdoch's comments about windows I tried Sweave(D:/Cic/Sweave/Parasite/Comb/12/ParasiteComb12.Rnw, encoding = UTF-8) from the Rgui command window and compiled without any problems When I had a look at the tex file there were a few DOS Alt-248 (degree symbol ) within latex comments which were added last running R2.14 before updating Removing them and re running without the encoding argument brought things back to normal. I tried as a test \SweaveOpts{encoding=UTF8} but that appears not to work All I have to do now is to put the extra argument into my text editors clip library for Sweave for next time when I cannot solve things. Its been a long week ! Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email home: mac...@northnet.com.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recode Variable
Hi David, You bring up a good question. I am not sure what is the right way to solve it. But here is a simple solution I put together: x = c(1:10,5) y = x x[c(2,3)] - NA # reproducing the problem: y[x==5] na2F - function(x) { x2 - x x2[is.na(x)] - F x2 } na2F(x==5) # solved y[na2F(x==5)] I'd be happy to see other solutions to it. With regards, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Thu, Apr 12, 2012 at 12:08 PM, David Studer stude...@gmail.com wrote: Hello everybody, I know this is pretty basic stuff, but could anyone explain me how to recode a single value of a variable into a missing value? I used to do it like this: myData[myData$var1==5;var1]-NA # recode value 5 into NA But the column var1 already contains NAs, which results in the following error message: missing values are not allowed in subscripted assignments of data frames Thank you very much for any advice! David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recode Variable
Le jeudi 12 avril 2012 à 12:29 +0300, Tal Galili a écrit : Hi David, You bring up a good question. I am not sure what is the right way to solve it. But here is a simple solution I put together: x = c(1:10,5) y = x x[c(2,3)] - NA # reproducing the problem: y[x==5] na2F - function(x) { x2 - x x2[is.na(x)] - F x2 } na2F(x==5) # solved y[na2F(x==5)] I'd be happy to see other solutions to it. You can simply use the built-in function which() for this, since it removes NAs, only returning the position of TRUE elements: which(c(NA, 1:10 == 5)) [1] 6 My two cents __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recode Variable
Le jeudi 12 avril 2012 à 11:08 +0200, David Studer a écrit : Hello everybody, I know this is pretty basic stuff, but could anyone explain me how to recode a single value of a variable into a missing value? I used to do it like this: myData[myData$var1==5;var1]-NA # recode value 5 into NA But the column var1 already contains NAs, which results in the following error message: missing values are not allowed in subscripted assignments of data frames Thank you very much for any advice! You can just do this: myData - data.frame(var1=1:10) myData$var1[2]-NA myData[myData$var1 == 5, var1] - NA # Fails myData$var1[myData$var1 == 5] - NA # Works myData var1 1 1 2NA 3 3 4 4 5NA 6 6 7 7 8 8 9 9 10 10 Regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Schedule R script using cron
On 12.04.2012 03:51, winie wrote: I am trying to schedule my R script using cron, but it is not working. It seems R can not find packages in cron. Anyone can help me? Thanks. The following is my bash script # source my porfile . /home/winie/.profile # script.R will load packages R CMD BATCH /home/script.R Maybe it does not call the R version your expect? Or you have not set the pat to the library given the packages are not installed in R's main library in R_HOME? Uwe Ligges -- View this message in context: http://r.789695.n4.nabble.com/Schedule-R-script-using-cron-tp4550729p4550729.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loess function take
On 12.04.2012 05:49, arunkumar wrote: Hi The function loess takes very long time if the dataset is very huge I have around 100 records and used only one independent variable. still it takes very long time Any suggestion to reduce the time Use another method that is computationally less expensive for that many observations. Uwe Ligges - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/loess-function-take-tp4550896p4550896.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] r software resource persons India (hyd)
Looking for r-software resource persons for the Sensitization and Capacity Building Workshop on Free Software and Knowledge Initiatives in Agricultural Research for Development to be held in the month of July 2012 at Hyderabad. https://sites.google.com/site/fskiard/ __ Sridhar Gutam PhD, ARS, Patent Laws (NALSAR), IP Biotech. (WIPO) Senior Scientist (Plant Physiology) Central Institute for Subtropical Horticulture http://www.cishlko.org Rehmankhera, Kakori Post Lucknow 227107, Uttar Pradesh, India Phone: +91-522-2841022/23/24; Fax: +91-522-2841025 Mobile:+91-9005760036/8005346136 https://www.facebook.com/gutamsridhar http://www.linkedin.com/in/sridhargutam http://twitter.com/gutam2000http://works.bepress.com/sridhar_gutam/rss.html [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recode Variable
1. Some data structured the way you are using would have been helpful. I used Tal Galil's play data and set up a dataframe with the variable names you are using: structure(list(var1 = c(1, NA, NA, 4, 5, 6, 7, 8, 9, 10, 5), var2 = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5)), .Names = c(var1, var2), row.names = c(NA, -11L), class = data.frame) myData var1 var2 1 11 2NA2 3NA3 4 44 5 55 6 66 7 77 8 88 9 99 10 10 10 1155 2. The error message I get from your line of code is myData[myData$var1==5;var1]-NA Error: unexpected ';' in myData[myData$var1==5; Probably the semikolon is a typo? 3. If I understand your question correctly, the easiest answer I can find is ifelse(): myData$var1 - ifelse( myData$var1 == 5, NA, myData$var1 ) myData var1 var2 1 11 2NA2 3NA3 4 44 5NA5 6 66 7 77 8 88 9 99 10 10 10 11 NA5 Rgds, Rainer On Thursday 12 April 2012 11:08:45 David Studer wrote: Hello everybody, I know this is pretty basic stuff, but could anyone explain me how to recode a single value of a variable into a missing value? I used to do it like this: myData[myData$var1==5;var1]-NA # recode value 5 into NA But the column var1 already contains NAs, which results in the following error message: missing values are not allowed in subscripted assignments of data frames Thank you very much for any advice! David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Seeking help with LOGIT model
Dear all, I am fitting a LOGIT model on this Data... Data - structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 47, 58, 82, 100, 222, 164, 161, 70, 219, 81, 209, 182, 185, 104, 126, 192, 95, 245, 97, 177, 125, 56, 85, 199, 298, 145, 78, 144, 178, 146, 132, 98, 120, 148, 123, 282, 79, 34, 104, 91, 199, 101, 109, 117, 1.1, 0.92, 1.72, 2.18, 1.75, 2.26, 2.07, 1.43, 1.92, 1.82, 2.34, 2.12, 1.81, 1.35, 1.26, 2.07, 2.04, 1.55, 1.89, 1.68, 0.76, 1.96, 1.29, 1.81, 1.72, 2.39, 1.68, 2.29, 2.34, 2.21, 1.42, 1.97, 2.12, 1.9, 1.15, 1.7, 1.24, 1.55, 2.04, 1.59, 2.07, 2, 1.84, 2.04, 51.2, 48.5, 50.8, 54.4, 52.4, 56.7, 54.6, 52.7, 52.3, 53, 55.4, 53.5, 51.6, 48.5, 49.3, 53.9, 55.7, 51.2, 54, 52.2, 51.1, 54, 55, 52.9, 53.7, 55.8, 50.4, 58.8, 54.5, 53.5, 48.8, 54.5, 52.1, 56, 56.2, 53.3, 50.9, 53.2, 51.7, 54.3, 53.7, 54.7, 47, 56.9, 0.321, 0.224, 0.127, 0.063, 0.021, 0.027, 0.139, 0.218, 0.008, 0.012, 0.076, 0.299, 0.04, 0.069, 0.33, 0.017, 0.166, 0.003, 0.01, 0.076, 0.454, 0.032, 0.266, 0.018, 0.038, 0.067, 0.075, 0.064, 0.065, 0.065, 0.09, 0.016, 0.061, 0.019, 0.389, 0.037, 0.161, 0.127, 0.017, 0.222, 0.026, 0.012, 0.057, 0.022, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0), .Dim = c(44L, 6L), .Dimnames = list( c(Obs 1, Obs 2, Obs 3, Obs 4, Obs 5, Obs 6, Obs 7, Obs 8, Obs 9, Obs 10, Obs 11, Obs 12, Obs 13, Obs 14, Obs 15, Obs 16, Obs 17, Obs 18, Obs 19, Obs 20, Obs 21, Obs 22, Obs 23, Obs 24, Obs 25, Obs 26, Obs 27, Obs 28, Obs 29, Obs 30, Obs 31, Obs 32, Obs 33, Obs 34, Obs 35, Obs 36, Obs 37, Obs 38, Obs 39, Obs 40, Obs 41, Obs 42, Obs 43, Obs 44), c(Y, X 1, X 2, X 3, X 4, X 5))) glm(Data[,1] ~ Data[,-1], binomial(link = logit)) Call: glm(formula = Data[, 1] ~ Data[, -1], family = binomial(link = logit)) Coefficients: (Intercept) Data[, -1]X 1 Data[, -1]X 2 Data[, -1]X 3 Data[, -1]X 4 Data[, -1]X 5 10.993260.01943 10.61013 -0.66763 70.98785 17.33126 Degrees of Freedom: 43 Total (i.e. Null); 38 Residual Null Deviance: 44.58 Residual Deviance: 17.46AIC: 29.46 Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred However I am getting a warning mesage as fitted probabilities numerically 0 or 1 occurred. Here my question is, have I made any mistakes with my above implementation? Is it just because, I have too less number of '0' in my response Variable? Thanks for your help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reading SPSS: underlying numerical codes
Dear people, I have got a question concerning the underlying numerical codes when reading an SPSS file into R. I used the package foreign and when I look at a variable I get the verbal codes. I would like to know how it is possible to get the underlying numerical codes as output, which are the same as in my SPSS file. Thank you very much in advance for your help! Marion [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Schedule R script using cron
winie winieb...@gmail.com on Wed, 11 Apr 2012 18:51:28 -0700 writes: I am trying to schedule my R script using cron, but it is not working. It seems R can not find packages in cron. Anyone can help me? Thanks. The following is my bash script # source my porfile . /home/winie/.profile # script.R will load packages R CMD BATCH /home/script.R This has almost nothing to with R, but with running scripts in cron. On the systems, I've been using, the default shell cron uses is very simple, e.g., PATH = /usr/bin:/bin , so I assume that's why you source your (bash ?) profile, . /home/winie/.profile above. But that may not be sufficient; there are other settings, missing in the simple cron environment, that your .profile does not fix up, such as LD_LIBRARY_PATH, R_LIBS, R_PROFILE, ... I would add a line to your bash script env /tmp/cron_env_$$ after the . /home/winie/.profile line, and see how that (cron_env_... file) differs from what you get when you type 'env' in a regular interactive shell where (I assume) your 'R CMD BATCH ...' works correctly. Hoping that helps, Martin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Seeking help with LOGIT model
Christofer Bogaso bogaso.christofer at gmail.com writes: Dear all, I am fitting a LOGIT model on this Data... snip --- glm(Data[,1] ~ Data[,-1], binomial(link = logit)) Call: glm(formula = Data[, 1] ~ Data[, -1], family = binomial(link = logit)) Coefficients: (Intercept) Data[, -1]X 1 Data[, -1]X 2 Data[, -1]X 3 Data[, -1]X 4 Data[, -1]X 5 10.993260.01943 10.61013 -0.66763 70.98785 17.33126 Degrees of Freedom: 43 Total (i.e. Null); 38 Residual Null Deviance: 44.58 Residual Deviance: 17.46AIC: 29.46 Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred However I am getting a warning mesage as fitted probabilities numerically 0 or 1 occurred. Here my question is, have I made any mistakes with my above implementation? I s it just because, I have too less number of '0' in my response Variable? Look at the output of summary, especially the standard errors. You seem to be getting complete separation on X5 and X4 doesn,'t look so hot either. Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] strsplit help
Thanks - I checked through and it looks as if all of the geneids are formatted similarily so I don't know which one would be causing an error. Interestingly, your sapply method works on the same data. So I'm happy although still confused, because the strsplit method worked the other day with a similarly generated dataset. I dumped my entire dataframe below. Incase anyone wants to investigate. Alison Rumino_Reps_agreeWalign$geneid.prefix - sapply(gene.list, [, 1) Rumino_Reps_agreeWalign$geneid.suffix - sapply(gene.list, [, 2) dput(Rumino_Reps_agreeWalign) structure(list(geneid = c(657313.locus_tag:RTO_08940, 457412.251848018, 657314.locus_tag:CK5_20630, 657323.locus_tag:CK1_33060, 657313.locus_tag:RTO_09690, 471875.197297106, 411470.DS231493.G14, 411459.149830627, 657313.locus_tag:RTO_09720, 411460.145845997, 411459.149831369, 657321.locus_tag:RBR_01830, 411460.145846414, 457412.251848805, 657321.locus_tag:RBR_08030, 471875.197296907, 457412.251847995, 657314.locus_tag:CK5_20840, 411460.145846423, 657314.locus_tag:CK5_25030, 457412.251847990, 471875.197297117, 471875.197299322, 411459.149831093, 411459.149831815, 411460.145846434, 213810.locus_tag:RUM_09700, 657314.locus_tag:CK5_09460, 657323.locus_tag:CK1_18840, 471875.197297108, 411460.145846680, 411459.149831368, 657314.locus_tag:CK5_19120, 657321.locus_tag:RBR_09560, 411460.145846435, 657323.locus_tag:CK1_11530, 457412.251850723, 213810.locus_tag:RUM_12960, 213810.locus_tag:RUM_14740, 213810.locus_tag:RUM_07030, 471875.197296936, 411459.149831092, 471875.197297110, 471875.197298135, 411460.145846430, 657314.locus_tag:CK5_20370, 657313.locus_tag:RTO_09790, 657323.locus_tag:CK1_33050, 411460.145846407, 457412.251849909, 411460.145846340, 657313.locus_tag:RTO_14810, 457412.251848010, 457412.251850599, 657323.locus_tag:CK1_33200, 657323.locus_tag:CK1_33190, 213810.locus_tag:RUM_03050, 657314.locus_tag:CK5_09880, 213810.locus_tag:RUM_15180, 657313.locus_tag:RTO_14610, 657313.locus_tag:RTO_23930, 411459.149830473, 657313.locus_tag:RTO_18090, 657323.locus_tag:CK1_27940, 657314.locus_tag:CK5_20720, 411459.149831855, 471875.197297691, 411459.149833320, 457412.251849358, 657321.locus_tag:RBR_13130, 411459.149831077, 471875.197297272, 657314.locus_tag:CK5_09370, 457412.251847994, 411459.149831080, 657314.locus_tag:CK5_20730, 457412.251850579, 213810.locus_tag:RUM_14870, 657321.locus_tag:RBR_01750, 657313.locus_tag:RTO_09660, 657314.locus_tag:CK5_28910, 411460.145846907, 657313.locus_tag:RTO_09860, 457412.251847996, 657323.locus_tag:CK1_38480, 411460.145846417, 471875.197297592, 411459.149831814, 457412.251848016, 411459.149831804, 657323.locus_tag:CK1_32880, 657321.locus_tag:RBR_08130, 411460.145846429, 657313.locus_tag:RTO_09880, 213810.locus_tag:RUM_03410, 657313.locus_tag:RTO_09740, 657313.locus_tag:RTO_09840, 457412.251848009, 657323.locus_tag:CK1_33090, 657323.locus_tag:CK1_25000, 411459.149831095, 411459.149830934, 457412.251847970, 457412.251848000, 657314.locus_tag:CK5_20680, 411459.149831088, 657323.locus_tag:CK1_19350, 657321.locus_tag:RBR_08670, 471875.197299547, 411459.149831081, 657323.locus_tag:CK1_32550, 411459.149831091, 657313.locus_tag:RTO_24580, 457412.251848004, 471875.197297195, 411460.145846602, 657321.locus_tag:RBR_06200, 213810.locus_tag:RUM_19570, 411460.145846361, 411459.149833804, 657323.locus_tag:CK1_32930, 471875.197296906, 411459.149831078, 657321.locus_tag:RBR_09900, 411460.145846496, 657321.locus_tag:RBR_08260, 411459.149833021, 657313.locus_tag:RTO_02600, 657323.locus_tag:CK1_33030, 657313.locus_tag:RTO_09750, 213810.locus_tag:RUM_14790, 457412.251848017, 457412.251848806, 457412.251847640, 657314.locus_tag:CK5_20620, 411459.149830474, 657323.locus_tag:CK1_11750, 213810.locus_tag:RUM_09690, 457412.251847999, 657321.locus_tag:RBR_05870, 411460.145846409, 657313.locus_tag:RTO_16220, 657321.locus_tag:RBR_10630, 411459.149833026, 457412.251847997, 657313.locus_tag:RTO_09650, 471875.197297129, 471875.197297112, 213810.locus_tag:RUM_14720, 457412.251847991, 657313.locus_tag:RTO_09730, 471875.197297132, 657313.locus_tag:RTO_14650, 411470.DS231491.G186, 457412.251849520, 657323.locus_tag:CK1_04710, 657323.locus_tag:CK1_04510, 411460.145846182, 411460.145846883, 657321.locus_tag:RBR_08040, 411459.149833983, 457412.251849519, 471875.197297124, 457412.251849906, 657321.locus_tag:RBR_08010, 657321.locus_tag:RBR_03380, 657323.locus_tag:CK1_20230, 471875.197297115, 657323.locus_tag:CK1_13100, 657323.locus_tag:CK1_32950, 411460.145846428, 471875.197297120, 213810.locus_tag:RUM_13040, 657314.locus_tag:CK5_25080, 411459.149831096, 411459.149831090, 411459.14981, 411459.149831370, 657313.locus_tag:RTO_26330, 411459.149833340, 657314.locus_tag:CK5_20590, 411460.145846458, 471875.197297290, 657313.locus_tag:RTO_09850, 213810.locus_tag:RUM_12130, 657323.locus_tag:CK1_32910, 213810.locus_tag:RUM_09770, 657313.locus_tag:RTO_09640, 657313.locus_tag:RTO_09830, 457412.251849013, 411460.145847544,
[R] How insert data to a column in existing csv file?
I was working with some excel files with a lot of data. And by hand it is impossible to handle them. So they are now converted to .csv. With headers above the columns, like: Data1, Data2, Data3 But now I needed to calculate the log2 value of Data1 and place the result under Data2. I can't find how to do that. Does anyone else know? I have the log2 values, but how do I get then inside the .csv file under Data2? I already tried write.table(), buy that wasn't it. And I am kinda stuck on this now. -- View this message in context: http://r.789695.n4.nabble.com/How-insert-data-to-a-column-in-existing-csv-file-tp4551327p4551327.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How insert data to a column in existing csv file?
Hi, You can use write.table with Append = TRUE to keep on writing in the same csv file, but I don't know how to write in an specific cell of your csv file. http://stat.ethz.ch/R-manual/R-devel/library/utils/html/write.table.html write.table (data, file = example.csv, sep = ;, col.names = NA, append = TRUE, dec =,) I think the best thing to do once you have imported your data into R is to create a new csv file and write in it the table you need. Hope it helps, R -- View this message in context: http://r.789695.n4.nabble.com/How-insert-data-to-a-column-in-existing-csv-file-tp4551327p4551441.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] General question on the message with non zero exit status
I have a general question how to understand the message with non-zero exit status when new package is installed. Based on my experience, this message implies a package dependence. Am I correct to understand this message? Are there anyone who can provide some reference or explain details about the message with non zero exit status? I very appreciate for your kindness in advance. -- View this message in context: http://r.789695.n4.nabble.com/General-question-on-the-message-with-non-zero-exit-status-tp4551438p4551438.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Recode Variable
myData[myData$var1==5;var1]-NA # recode value 5 into NA try myData[!is.na(myData$var1) myData$var1==5;var1]-NA or, more simply, myData$var1[myData$var1==5]-NA *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help in creating a matrix
Hi I have dataset with n variables, say n =3 x y z the formula should be form = x+y+z+x*x +x*y+x*z +y*y + y*z+z*z my code has to for loop Is there any way to reduce two loops for (i in 1:n) { for (j in i:n) { dat= cbind(dat,dat[,i]*dat[,j]) } } - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-creating-a-matrix-tp4551532p4551532.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Support for R in highlight.js
Hello, I'm the maintainer of a syntax highlighting tool highlight.js[1]. Recently the Kaggle project has announced they wanted to sponsor the development of the R highlighting definition for it[2]. I wanted to drop a line about it here since I suspect this list has much more R programmers on it than our small discussion group :-). So if you're interested and don't mind touching a little bit of JavaScript — please reply to the announcement or personally to Adam Kennedy adam.kenn...@kaggle.com who's behind it from the Kaggle side. [1]: http://softwaremaniacs.org/soft/highlight/en/ [2]: https://groups.google.com/d/topic/highlightjs/-ogtOaK-TQY/discussion __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving multiple plots using tiff function
Dear R users, I still did not receive an answer to my question and went through the archive with no luck. So what does tiff(filename =Rplot%03d.tif) mean ? Why the following code does produce two files? tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10, compression = lzw) plot(1) mtext(Fig 1,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(2) mtext(Fig 2,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(3) mtext(Fig 3,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) dev.off() Your help is appreciated, John On Fri, Apr 6, 2012 at 2:26 PM, John S john.smith...@gmail.com wrote: Sorry forgot to mention that I am using windows 7 and R session info R version 2.15.0 (2012-03-30) Platform: i386-pc-mingw32/i386 (32-bit Thanks, John On Fri, Apr 6, 2012 at 2:17 PM, John S john.smith...@gmail.com wrote: Dear R experts, I am trying to save three plots using tiff graphics devices; however the following code only produces two files (Rplot002.tif and Rplot003.tif) showing figures 1 and 3. Here is a simplified ex code tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10, compression = lzw) plot(1) mtext(Fig 1,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(2) mtext(Fig 2,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(3) mtext(Fig 3,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) dev.off() Using pdf () produces the correct 3 figures but I want to use tiff images .Any clues why this occurs? I am opening a tiff graphics device and writing plots to files in a loop so I need to have a single call to tiff(). Thanks, John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Seeking help with LOGIT model
Thanks Ken for your reply. No doubt your english is quite tough!! I understand something is not normal with the 5th explanatory variable (se:2872.17069!) However could not understand what you mean by You seem to be getting complete separation on X5 ? Can you please be more elaborate? Thanks, On Thu, Apr 12, 2012 at 4:06 PM, ken knoblauch ken.knobla...@inserm.fr wrote: Christofer Bogaso bogaso.christofer at gmail.com writes: Dear all, I am fitting a LOGIT model on this Data... snip --- glm(Data[,1] ~ Data[,-1], binomial(link = logit)) Call: glm(formula = Data[, 1] ~ Data[, -1], family = binomial(link = logit)) Coefficients: (Intercept) Data[, -1]X 1 Data[, -1]X 2 Data[, -1]X 3 Data[, -1]X 4 Data[, -1]X 5 10.99326 0.01943 10.61013 -0.66763 70.98785 17.33126 Degrees of Freedom: 43 Total (i.e. Null); 38 Residual Null Deviance: 44.58 Residual Deviance: 17.46 AIC: 29.46 Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred However I am getting a warning mesage as fitted probabilities numerically 0 or 1 occurred. Here my question is, have I made any mistakes with my above implementation? I s it just because, I have too less number of '0' in my response Variable? Look at the output of summary, especially the standard errors. You seem to be getting complete separation on X5 and X4 doesn,'t look so hot either. Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading SPSS: underlying numerical codes
Hi Marion, Did you look at the help file? Did you try use.value.labels = FALSE? Best, Ista On Thu, Apr 12, 2012 at 6:28 AM, Marion Wenty marion.we...@gmail.com wrote: Dear people, I have got a question concerning the underlying numerical codes when reading an SPSS file into R. I used the package foreign and when I look at a variable I get the verbal codes. I would like to know how it is possible to get the underlying numerical codes as output, which are the same as in my SPSS file. Thank you very much in advance for your help! Marion [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to calculate the McFadden R-square for LOGIT model?
Dear all, can somebody please help me how to calculate McFadden R-square for a LOGIT model? Corresponding definition can be found here: http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp?topic=%2Fcom.ibm.spss.statistics.help%2Falg_plum_statistics_rsq_mcfadden.htm Here is my data: Data - structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 47, 58, 82, 100, 222, 164, 161, 70, 219, 81, 209, 182, 185, 104, 126, 192, 95, 245, 97, 177, 125, 56, 85, 199, 298, 145, 78, 144, 178, 146, 132, 98, 120, 148, 123, 282, 79, 34, 104, 91, 199, 101, 109, 117, 1.1, 0.92, 1.72, 2.18, 1.75, 2.26, 2.07, 1.43, 1.92, 1.82, 2.34, 2.12, 1.81, 1.35, 1.26, 2.07, 2.04, 1.55, 1.89, 1.68, 0.76, 1.96, 1.29, 1.81, 1.72, 2.39, 1.68, 2.29, 2.34, 2.21, 1.42, 1.97, 2.12, 1.9, 1.15, 1.7, 1.24, 1.55, 2.04, 1.59, 2.07, 2, 1.84, 2.04, 51.2, 48.5, 50.8, 54.4, 52.4, 56.7, 54.6, 52.7, 52.3, 53, 55.4, 53.5, 51.6, 48.5, 49.3, 53.9, 55.7, 51.2, 54, 52.2, 51.1, 54, 55, 52.9, 53.7, 55.8, 50.4, 58.8, 54.5, 53.5, 48.8, 54.5, 52.1, 56, 56.2, 53.3, 50.9, 53.2, 51.7, 54.3, 53.7, 54.7, 47, 56.9, 0.321, 0.224, 0.127, 0.063, 0.021, 0.027, 0.139, 0.218, 0.008, 0.012, 0.076, 0.299, 0.04, 0.069, 0.33, 0.017, 0.166, 0.003, 0.01, 0.076, 0.454, 0.032, 0.266, 0.018, 0.038, 0.067, 0.075, 0.064, 0.065, 0.065, 0.09, 0.016, 0.061, 0.019, 0.389, 0.037, 0.161, 0.127, 0.017, 0.222, 0.026, 0.012, 0.057, 0.022, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0), .Dim = c(44L, 6L), .Dimnames = list( c(Obs 1, Obs 2, Obs 3, Obs 4, Obs 5, Obs 6, Obs 7, Obs 8, Obs 9, Obs 10, Obs 11, Obs 12, Obs 13, Obs 14, Obs 15, Obs 16, Obs 17, Obs 18, Obs 19, Obs 20, Obs 21, Obs 22, Obs 23, Obs 24, Obs 25, Obs 26, Obs 27, Obs 28, Obs 29, Obs 30, Obs 31, Obs 32, Obs 33, Obs 34, Obs 35, Obs 36, Obs 37, Obs 38, Obs 39, Obs 40, Obs 41, Obs 42, Obs 43, Obs 44), c(Y, X 1, X 2, X 3, X 4, X 5))) AND, my model is: glm(Data[,1] ~ Data[,-1], binomial(link = logit)) Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving multiple plots using tiff function
On 12-04-2012, at 13:07, John S wrote: Dear R users, I still did not receive an answer to my question and went through the archive with no luck. So what does tiff(filename =Rplot%03d.tif) mean ? Just read the documentation for tiff: ?tiff Why the following code does produce two files? It produces no files for me. Only an error message. tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10, compression = lzw) plot(1) mtext(Fig 1,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(2) mtext(Fig 2,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(3) mtext(Fig 3,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) dev.off() You must specify the antialias argument. Which I did: I set it to none and got 3 .tif (plot) files. So I don't know what's wrong with your stuff. Berend __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Seeking help with LOGIT model
You should look up the Hauck-Donne phenomenon, which shows that with binomial GLMs, the standard error can grow faster than the effect size. Complete separation results, for example, when one predictor (or a combination of several predictors) perfectly predicts the response. Something like this seems to be happening for variables 4 and 5. You could try the brglm function from the package of the same name, which uses bias correction. Compare (after coercing your Data to a data frame): summary(glm(Y ~ ., binomial, Data)) Call: glm(formula = Y ~ ., family = binomial, data = Data) Deviance Residuals: Min1QMedian3Q Max -2.00979 0.0 0.6 0.27987 1.82302 Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) 10.99326 20.77336 0.529 0.5967 `X 1` 0.019430.01040 1.868 0.0617 . `X 2` 10.610135.65409 1.877 0.0606 . `X 3` -0.667630.47668 -1.401 0.1613 `X 4` 70.98785 36.41181 1.950 0.0512 . `X 5` 17.33126 2872.17069 0.006 0.9952 summary(brglm(Y ~ ., binomial, Data)) Call: brglm(formula = Y ~ ., family = binomial, data = Data) Coefficients: Estimate Std. Error z value Pr(|z|) (Intercept) 12.017791 14.337183 0.838 0.4019 `X 1`0.014898 0.008263 1.803 0.0714 . `X 2`8.307941 4.010792 2.071 0.0383 * `X 3` -0.576309 0.352097 -1.637 0.1017 `X 4` 35.627644 16.638766 2.141 0.0323 * `X 5`2.134544 2.570756 0.830 0.4064 Good luck. Ken Quoting Christofer Bogaso bogaso.christo...@gmail.com: Thanks Ken for your reply. No doubt your english is quite tough!! I understand something is not normal with the 5th explanatory variable (se:2872.17069!) However could not understand what you mean by You seem to be getting complete separation on X5 ? Can you please be more elaborate? Thanks, On Thu, Apr 12, 2012 at 4:06 PM, ken knoblauch ken.knobla...@inserm.fr wrote: Christofer Bogaso bogaso.christofer at gmail.com writes: Dear all, I am fitting a LOGIT model on this Data... snip --- glm(Data[,1] ~ Data[,-1], binomial(link = logit)) Call: glm(formula = Data[, 1] ~ Data[, -1], family = binomial(link = logit)) Coefficients: (Intercept) Data[, -1]X 1 Data[, -1]X 2 Data[, -1]X 3 Data[, -1]X 4 Data[, -1]X 5 10.99326 0.01943 10.61013 -0.66763 70.98785 17.33126 Degrees of Freedom: 43 Total (i.e. Null); 38 Residual Null Deviance: 44.58 Residual Deviance: 17.46 AIC: 29.46 Warning message: glm.fit: fitted probabilities numerically 0 or 1 occurred However I am getting a warning mesage as fitted probabilities numerically 0 or 1 occurred. Here my question is, have I made any mistakes with my above implementation? I s it just because, I have too less number of '0' in my response Variable? Look at the output of summary, especially the standard errors. You seem to be getting complete separation on X5 and X4 doesn,'t look so hot either. Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] deferred call
Bert and Gabor, Thanks for clarifying. Much appreciated. One more question. Do either of you know the location of the code that does the lookup of the default arguments? I would like to be able to capture the implicit dependency of the function on the default arguments. Hence, I would write something like: capture.dag - function(fun) { ans - list() args - formals(fun) for(nm in names(args)) { ans[[ nm ]] - lookup.the.object(args[[nm]]) } ans } However, it seems that this logic is already implemented in the core of R, and it would be great to re-use it. Thanks, Whit On Thu, Apr 12, 2012 at 1:00 AM, Bert Gunter gunter.ber...@gene.com wrote: On Wed, Apr 11, 2012 at 8:12 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Apr 11, 2012 at 10:17 PM, Whit Armstrong armstrong.w...@gmail.com wrote: I must admit I'm a little ashamed to have been using R for so long, and still lack a sound understanding of deferred calls, eval, deparse, substitute, and friends. I'm attempting to make a deferred call to a function which has default arguments in the following way: call.foo - function(f) { x - f() } x - 1:10 f - function(x=x) { x^2 } call.foo(f) However, I'm getting the error: Error in x^2 : 'x' is missing Is there a common R idiom for calling 'formals' on the function, and then grabbing the named default arguments from the enclosing frame? I naively thought that since function 'f' was defined w/ a default argument of 'x' and x is defined in the same envir as the function itself, that the call would succeed. f - function(x=x) x^2 is an endless recursion. Try To amplify just a bit on Gabor's comment, section 4.3.3 of the R language definition explicitly states: One of the most important things to know about the evaluation of arguments to a function is that supplied arguments and default arguments are treated differently. The supplied arguments to a function are evaluated in the evaluation frame of the calling function. The default arguments to a function are evaluated in the evaluation frame of the function. So foo - function (x = x) {...} tries to define foo with the default argument x, which is evaluated in the ** environment of the function ** not in the caller's environment, where it is 1:10. So if x ever needs to be evaluated within foo (i.e., its promise is forced), then it looks for the value of the rhs of the x=x assignment within foo, which is (the promise for) x, again, within foo, which is x again,... HTH -- Bert f - function(x.=x) { x^2 } (note the dot) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving multiple plots using tiff function
Thanks Berend for your answer! I read the documentation but I dont understand filename =Rplot%03d.tif ? Do you mind sending me what you tried? On Thu, Apr 12, 2012 at 7:34 AM, Berend Hasselman b...@xs4all.nl wrote: On 12-04-2012, at 13:07, John S wrote: Dear R users, I still did not receive an answer to my question and went through the archive with no luck. So what does tiff(filename =Rplot%03d.tif) mean ? Just read the documentation for tiff: ?tiff Why the following code does produce two files? It produces no files for me. Only an error message. tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10, compression = lzw) plot(1) mtext(Fig 1,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(2) mtext(Fig 2,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(3) mtext(Fig 3,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) dev.off() You must specify the antialias argument. Which I did: I set it to none and got 3 .tif (plot) files. So I don't know what's wrong with your stuff. Berend [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving multiple plots using tiff function
So what does tiff(filename =Rplot%03d.tif) mean ? Just read the documentation for tiff: ?tiff A look at ?sprintf might also be useful if you're unfamiliar with the C format specification. %03d is the format spec for a 3-digit decimal number with leading zeroes. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving multiple plots using tiff function
On 12.04.2012 13:49, John S wrote: Thanks Berend for your answer! I read the documentation but I don’t understand filename =Rplot%03d.tif ? Do you mind sending me what you tried? This is a bug in R. I'll take a look. Best, Uwe Ligges On Thu, Apr 12, 2012 at 7:34 AM, Berend Hasselmanb...@xs4all.nl wrote: On 12-04-2012, at 13:07, John S wrote: Dear R users, I still did not receive an answer to my question and went through the archive with no luck. So what does tiff(filename =Rplot%03d.tif) mean ? Just read the documentation for tiff: ?tiff Why the following code does produce two files? It produces no files for me. Only an error message. tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10, compression = lzw) plot(1) mtext(Fig 1,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(2) mtext(Fig 2,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(3) mtext(Fig 3,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) dev.off() You must specify the antialias argument. Which I did: I set it to none and got 3 .tif (plot) files. So I don't know what's wrong with your stuff. Berend [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading SPSS: underlying numerical codes
Hi Ista, thank you for your reply! Yes, I looked at the help sheet but didn't use this command because I would still like the categorial variables to be converted into factors and have the value labels from SPSS imported into R as levels. With the use.value.labels = FALSE? command I do get the same underlying codes as in SPSS but I loose the information about the levels, I think. Does anyone know a way to preserve both? Thank you very much for your help in advance? Marion 2012/4/12 Ista Zahn istaz...@gmail.com Hi Marion, Did you look at the help file? Did you try use.value.labels = FALSE? Best, Ista On Thu, Apr 12, 2012 at 6:28 AM, Marion Wenty marion.we...@gmail.com wrote: Dear people, I have got a question concerning the underlying numerical codes when reading an SPSS file into R. I used the package foreign and when I look at a variable I get the verbal codes. I would like to know how it is possible to get the underlying numerical codes as output, which are the same as in my SPSS file. Thank you very much in advance for your help! Marion [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] General question on the message with non zero exit status
On 12.04.2012 12:05, Chel Hee Lee wrote: I have a general question how to understand the message with non-zero exit status when new package is installed. Based on my experience, this message implies a package dependence. Am I correct to understand this message? Are there anyone who can provide some reference or explain details about the message with non zero exit status? A process typically indicates success by an exit status 0 and csan flag different kinds of errors by other exit codes. This is so far unrelated to R. The INSTALL script evaluates the exit status and tells you that something went wrong according to that status, for more information, you will need to look at the (text) output of the INSTALL run. Uwe Ligges I very appreciate for your kindness in advance. -- View this message in context: http://r.789695.n4.nabble.com/General-question-on-the-message-with-non-zero-exit-status-tp4551438p4551438.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using dcast with multiple functions to aggregate
Dear R communitiy, I am trying to use multiple functions for aggregation within a function call for dcast. However this seems to result in an error. Also I have not managed to make dcast() work with fun.aggregate=sd. Please find attached some example code using the ChickWeight data. Many thanks for your help! Jokel #Chick weight example names(ChickWeight) - tolower(names(ChickWeight)) sd(ChickWeight$weight) # works fine mean(ChickWeight$weight) # works fine length(ChickWeight$weight) # works fine chick_m - melt(ChickWeight, id=2:4, na.rm=TRUE) dcast(chick_m, time~variable, mean) # works fine dcast(chick_m, time~variable, length) # works fine dcast(chick_m, time~variable, fun.aggregate=sd) # gives an error dcast(chick_m, time~variable, c(mean, length)) # gives an error [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to calculate the McFadden R-square for LOGIT model?
Please ignore this mail. I got a solution by using 'pscl' package! On Thu, Apr 12, 2012 at 4:56 PM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Dear all, can somebody please help me how to calculate McFadden R-square for a LOGIT model? Corresponding definition can be found here: http://publib.boulder.ibm.com/infocenter/spssstat/v20r0m0/index.jsp?topic=%2Fcom.ibm.spss.statistics.help%2Falg_plum_statistics_rsq_mcfadden.htm Here is my data: Data - structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 47, 58, 82, 100, 222, 164, 161, 70, 219, 81, 209, 182, 185, 104, 126, 192, 95, 245, 97, 177, 125, 56, 85, 199, 298, 145, 78, 144, 178, 146, 132, 98, 120, 148, 123, 282, 79, 34, 104, 91, 199, 101, 109, 117, 1.1, 0.92, 1.72, 2.18, 1.75, 2.26, 2.07, 1.43, 1.92, 1.82, 2.34, 2.12, 1.81, 1.35, 1.26, 2.07, 2.04, 1.55, 1.89, 1.68, 0.76, 1.96, 1.29, 1.81, 1.72, 2.39, 1.68, 2.29, 2.34, 2.21, 1.42, 1.97, 2.12, 1.9, 1.15, 1.7, 1.24, 1.55, 2.04, 1.59, 2.07, 2, 1.84, 2.04, 51.2, 48.5, 50.8, 54.4, 52.4, 56.7, 54.6, 52.7, 52.3, 53, 55.4, 53.5, 51.6, 48.5, 49.3, 53.9, 55.7, 51.2, 54, 52.2, 51.1, 54, 55, 52.9, 53.7, 55.8, 50.4, 58.8, 54.5, 53.5, 48.8, 54.5, 52.1, 56, 56.2, 53.3, 50.9, 53.2, 51.7, 54.3, 53.7, 54.7, 47, 56.9, 0.321, 0.224, 0.127, 0.063, 0.021, 0.027, 0.139, 0.218, 0.008, 0.012, 0.076, 0.299, 0.04, 0.069, 0.33, 0.017, 0.166, 0.003, 0.01, 0.076, 0.454, 0.032, 0.266, 0.018, 0.038, 0.067, 0.075, 0.064, 0.065, 0.065, 0.09, 0.016, 0.061, 0.019, 0.389, 0.037, 0.161, 0.127, 0.017, 0.222, 0.026, 0.012, 0.057, 0.022, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0), .Dim = c(44L, 6L), .Dimnames = list( c(Obs 1, Obs 2, Obs 3, Obs 4, Obs 5, Obs 6, Obs 7, Obs 8, Obs 9, Obs 10, Obs 11, Obs 12, Obs 13, Obs 14, Obs 15, Obs 16, Obs 17, Obs 18, Obs 19, Obs 20, Obs 21, Obs 22, Obs 23, Obs 24, Obs 25, Obs 26, Obs 27, Obs 28, Obs 29, Obs 30, Obs 31, Obs 32, Obs 33, Obs 34, Obs 35, Obs 36, Obs 37, Obs 38, Obs 39, Obs 40, Obs 41, Obs 42, Obs 43, Obs 44), c(Y, X 1, X 2, X 3, X 4, X 5))) AND, my model is: glm(Data[,1] ~ Data[,-1], binomial(link = logit)) Thanks, __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to calculate the McFadden R-square for LOGIT model?
Christofer Bogaso bogaso.christofer at gmail.com writes: Dear all, can somebody please help me how to calculate McFadden R-square for a LOGIT model? [snip] library(sos) findFn(McFadden) brings you to: http://finzi.psych.upenn.edu/R/library/pscl/html/pR2.html i.e. install the sos package; use it to search install the pscl package use the pR2() function __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How insert data to a column in existing csv file?
On Apr 12, 2012, at 5:18 AM, Yellow wrote: I was working with some excel files with a lot of data. And by hand it is impossible to handle them. So they are now converted to .csv. With headers above the columns, like: Data1, Data2, Data3 But now I needed to calculate the log2 value of Data1 and place the result under Data2. I can't find how to do that. First you need to explain more clearly what you mean by place the result under Data2. Is this a display concern? Or are you trying to interleave rows of original data and logged data using a column organization? Why only Data2? What should go in the rows for Data1 and Data3? ? What is the goal of this effort? Does anyone else know? I have the log2 values, but how do I get then inside the .csv file under Data2? Post some sample code that constructs the data.frames and the code you used. I already tried write.table(), buy that wasn't it. And I am kinda stuck on this now. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Centering (e.g. on prcomp)
Hi! I'm doing a PCA on some testdata (only 2 features) currently to see what happens. I read a lot of times one should center ones data, so i left the option on. But now i am scratching my head on how to correctly transform new data to be comparable to the data used in the pca. pca$x are the points (in PC system) the function returns origpoints%*%pca$rotation is not quite the same, because it is missing the centering for the original data i can of course do scale(origpoints,scaled=F) beforehand, and then the results will be the same, but for new data that option isn't available. So how would i properly transform it? greetings Jessica __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R error message
Hi, I'm trying to do an exploratory factor analysis for a uni assignment but I keep getting this error message coming up [1] One of your variables is a constant. Constants are disallowed as part of a scale. when I turn the data into a matrix and look at the stats. I've been told that this means one of the variables doesn't vary much any more, but I am really stuck on how to sort this out. The code I have used is summary(prefdata) prefdata[prefdata5]=NA summary(prefdata) prefdata2=as.matrix(prefdata[3:22]) stats=paf(prefdata2) [1] One of your variables is a constant. Constants are disallowed as part of a scale. Any help would be greatly appreciated, a few of us are stuck with this and we're going out of our minds trying to figure out how to fix it! Thank you so much, Harriet the MSc students at Edinburgh -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in creating a matrix
I have dataset with n variables, say n =3 x y z the formula should be form = x+y+z+x*x +x*y+x*z +y*y + y*z+z*z my code has to for loop Is there any way to reduce two loops for (i in 1:n) { for (j in i:n) { dat= cbind(dat,dat[,i]*dat[,j]) } } Yes; use outer But - Why only two levels of looping for three variables? - What have i, j and dat to do with the formula? - Why doesnt the formula appear anywhere in the loop? - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-creating-a-matrix-tp4551532p4551532.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Multivariate multilevel mixed effects model: interaction
Hello. I am running a multivariate multilevel mixed effects model, and am trying to understand what the interaction term tells me. A very simplified version of the model looks like this: model - lmer (phq ~ -1 + as.factor(index_phq) * Neuro + ( -1 + as.factor(index_phq)|UserID), data=data) The phq variable is a categorical depression score on 9 depression items (classified by the variable index_phq), and Neuroticism is a covariate (random effect = the subjects of my study, they should be allowed to vary in slope/intercept). The output looks like this: Fixed effects: EstimateStd.Error t-value as.factor(index_phq)10.0185335 0.0466784 0.397 as.factor(index_phq)2 -0.0327630 0.0453493 -0.722 as.factor(index_phq)30.2210580 0.0612363 3.610 as.factor(index_phq)40.6240455 0.0582654 10.710 as.factor(index_phq)50.1121727 0.0622298 1.803 as.factor(index_phq)6 -0.1797495 0.0484940 -3.707 as.factor(index_phq)7 -0.0907630 0.0488517 -1.858 as.factor(index_phq)8 -0.0854370 0.0384632 -2.221 as.factor(index_phq)9 -0.0621792 0.0319729 -1.945 Neuro 0.0218704 0.0019690 11.107 as.factor(index_phq)2:Neuro 0.0026006 0.0018268 1.424 as.factor(index_phq)3:Neuro 0.0012185 0.0025774 0.473 as.factor(index_phq)4:Neuro 0.0009458 0.0023336 0.405 as.factor(index_phq)5:Neuro 0.0061280 0.0025547 2.399 as.factor(index_phq)6:Neuro 0.0070453 0.0018788 3.750 as.factor(index_phq)7:Neuro -0.0008890 0.0020755 -0.428 as.factor(index_phq)8:Neuro -0.0092411 0.0020197 -4.575 as.factor(index_phq)9:Neuro -0.0159498 0.0021470 -7.429 Looking only at the interaction effects, do I understand correctly that ... 1) Neuroticism has a significant effect on all PHQ items, because the effect is significant on phq1 (t-value=11.107), and the other t-values are at a maximum -7.429 lower than the t-value of 11.107, meaning they are still significant because they are still all above t~2? 2) The strongest effect is on PHQ6, which is significantly higher than the effect from Neuro on PHQ1? 3) The weakest effect is on PHQ9, which is significantly lower than the effect from Neuro on PHQ1? Thank you Eiko [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] pyramid.plot in plotrix, axis labelling
Hi, I've been looking at ways to make pyramid plots in R. I like the pyramid.plot method in plotrix as it seems the simplest to use and building them in ggplot looks a bit more code intensive than I'd like, being as I'm new to R. This package does pretty much what I need it to do, however I can't seem to scale the x axis labels. The other labels scale fine with labelcex. I guess the preferred method is to remove them and re-build them as you might in the base package, but I have no idea how to refer to them as there are two of them. I have enclosed some sample data lifted from another example. I've scaled down the other labels using labelcex whch leaves the disparity in sizes that I'm trying to remove. I'd like something like this but with the x axis lables the same size as the y. mpop=c(50,75,80,100,110,90,85,60,40,20) fpop=c(50,75,80,100,110,90,85,60,50,30) coh=c(0-9,10-19,20-29,30-39,40-49,50-59,60-69,70-79,80-89,90-99) pyramid.plot(mpop,fpop,labels=coh,gap=15,labelcex=0.7,top.labels=c(males,age group,females),lxcol=red,rxcol=blue, laxlab=c(0,50,100,150),raxlab=c(0,50,100,150)) Any suggestions gratefully recieved. Gavin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Encoding of Sweave file error message
On 12-04-12 12:13 AM, Duncan Mackay wrote: At 12:03 12/04/2012, you wrote: I had the same problem! So, as I'm a linux user, I prefer use linux terminal. On terminal I type this to compile R CMD Sweave --encoding=utf-8 myfile.Rnw and the compilation is successful. Try to set the encoding option in Sweave(). Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail:mailto:wal...@ufpr.brwal...@ufpr.br twitter: @walmeszeviani homepage:http://www.leg.ufpr.br/%7Ewalmeshttp://www.leg.ufpr.br/~walmes linux user number: 531218 == Hi Walmes Thank you very much. That appears to be the problem. When I typed from the DOS terminal R CMD Sweave --encoding=utf-8 ParasiteComb12.Rnw it compiled the tex file without any error messages. I have not really got into font encoding and reading the Sweave manual I thought that what I had done would be sufficient. I found an old note which gave a reference to http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4725.html http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4889.html but that appears to be specific. The ?Sweave and the Sweave manual appear to be more specific about the latex side. After having a look at iconvlist() and bearing in mind Duncan Murdoch's comments about windows I tried Sweave(D:/Cic/Sweave/Parasite/Comb/12/ParasiteComb12.Rnw, encoding = UTF-8) from the Rgui command window and compiled without any problems When I had a look at the tex file there were a few DOS Alt-248 (degree symbol ) within latex comments which were added last running R2.14 before updating That doesn't sound like UTF-8 encoding, it sounds like Latin-1. So declaring it to be UTF-8 will eventually cause you some problems, when you put some of those characters in a place that LaTeX processes. You can avoid the problem by putting this line in your Rnw file: \usepackage[latin1]{inputenc} as the ?Sweave help page says. Or, just delete those non-ASCII characters. There's a function in the tools package to detect them: see ?tools::showNonASCII. Duncan Murdoch Removing them and re running without the encoding argument brought things back to normal. I tried as a test \SweaveOpts{encoding=UTF8} but that appears not to work All I have to do now is to put the extra argument into my text editors clip library for Sweave for next time when I cannot solve things. Its been a long week ! Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email home: mac...@northnet.com.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Centering (e.g. on prcomp)
Ah.. forget it, something must have gone wrong while i was testing (probably messed up some apply()). Seems you can just subtract the returned means - i hope at least. Am 12.04.2012 um 14:30 schrieb Jessica Streicher: Hi! I'm doing a PCA on some testdata (only 2 features) currently to see what happens. I read a lot of times one should center ones data, so i left the option on. But now i am scratching my head on how to correctly transform new data to be comparable to the data used in the pca. pca$x are the points (in PC system) the function returns origpoints%*%pca$rotation is not quite the same, because it is missing the centering for the original data i can of course do scale(origpoints,scaled=F) beforehand, and then the results will be the same, but for new data that option isn't available. So how would i properly transform it? greetings Jessica __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Encoding of Sweave file error message
Hi Duncan Thank you for the tips I tried \usepackage[latin1]{inputenc} but it still bailed up. tried showNonASCII on the file with the ° typed as Alt-248 (used to doing as DOS value) becomes Alt-176 in ASCII % 1° line resulted in 483: % 1b0 line The showNonASCII is a nifty function Duncan At 22:32 12/04/2012, you wrote: On 12-04-12 12:13 AM, Duncan Mackay wrote: At 12:03 12/04/2012, you wrote: I had the same problem! So, as I'm a linux user, I prefer use linux terminal. On terminal I type this to compile R CMD Sweave --encoding=utf-8 myfile.Rnw and the compilation is successful. Try to set the encoding option in Sweave(). Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail:mailto:wal...@ufpr.brwal...@ufpr.br twitter: @walmeszeviani homepage:http://www.leg.ufpr.br/%7Ewalmeshttp://www.leg.ufpr.br/~walmes linux user number: 531218 == Hi Walmes Thank you very much. That appears to be the problem. When I typed from the DOS terminal R CMD Sweave --encoding=utf-8 ParasiteComb12.Rnw it compiled the tex file without any error messages. I have not really got into font encoding and reading the Sweave manual I thought that what I had done would be sufficient. I found an old note which gave a reference to http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4725.html http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4889.html but that appears to be specific. The ?Sweave and the Sweave manual appear to be more specific about the latex side. After having a look at iconvlist() and bearing in mind Duncan Murdoch's comments about windows I tried Sweave(D:/Cic/Sweave/Parasite/Comb/12/ParasiteComb12.Rnw, encoding = UTF-8) from the Rgui command window and compiled without any problems When I had a look at the tex file there were a few DOS Alt-248 (degree symbol ) within latex comments which were added last running R2.14 before updating That doesn't sound like UTF-8 encoding, it sounds like Latin-1. So declaring it to be UTF-8 will eventually cause you some problems, when you put some of those characters in a place that LaTeX processes. You can avoid the problem by putting this line in your Rnw file: \usepackage[latin1]{inputenc} as the ?Sweave help page says. Or, just delete those non-ASCII characters. There's a function in the tools package to detect them: see ?tools::showNonASCII. Duncan Murdoch Removing them and re running without the encoding argument brought things back to normal. I tried as a test \SweaveOpts{encoding=UTF8} but that appears not to work All I have to do now is to put the extra argument into my text editors clip library for Sweave for next time when I cannot solve things. Its been a long week ! Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email home: mac...@northnet.com.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Michaelson-Morley Speed of Light Data
The same data, with the proper citations to Michelson(1882) and Stigler(1977) are contained in the HistData package as data(Michelson) See library(HistData) example(Michelson) On 4/11/2012 7:42 AM, Duncan Murdoch wrote: On 12-04-11 12:43 AM, Křištof Želechovski wrote: URL: http://finzi.psych.upenn.edu/R/library/datasets/html/morley.html The classical data of Michaelson and Morley on the speed of light Can you provide more information about the data? How were they obtained, etc.? I do not have the book Genstat Primer and the nearest location where it is available is University of York which is rather far from my location. If you can't find the cited reference, I'd try Google. For instance, it led me to this page http://en.wikipedia.org/wiki/File:Michelsonmorley-boxplot.svg which appears to show five series. Duncan Murdoch Note that the data for the Michelson-Morley experiments [1] consist of 6 experiments of 17 runs each, not of 5 series of 20 runs each. Best regards, Christopher Yeleighton ___ [1]URL: http://en.wikisource.org/wiki/On_the_Relative_Motion_of_the_Earth_and_the_Luminiferous_Ether __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele StreetWeb: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Encoding of Sweave file error message
Hi Rainer Thanks for an alternative. For the record I tried your latex solution on my Windows 7 \usepackage[utf8x]{inputenc} but it failed on the Alt-248 Regards Duncan At 19:13 12/04/2012, you wrote: I also had the same problem. Being on Linux, I prefer Walmes' command line method but I found that putting \usepackage[utf8x]{inputenc} as the first instruction in the master .Rnw file also does the trick. No need to change anything after that in the file, at least not for me! Rgds, Rainer On Thursday 12 April 2012 14:13:06 Duncan Mackay wrote: At 12:03 12/04/2012, you wrote: I had the same problem! So, as I'm a linux user, I prefer use linux terminal. On terminal I type this to compile R CMD Sweave --encoding=utf-8 myfile.Rnw and the compilation is successful. Try to set the encoding option in Sweave(). Bests. Walmes. == Walmes Marques Zeviani LEG (Laboratório de Estatística e Geoinformação, 25.450418 S, 49.231759 W) Departamento de Estatística - Universidade Federal do Paraná fone: (+55) 41 3361 3573 VoIP: (3361 3600) 1053 1173 e-mail: mailto:wal...@ufpr.brwal...@ufpr.br twitter: @walmeszeviani homepage: http://www.leg.ufpr.br/%7Ewalmeshttp://www.leg.ufpr.br/~walmes linux user number: 531218 == Hi Walmes Thank you very much. That appears to be the problem. When I typed from the DOS terminal I have exactl ParasiteComb12.Rnw it compiled the tex file without any error messages. I have not really got into font encoding and reading the Sweave manual I thought that what I had done would be sufficient. I found an old note which gave a reference to http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4725.html http://tolstoy.newcastle.edu.au/R/e10/help/10/05/4889.html but that appears to be specific. The ?Sweave and the Sweave manual appear to be more specific about the latex side. After having a look at iconvlist() and bearing in mind Duncan Murdoch's comments about windows I tried Sweave(D:/Cic/Sweave/Parasite/Comb/12/ParasiteComb12.Rnw, encoding = UTF-8) from the Rgui command window and compiled without any problems When I had a look at the tex file there were a few DOS Alt-248 (degree symbol ) within latex comments which were added last running R2.14 before updating Removing them and re running without the encoding argument brought things back to normal. I tried as a test \SweaveOpts{encoding=UTF8} but that appears not to work All I have to do now is to put the extra argument into my text editors clip library for Sweave for next time when I cannot solve things. Its been a long week ! Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England ARMIDALE NSW 2351 Email home: mac...@northnet.com.au [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving multiple plots using tiff function
On 12.04.2012 13:53, Uwe Ligges wrote: On 12.04.2012 13:49, John S wrote: Thanks Berend for your answer! I read the documentation but I don’t understand filename =Rplot%03d.tif ? Do you mind sending me what you tried? This is a bug in R. I'll take a look. I think I have a fix, will check and commit later today. Uwe Ligges Best, Uwe Ligges On Thu, Apr 12, 2012 at 7:34 AM, Berend Hasselmanb...@xs4all.nl wrote: On 12-04-2012, at 13:07, John S wrote: Dear R users, I still did not receive an answer to my question and went through the archive with no luck. So what does tiff(filename =Rplot%03d.tif) mean ? Just read the documentation for tiff: ?tiff Why the following code does produce two files? It produces no files for me. Only an error message. tiff(filename =Rplot%03d.tif,width=24,height=20,units=cm,res=300, pointsize=10, compression = lzw) plot(1) mtext(Fig 1,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(2) mtext(Fig 2,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) plot(3) mtext(Fig 3,side=3,line=4,adj=0.50,padj=2,col=black,cex=1) dev.off() You must specify the antialias argument. Which I did: I set it to none and got 3 .tif (plot) files. So I don't know what's wrong with your stuff. Berend [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Survreg output - interpretation
--- begin included message --- Hello R users, I am analizing survival data (mostly uncensored) and want to extract the most out of it. Since I have more than one factor, I?ve read that the survival regression can help to test the interactions between factors, and then decide how to do the comparisons using the Log-rank test (survdiff). 1- if I chose the Weibull distribution, does the output inform the goodness of fit to it? perhaps in this part of the output... Weibull distribution Loglik(model)= -1302.8 Loglik(intercept only)= -1311 Chisq= 16.49 on 11 degrees of freedom, p= 0.12 Number of Newton-Raphson Iterations: 7 n= 873 2- one of my factors is gender (2 levels). With survreg, it appears as significant, but if I compare them with log-rank it turns not significant. Are they comparing different things? or is it a test power issue? --- end inclusion --- 1. To understand goodness of fit you need to look at the residuals in multiple ways. (The same answer applies to ordinary linear regression.) 2. You have not given us enough information to answer the questions. If the data is p=.049 vs p=.051, the the answers are in agreement even though the artificial label of significant changes. The logrank test and survreg are not the same model. If the data is p=.02 vs p=.8, then you have an error in the code. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] selective labels display on histogram
Hello, Is it possible to selectively display labels on a histogram? Thanks Carol [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of warnings
Any help ? -- View this message in context: http://r.789695.n4.nabble.com/number-of-warnings-tp4550325p4551760.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with lmer and fixef
Hello, I am trying to do contrasts after applying a binomial mixed effect model with the function lmer. I have to extract the fix effect values, but as I write fixef(model), I get this error message: Error in UseMethod(fixef) : no method for 'fixef' with objects of class mer Has anybody some ideas why? And how can I then post-hoc testing my data if I cannot do the contrasts? Thank you very much -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-lmer-and-fixef-tp4551816p4551816.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Curve fitting, probably splines
Dear all, This is probably more related to statistics than to [R] but I hope someone can give me an idea how to solve it nevertheless: Assume I have a variable y that is a function of x: y=f(x). I know the average value of y for different intervals of x. For example, I know that in the interval[0;x1] the average y is y1, in the interval [x1;x2] the average y is y2 and so forth. I would like to find a line of minimum curvature so that the average values of y in each interval correspond to y1, y2, ... My idea was to use (cubic) splines. But the problem I have seems somewhat different to what is usually done with splines. As far as I understand it, splines help to find a curve that passes a set of given points. But I don't have any points, I only have average values of y per interval. If you have any suggestions on how to solve this, I'd love to hear them. Thanks very much in advance, Michael [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of warnings
Hi Any help ? Call 999 Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/number-of- warnings-tp4550325p4551760.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] selective labels display on histogram
Hi Hello, Is it possible to selectively display labels on a histogram? What labels? Like that? x-rnorm(1) hist(x) hist(x, axes=F, xlab=bla, ylab=ble, main=bleble) axis(1, at=c(-4, -1, 1, 4)) Regards Petr Thanks Carol [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R error message
Hi, The code I have used is summary(prefdata) prefdata[prefdata5]=NA summary(prefdata) prefdata2=as.matrix(prefdata[3:22]) stats=paf(prefdata2) [1] One of your variables is a constant. Constants are disallowed as part of could you provide some data / sample data you used for prefdata and code that is fully reproducible? Regards! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with lmer and fixef
swertie v_coudrain at voila.fr writes: I am trying to do contrasts after applying a binomial mixed effect model with the function lmer. I have to extract the fix effect values, but as I write fixef(model), I get this error message: Error in UseMethod(fixef) : no method for 'fixef' with objects of class mer Has anybody some ideas why? And how can I then post-hoc testing my data if I cannot do the contrasts? Thank you very much The most likely answer is that you have loaded another package that interferes with the lme4 package, most likely nlme. For example: library(lme4) ## CRAN version, or use lme4.0 from r-forge example(lmer) ## to generate some fitted values fixef(fm1) ## works library(nlme) ## produces warning about masking The following objects ... fixef(fm1) ## gives your error detach(package:nlme) fixef(fm1) ## works again other possible culprits are the glmmADMB package, or other packages that depend on (and hence automatically load) nlme. See sessionInfo() ... Questions like this are probably more suited to the r-sig-mixed-models list. Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Support for R in highlight.js
There are numerous JS libraries for syntax highlighting. I have never tried highlight.js yet, but I wrote something for SyntaxHighlighter which might be easily translated to highlight.js: http://yihui.name/en/2010/09/syntaxhighlighter-brush-for-the-r-language/ Regards, Yihui -- Yihui Xie xieyi...@gmail.com Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Thu, Apr 12, 2012 at 2:04 AM, Ivan Sagalaev man...@softwaremaniacs.org wrote: Hello, I'm the maintainer of a syntax highlighting tool highlight.js[1]. Recently the Kaggle project has announced they wanted to sponsor the development of the R highlighting definition for it[2]. I wanted to drop a line about it here since I suspect this list has much more R programmers on it than our small discussion group :-). So if you're interested and don't mind touching a little bit of JavaScript — please reply to the announcement or personally to Adam Kennedy adam.kenn...@kaggle.com who's behind it from the Kaggle side. [1]: http://softwaremaniacs.org/soft/highlight/en/ [2]: https://groups.google.com/d/topic/highlightjs/-ogtOaK-TQY/discussion __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of warnings
This is the R-help mailig list, not Nabble, hence quote the original message! Anyway, the answer is: See ?options and its argument nwarnings. Uwe ligges On 12.04.2012 14:49, helin_susam wrote: Any help ? -- View this message in context: http://r.789695.n4.nabble.com/number-of-warnings-tp4550325p4551760.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Remove superscripts from HTML objects
Hi, h - htmlpCatsupa/sup/ppDog/p/html sub(sup.*sup,,h) see http://en.wikibooks.org/wiki/R_Programming/Text_Processing for more information. Regards! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] selective labels display on histogram
No, data labels on the histogram bars. labels = T in hist displays all data labels. thanks From: Petr PIKAL petr.pi...@precheza.cz Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch Sent: Thursday, April 12, 2012 4:03 PM Subject: Re: [R] selective labels display on histogram Hi Hello, Is it possible to selectively display labels on a histogram? What labels? Like that? x-rnorm(1) hist(x) hist(x, axes=F, xlab=bla, ylab=ble, main=bleble) axis(1, at=c(-4, -1, 1, 4)) Regards Petr Thanks Carol [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] correlation matrix between data from different files
Dear users, I'm quite a new french R-user, and I have a problem about doing a correlation matrix. I have temperature data for each weather station of my study area and for each year (for example, a data file for the weather station N°1 for the year 2009, a data file for the N°2 for the year 2010, ). So I have 70 weather stations with one data file per year since 2005. Each station has 4 temperature sensors. Each data file has exactly the same structure: datehour, sensor1, sensor2, sensor3, sensor4. Here's an example: time sensor1 sensor2 sensor3sensor4 01/01/2008 00:00-0.25 -2.43 -3.25 -2.37 01/01/2008 00:15-0.18 -2.37 -3.18 -2.25 01/01/2008 00:30-0.25 -2.5-3.37 -2.56 01/01/2008 00:45-0.25 -2.37 -3.31 -2.37 I need to do a matrix correlation between each same sensors of the different stations (one correlation matrix between all the sensors 1 of the 70 stations, another one for sensor 2, ...). I have to find for each year and each station the best correlation. For example, which one of the 70 weather stations is the most well correlated with station 1 for the sensor 1? and with station 2? ... and so one for each sensor and each station. Example: Sensor 1 for the year 2009 Station 1 Station 2 Station 3 [...] Station 1 1 0.910 0.748 Station 2 0.91010.6 Station 3 0.748 0.6 1 [...] And the same for year 2005,2006,2007,2008,2009,2010,2011 for each of the 4 sensors. Have you got any idea how can I do this on R? Should I first merge all the sensors in one file or could I do it with data in separate files (like I have for the moment)? Thank you very much for all your answers! -- View this message in context: http://r.789695.n4.nabble.com/correlation-matrix-between-data-from-different-files-tp4552226p4552226.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How insert data to a column in existing csv file?
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Yellow Sent: Thursday, April 12, 2012 2:18 AM To: r-help@r-project.org Subject: [R] How insert data to a column in existing csv file? I was working with some excel files with a lot of data. And by hand it is impossible to handle them. So they are now converted to .csv. With headers above the columns, like: Data1, Data2, Data3 But now I needed to calculate the log2 value of Data1 and place the result under Data2. I can't find how to do that. Does anyone else know? I have the log2 values, but how do I get then inside the .csv file under Data2? I already tried write.table(), buy that wasn't it. And I am kinda stuck on this now. In the absence of a reproducible example, we can only guess. My guess is that you should read the csv file into a data frame, add or modify your variable(s), then write out a new csv file. Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How insert data to a column in existing csv file?
I would suggest using the XLConnect package so that you can read/write the Excel files directly. You can read in the files to a dataframe, make your transformations and then write the result back out to the Excel file. On Thu, Apr 12, 2012 at 11:29 AM, Nordlund, Dan (DSHS/RDA) nord...@dshs.wa.gov wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Yellow Sent: Thursday, April 12, 2012 2:18 AM To: r-help@r-project.org Subject: [R] How insert data to a column in existing csv file? I was working with some excel files with a lot of data. And by hand it is impossible to handle them. So they are now converted to .csv. With headers above the columns, like: Data1, Data2, Data3 But now I needed to calculate the log2 value of Data1 and place the result under Data2. I can't find how to do that. Does anyone else know? I have the log2 values, but how do I get then inside the .csv file under Data2? I already tried write.table(), buy that wasn't it. And I am kinda stuck on this now. In the absence of a reproducible example, we can only guess. My guess is that you should read the csv file into a data frame, add or modify your variable(s), then write out a new csv file. Dan Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] selective labels display on histogram
Hi No, data labels on the histogram bars. labels = T in hist displays all data labels. You could find it probably quicker in documentation. Plotting command usually creates (invisibly) the object which can be saved and changed. h-hist(x) h is list which you can use or modify for instance this h.lab - h$counts h.lab[seq(2,16,2)]-NA hist(x, labels=as.character(h.lab)) prints every second label Regards Petr thanks From: Petr PIKAL petr.pi...@precheza.cz To: carol white wht_...@yahoo.com Cc: r-h...@stat.math.ethz.ch r-h...@stat.math.ethz.ch Sent: Thursday, April 12, 2012 4:03 PM Subject: Re: [R] selective labels display on histogram Hi Hello, Is it possible to selectively display labels on a histogram? What labels? Like that? x-rnorm(1) hist(x) hist(x, axes=F, xlab=bla, ylab=ble, main=bleble) axis(1, at=c(-4, -1, 1, 4)) Regards Petr Thanks Carol [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] scatter3d: problem with spheres-color
Dear List, I don't get scatter3d to color the sheres according to the '|' argument. library(car) scatter3d(prestige ~ income + education|type, data=Prestige) The spheres on my screen are all colored the same and they are not conditional on Prestige$type. On the other hand: Fit3d and Ellipse3d are colored according to the group argument. rgl_0.92.879 car_2.0-12 R version 2.15.0 i686-pc-linux-gnu (32-bit) I checked this under windows and: here they are colored according to 'Prestige$type'. Hmm? What goes wrong here, any ideas? thanks, René __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] convex nonnegative basis vectors in nullspace of matrix
Hi the solution with linear programming works very well! Even if I take more 'realistic' matrices with dimensions of about 25x60, the calculation of the basis goes well (if I increase the number of iterations to 1000). Meanwhile I also found an algorithm for an exact calculation of the extreme rays of the cone (Appendix in http://www.sciencedirect.com/science/article/pii/S0022519300910737). When I have time I will try to implement this solution as well and compare the performances, but the one I have now works fine in my application. Many thanks, Hannes -- View this message in context: http://r.789695.n4.nabble.com/convex-nonnegative-basis-vectors-in-nullspace-of-matrix-tp4548822p4552371.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] pyramid.plot in plotrix, axis labelling
Gavin, Thank you for this example. I would use the as.pyramidLikert function in the HH package. The resulting plot is a standard lattice plot, so any fine tuning uses that standard lattice features. Rich ## install.packages(HH) ## if necessary library(HH) mydata - cbind(mpop,fpop)[10:1,] dimnames(mydata) - list(coh, c(males,females)) mydata males females 0-9 20 30 10-1940 50 20-2960 60 30-3985 85 40-4990 90 50-59 110 110 60-69 100 100 70-7980 80 80-8975 75 90-9950 50 as.pyramidLikert(plot.likert(mydata)) print(as.pyramidLikert(plot.likert(mydata)), panel.width=.45) update(as.pyramidLikert(plot.likert(mydata)), scales=list(cex=2)) print(update(as.pyramidLikert(plot.likert(mydata)), scales=list(cex=2)), panel.width=.42) packageVersion(HH) [1] 2.2.23 -- Forwarded message -- From: Gavin Rudge g.ru...@bham.ac.uk Date: Thu, Apr 12, 2012 at 7:55 AM Subject: [R] pyramid.plot in plotrix, axis labelling To: r-help@r-project.org r-help@r-project.org Hi, I've been looking at ways to make pyramid plots in R. I like the pyramid.plot method in plotrix as it seems the simplest to use and building them in ggplot looks a bit more code intensive than I'd like, being as I'm new to R. This package does pretty much what I need it to do, however I can't seem to scale the x axis labels. The other labels scale fine with labelcex. I guess the preferred method is to remove them and re-build them as you might in the base package, but I have no idea how to refer to them as there are two of them. I have enclosed some sample data lifted from another example. I've scaled down the other labels using labelcex whch leaves the disparity in sizes that I'm trying to remove. I'd like something like this but with the x axis lables the same size as the y. mpop=c(50,75,80,100,110,90,85,60,40,20) fpop=c(50,75,80,100,110,90,85,60,50,30) coh=c(0-9,10-19,20-29,30-39,40-49,50-59,60-69,70-79,80-89,90-99) pyramid.plot(mpop,fpop,labels=coh,gap=15,labelcex=0.7,top.labels=c(males,age group,females),lxcol=red,rxcol=blue, laxlab=c(0,50,100,150),raxlab=c(0,50,100,150)) Any suggestions gratefully recieved. Gavin. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] selective labels display on histogram
Is this what you mean? x - rnorm(12) histogram(x) histogram(x, scales=list(x=list(at=c(-1, 1), labels=c(minus one, one On Thu, Apr 12, 2012 at 9:28 AM, carol white wht_...@yahoo.com wrote: Hello, Is it possible to selectively display labels on a histogram? Thanks Carol [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatter3d: problem with spheres-color
I do something similar my script is structured as follows: perhaps it will help library(car) library(rgl) library(mgcv) scatter3d(MADep2009 ~ MADwet2009 + MedAD2009 | as.factor(VegClass), data = SFCN, sphere.size=1.5, surface=FALSE, parallel=FALSE, elliposiod=TRUE, surface.col=c(green, red, blue, gold, firebrick3) hope this offers some assistance. Steve Steve Friedman Ph. D. Ecologist / Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 René Mayer mayer@psychologi e.tu-dresden.de To Sent by: r-help@r-project.org r-help-bounces@r- cc project.org Subject [R] scatter3d: problem with 04/12/2012 01:14 spheres-color PM Dear List, I don't get scatter3d to color the sheres according to the '|' argument. library(car) scatter3d(prestige ~ income + education|type, data=Prestige) The spheres on my screen are all colored the same and they are not conditional on Prestige$type. On the other hand: Fit3d and Ellipse3d are colored according to the group argument. rgl_0.92.879 car_2.0-12 R version 2.15.0 i686-pc-linux-gnu (32-bit) I checked this under windows and: here they are colored according to 'Prestige$type'. Hmm? What goes wrong here, any ideas? thanks, René __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] strsplit help
Alison, You've got two geneids with two periods (instead of just one period). gene.list - strsplit(as.character(Rumino_Reps_agreeWalign$geneid),\\.) Rumino_Reps_agreeWalign[sapply(gene.list, length)!=2, ] geneid count_Conser count_NonCons count_ConsSubst count_NCSubst 7411470.DS231493.G141 0 0 0 154 411470.DS231491.G1861 2 0 1 Your method had an error, because it couldn't deal with the different lengths of vectors in the list created by strsplit. My method ran without error because it just pulled of the first two parts of the geneid, 411470.DS231493 and 411470.DS231491 and ignored the third part of the geneid G14 and G186. However, you may need to come up with a different method or a workaround, if you want the full geneid from these two records. Jean alison waller alison.wal...@embl.de wrote on 04/12/2012 03:00:26 AM: Thanks - I checked through and it looks as if all of the geneids are formatted similarily so I don't know which one would be causing an error. Interestingly, your sapply method works on the same data. So I'm happy although still confused, because the strsplit method worked the other day with a similarly generated dataset. I dumped my entire dataframe below. Incase anyone wants to investigate. Alison Rumino_Reps_agreeWalign$geneid.prefix - sapply(gene.list, [, 1) Rumino_Reps_agreeWalign$geneid.suffix - sapply(gene.list, [, 2) dput(Rumino_Reps_agreeWalign) structure(list(geneid = c(657313.locus_tag:RTO_08940, 457412.251848018, 657314.locus_tag:CK5_20630, 657323.locus_tag:CK1_33060, 657313.locus_tag:RTO_09690, 471875.197297106, 411470.DS231493.G14, 411459.149830627, 657313.locus_tag:RTO_09720, 411460.145845997, 411459. 149831369, 657321.locus_tag:RBR_01830, 411460.145846414, 457412. 251848805, 657321.locus_tag:RBR_08030, 471875.197296907, 457412. 251847995, 657314.locus_tag:CK5_20840, 411460.145846423, 657314.locus_tag:CK5_25030, 457412.251847990, 471875.197297117, 471875.197299322, 411459. 149831093, 411459.149831815, 411460.145846434, 213810.locus_tag:RUM_09700, 657314.locus_tag:CK5_09460, 657323.locus_tag:CK1_18840, 471875. 197297108, 411460.145846680, 411459.149831368, 657314.locus_tag:CK5_19120, 657321.locus_tag:RBR_09560, 411460.145846435, 657323.locus_tag:CK1_11530, 457412.251850723, 213810.locus_tag:RUM_12960, 213810.locus_tag:RUM_14740, 213810.locus_tag:RUM_07030, 471875.197296936, 411459. 149831092, 471875.197297110, 471875.197298135, 411460.145846430, 657314.locus_tag:CK5_20370, 657313.locus_tag:RTO_09790, 657323.locus_tag:CK1_33050, 411460. 145846407, 457412.251849909, 411460.145846340, 657313.locus_tag:RTO_14810, 457412.251848010, 457412.251850599, 657323.locus_tag:CK1_33200, 657323.locus_tag:CK1_33190, 213810.locus_tag:RUM_03050, 657314.locus_tag:CK5_09880, 213810.locus_tag:RUM_15180, 657313.locus_tag:RTO_14610, 657313.locus_tag:RTO_23930, 411459.149830473, 657313.locus_tag:RTO_18090, 657323.locus_tag:CK1_27940, 657314.locus_tag:CK5_20720, 411459.149831855, 471875. 197297691, 411459.149833320, 457412.251849358, 657321.locus_tag:RBR_13130, 411459.149831077, 471875.197297272, 657314.locus_tag:CK5_09370, 457412.251847994, 411459.149831080, 657314.locus_tag:CK5_20730, 457412.251850579, 213810.locus_tag:RUM_14870, 657321.locus_tag:RBR_01750, 657313.locus_tag:RTO_09660, 657314.locus_tag:CK5_28910, 411460. 145846907, 657313.locus_tag:RTO_09860, 457412.251847996, 657323.locus_tag:CK1_38480, 411460.145846417, 471875.197297592, 411459.149831814, 457412. 251848016, 411459.149831804, 657323.locus_tag:CK1_32880, 657321.locus_tag:RBR_08130, 411460.145846429, 657313.locus_tag:RTO_09880, 213810.locus_tag:RUM_03410, 657313.locus_tag:RTO_09740, 657313.locus_tag:RTO_09840, 457412. 251848009, 657323.locus_tag:CK1_33090, 657323.locus_tag:CK1_25000, 411459. 149831095, 411459.149830934, 457412.251847970, 457412.251848000, 657314.locus_tag:CK5_20680, 411459.149831088, 657323.locus_tag:CK1_19350, 657321.locus_tag:RBR_08670, 471875.197299547, 411459.149831081, 657323.locus_tag:CK1_32550, 411459.149831091, 657313.locus_tag:RTO_24580, 457412. 251848004, 471875.197297195, 411460.145846602, 657321.locus_tag:RBR_06200, 213810.locus_tag:RUM_19570, 411460.145846361, 411459. 149833804, 657323.locus_tag:CK1_32930, 471875.197296906, 411459. 149831078, 657321.locus_tag:RBR_09900, 411460.145846496, 657321.locus_tag:RBR_08260, 411459.149833021, 657313.locus_tag:RTO_02600, 657323.locus_tag:CK1_33030, 657313.locus_tag:RTO_09750, 213810.locus_tag:RUM_14790, 457412. 251848017, 457412.251848806, 457412.251847640, 657314.locus_tag:CK5_20620, 411459.149830474, 657323.locus_tag:CK1_11750, 213810.locus_tag:RUM_09690, 457412.251847999, 657321.locus_tag:RBR_05870, 411460. 145846409, 657313.locus_tag:RTO_16220,
Re: [R] Reading SPSS: underlying numerical codes
Hi Marion, I don't have access to SPSS, so it would be hard for me to figure this out for you. I would think that string variables would be imported as strings or factors even when use.value.labels is true, but can't verify that. Good luck, Ista On Thu, Apr 12, 2012 at 7:59 AM, Marion Wenty marion.we...@gmail.com wrote: Hi Ista, thank you for your reply! Yes, I looked at the help sheet but didn't use this command because I would still like the categorial variables to be converted into factors and have the value labels from SPSS imported into R as levels. With the use.value.labels = FALSE? command I do get the same underlying codes as in SPSS but I loose the information about the levels, I think. Does anyone know a way to preserve both? Thank you very much for your help in advance? Marion 2012/4/12 Ista Zahn istaz...@gmail.com Hi Marion, Did you look at the help file? Did you try use.value.labels = FALSE? Best, Ista On Thu, Apr 12, 2012 at 6:28 AM, Marion Wenty marion.we...@gmail.com wrote: Dear people, I have got a question concerning the underlying numerical codes when reading an SPSS file into R. I used the package foreign and when I look at a variable I get the verbal codes. I would like to know how it is possible to get the underlying numerical codes as output, which are the same as in my SPSS file. Thank you very much in advance for your help! Marion [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] writing spdiags function for R
Dear R-list, I am in the process of translating a long function written in Matlab into R (mainly because I am a big of fan of R, and folks will not have to pay to use it :). In the translation of this function I got stack because they use spdiags, which, as far as I can tell it is not available in R. I have explored the Matrix package, from which I borrowed some of the functions (e.g., sparseMatrix), but I could not actually find an equivalent to spdiags (please, let me know if it is there somewhere). So, I have written my own spdiags function (below); following also a suggestion in an old, and perhaps unique post, about this issue. It works only for square matrices (that's my need), however I have a couple of issues, mainly related to computational efficiency: 1) if I use it with a sparseMatrix, it throws a tedious warning sparse[ logic ] : .M.sub.i.logical() maybe inefficient; can I suppress this warning somehow, this is slowing the computation very radically; 2) I can go around this problem by translating a sparseMatrix back into a logical matrix before I run spdiags on it. However, the loop gets very slow for large matrices (e.g., 2000x2000), which is the kind of matrices I have to handle. If you look in the code, I have placed a system.time() where the code is slowing down, and it takes about: user system elapsed 0.280.050.33 to complete an iteration...thus, I was wondering whether there is a more efficient way to do what I am doing...also, if you spot other places where the function could be optimized I would be very glad to hear it! thank you very much in advance for your kind help, Best, Moreno ### ## it works only for square matrices ## it could work with sparse matrices but it spits a tedious warning ## it is definitely inefficient compared to the original matlab code ## choose below different matrices to test the function. # r = c(2,3,5,5); c = c(2,1,4,5) # A = sparseMatrix(r, c) # A = replicate(1000, rnorm(1000) ) # A = rbind(c(1,2,3),c(2,3,4),c(3,4,5)) spdiags = function(A){ # Find all nonzero diagonals i = rep(seq(1, nrow(A),1),nrow(A)); j = sort(i); d = sort(j-i); # d = d(find(diff([-inf; d]))); ## from Matlab ... # d = c(d[which(diff(d) == 1)], d[length(d)] ) ## this emulate above but needs to stick in last element d = unique(d); ##this should work just fine and it is simpler p = length(d); ##the nr. col of the new matrix m = nrow(A); n = ncol(A); B = matrix(0, nrow = min(c(m,n)), ncol = p); for (k in 1:p){ # print(k) cl = vector(); if (m = n){ i = max(1, 1+d[k]):min(n, m+d[k]); } else { i = max(1, 1-d[k]):min(m,n-d[k]); } system.time( if (length(i) != 0){ B[i,k] = A[ col(A) == row (A) - d[k]] } ) } return (list( B = B, d = d) ) } -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using dcast with multiple functions to aggregate
Hi Jokel, On Thu, Apr 12, 2012 at 7:57 AM, Jokel Meyer jokel.me...@googlemail.com wrote: Dear R communitiy, I am trying to use multiple functions for aggregation within a function call for dcast. However this seems to result in an error. Also I have not managed to make dcast() work with fun.aggregate=sd. Please find attached some example code using the ChickWeight data. Many thanks for your help! Jokel #Chick weight example names(ChickWeight) - tolower(names(ChickWeight)) sd(ChickWeight$weight) # works fine mean(ChickWeight$weight) # works fine length(ChickWeight$weight) # works fine chick_m - melt(ChickWeight, id=2:4, na.rm=TRUE) This doesn't do anything interesting, because there is only one measure.var! dcast(chick_m, time~variable, mean) # works fine dcast(chick_m, time~variable, length) # works fine dcast(chick_m, time~variable, fun.aggregate=sd) # gives an error Works on my machine. See session info below. dcast(chick_m, time~variable, c(mean, length)) # gives an error ?dcast tells you that fun.aggregate must return a single summary statistic. dcast is not the right function for the job. For reference, here is my session info: R version 2.14.2 (2012-02-29) Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit) locale: [1] C attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] plyr_1.7.1 reshape2_1.2.1 foreign_0.8-49 eha_2.0-7 [5] survival_2.36-12 loaded via a namespace (and not attached): [1] compiler_2.14.2 stringr_0.6 tcltk_2.14.2tools_2.14.2 Best, Ista [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scatter3d: problem with spheres-color
Dear René, I've confirmed that the spheres aren't coloured correctly on my Ubuntu system (the first colour is used for all of the spheres), and I know that this works right on Windows, as you mentioned. I'm curious to try it on my Mac, but don't have that handy at the moment. I also looked at the code for scatter3d.default(), and that is pretty straightforward; scatterplot3d.default() draws the spheres with the command rgl.spheres(x, y, z, color = surface.col[as.numeric(groups)], radius = size) I'm copying this response to Duncan Murdoch (the coauthor and maintainer of the rgl package) in case he has any insight into the problem. Thank you for drawing this issue to my attention. John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 12 Apr 2012 19:14:21 +0200 René Mayer ma...@psychologie.tu-dresden.de wrote: Dear List, I don't get scatter3d to color the sheres according to the '|' argument. library(car) scatter3d(prestige ~ income + education|type, data=Prestige) The spheres on my screen are all colored the same and they are not conditional on Prestige$type. On the other hand: Fit3d and Ellipse3d are colored according to the group argument. rgl_0.92.879 car_2.0-12 R version 2.15.0 i686-pc-linux-gnu (32-bit) I checked this under windows and: here they are colored according to 'Prestige$type'. Hmm? What goes wrong here, any ideas? thanks, René __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How insert data to a column in existing csv file?
Hi everyone, I read your messages and I tried some things out. The Data2 is filled with NA. So what I did was: NameFile.csv$Data2[is.na(NameFile.csv$Data2)] = log2Values And now it worked. :) Seems like I needed to replace it, and not only write it. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/How-insert-data-to-a-column-in-existing-csv-file-tp4551327p4552463.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Applying a function to categorized data?
Hi all, I'm just getting started in R. My problem is the following: I have a data frame (v1) with lots of production data measurements. Each row contains a single measurement ('ARI_MIT') with a timestamp. I want to lump the data by months with their mean and standard deviation. I have already successfully managed to do the lumping by adding another column to my data frame: v1$MONTH = strftime(v1$TIMESTAMP, %y%m) This makes a nice month-wise boxplot of my data, although I don't have an idea why: boxplot(v1$ARI_MIT ~ v1$MONTH) I don't need this plotted, though, but in the form of a new data frame with three columns: the month, the mean, and the standard deviation of all values from that month. I tried un-stacking v1 into a list of vectors and then looping over its elements, calculating the mean of each group: for (i in unstack(v1, v1$ARI_MIT ~ v1$MONTH)) { write(mean(i), ) } This works, but how do I get the data into a data frame? With the month labels in a column? They are not avaliable inside the loop body. I know I need to get a book on R. Thanks, robert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help in creating a matrix
The formula is created sepearately and data is created for the formula and then use the modelling lm - Thanks in Advance Arun -- View this message in context: http://r.789695.n4.nabble.com/Help-in-creating-a-matrix-tp4551532p4551967.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Pointwise Mutual Information
Hi, I want to calculate pointwise mutual information between label 2-gram, and words in my corpus 1-gram. Any suggestions as to how to go about it? l =label w = word C = reference collection I want to calculate following: p(w,l| C) p(w| C) p(l | C) -- View this message in context: http://r.789695.n4.nabble.com/Pointwise-Mutual-Information-tp4552486p4552486.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to automate creation of plots (create series of plots)
Hi All. I have problem with generating series of plots. In detail: I have file of data which I insert into dataframe: data-read.table(file.txt, header=TRUE, sep= ) Data in this file are prepared in such a way, that the header of each column has a value of one of examined parameter - something like that: X Y 01.001.1 01.2 01.5 01.6 02.0 1 11.74 10.71 16 16 16 11616 2 12.43 10.97 16 16 16 11 16 3 11.63 11.92 16 16 1 1161 I need to generate a XY plot for each column (I need to observe changes in context of parameter (header names) change). Each column has a few values and it is reflected in point's shape (pch). I'm doing this using (example for fourth column): plot(data$X~data$Y,main=Parameter, 01.1, pch=data$01.1) In this way I have different point shape and value of parameter in main plot label. For the first few columns it is: plot(data$X~data$Y,main=Parameter, 01.0, pch=data$Pr.01.0) plot(data$X~data$Y,main=Parameter, 1.1, pch=data$Pr.01.1) plot(data$X~data$Y,main=Parameter, 1.2, pch=data$Pr.01.2) I use it together with par(mfrow=c(3,2)), so I have 6 plots at a time. My question is: How can I automate creation od plots? The values in headers are not a series - they should be read from header, because I can not prepare them in one or two for loops. (1.2 and next can be 1.5 next 2.0 next 2.7 -certain values are not predictable) The problem is that I have a lot of columns (now 57, sometimes - about 100, without initial filtering - more than 300). Now I manually rewrite parameter value and copy line plot(...). It is very laborious work, and I think it can be automated. Does anyone has an idea how can I use data frame headers as parameters in plot (legend and parameter of pch)? I'm sure that it will be for loop - I know how many plots I need, but what inside for (combining data frame header and plot parameter)? Regards -- /|/| _ _ _/_ /_ _ / / _ __ / |(/(/(/(/((-/)(/ ( /((/( /_ _/ Magdalena Tkacz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with lmer and fixef
Thank you very much. I started R again and loaded less libraries and it worked! I didn't know about this problem, the next time, I'll check for this before looking a whole afternoon for alternative methods ;). -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-lmer-and-fixef-tp4551816p4552053.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of warnings
This is my wrong, I am so sorry for this. I just wanted to ask something which I did not know. Thanks for answer. Regards Helin. -- View this message in context: http://r.789695.n4.nabble.com/number-of-warnings-tp4550325p4552240.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Organizations where IT has approved the use of R software
Hi Gang, I realize this post is not directly related to programing issues with R, however, it appears this may be the best place to ask my question. I am putting forward a request that R be considered approved software in my organization. Never an easy task, this is made much more difficult given that it is open source software (sends the IT gang into little fits). So, I am compiling a list of organizations (Universities, goverment, industry,etc.) that are using R and whose IT department considers it approved software. If you belong to such an organization could you please let me know? If you know of organizations that this applies to, but are not directly affiliated with them I would still be interested but please just let me know which of these two cases your response fits into. Thanks in advance. Lynn -- View this message in context: http://r.789695.n4.nabble.com/Organizations-where-IT-has-approved-the-use-of-R-software-tp4552609p4552609.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with vectorization
Hi every one. I have a exponential function (3 fitting parameters) that I would like to use to produce data (6 series) without having to use a loop. Here wl = seq(300,500,1) k1 = c(1.2e-6, 4.9e-6, 9.6e-6, 2.7e-10, 6.7e-8, 7.44e-6) k2 = c(726, 352, 128, 5232, 1538, 128) k3 = c(-176, -224, -257, 88.7, -111, -256) stations = c('R5d', 'R5a', 'R9', '108', '406', '409') phiDIC = k1[1]*exp(k2[1]/(wl+k3[1])) #Here I would like to vectorize this function to create my 6 series instead of having to loop. Regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Help-with-vectorization-tp4552638p4552638.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] quadratic model with plateau
Thanks to all for your help! That works! Orange On Sat, Apr 7, 2012 at 7:25 PM, Gabor Grothendieck ggrothendi...@gmail.comwrote: Yes, I had fixed that on my end but didn't notice I had copied the old version. I think its obvious enough that anyone will fix it themselves. Regards. On Sat, Apr 7, 2012 at 7:23 PM, Rolf Turner rolf.tur...@xtra.co.nz wrote: One other minor glitch I just noticed: x - seq_along(x) should read x - seq_along(y) cheers, Rolf On 08/04/12 10:08, Gabor Grothendieck wrote: On Sat, Apr 7, 2012 at 3:58 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Fri, Apr 6, 2012 at 9:42 PM, help lyhelp.ly2...@gmail.com wrote: Dear All, I would like to make a quadratic with a plateau model in R. Is there a package in R doing this? The bentcableAR package seems won't work. The link below describes what I am looking for in R exactly: http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_nlin_sect033.htm Use nls directly: y- c(0.46, 0.47, 0.57, 0.61, 0.62, 0.68, 0.69, 0.78, 0.7, 0.74, 0.77, 0.78, 0.74, 0.8, 0.8, 0.78) x- seq_along(x) Mean- function(x, alpha, beta, gamma) { pmin(alpha + beta*x + gamma*x*x, alpha - beta^2/(4 * gamma)) } fm- nls(y ~ Mean(x, alpha, beta, gamma), start = list(alpha = 0.45, beta = 0.05, gamma = -0.0025)) fm summary(fm) plot(y ~ x) lines(fitted(fm) ~ x) It was pointed out to me offline that Mean as defined above is not identical to the definition in the poster's link. Here is a revision: y- c(0.46, 0.47, 0.57, 0.61, 0.62, 0.68, 0.69, 0.78, 0.7, 0.74, 0.77, 0.78, 0.74, 0.8, 0.8, 0.78) x- seq_along(x) Mean- function(x, alpha, beta, gamma) { ifelse(x -beta/(2 * gamma), alpha + beta*x + gamma*x*x, alpha - beta^2/(4 * gamma)) } fm- nls(y ~ Mean(x, alpha, beta, gamma), start = list(alpha = 0.45, beta = 0.05, gamma = -0.0025)) fm summary(fm) plot(y ~ x) lines(fitted(fm) ~ x) with(as.list(coef(fm)), abline(v = -beta/(2 * gamma))) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com -- Thanks so much! Orange help.ly2...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of warnings
Sorry, I did not understand. What does it mean call 999 ? -- View this message in context: http://r.789695.n4.nabble.com/number-of-warnings-tp4550325p4551999.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Survreg output - interpretation
Dear Terry  here is the survreg line from which I understand that gender is significant survreg(formula = Surv(dias, status) ~ trat * sexo * rep, dist = weibull)                   Value    Std. Error      z       p sexom           -0.2187    0.0993 -2.202 2.76e-02 and the log rank result  survdiff(Surv(dias, status) ~ sexo) Call: survdiff(formula = Surv(dias, status) ~ sexo)         N Observed Expected (O-E)^2/E (O-E)^2/V sexo=h 458     458     472    0.397     1.83 sexo=m 451     451     437    0.428     1.83  Chisq= 1.8 on 1 degrees of freedom, p= 0.176 do you think this could be an error code or is it because they are different models? thank you very much Eugenia De: Terry Therneau-2 [via R] ml-node+s789695n4551787...@n4.nabble.com Para: mariaeugeniau mariaeugen...@yahoo.com.ar Enviado: jueves, 12 de abril de 2012 10:06 Asunto: Re: Survreg output - interpretation --- begin included message --- Hello R users, I am analizing survival data (mostly uncensored) and want to extract the most out of it. Since I have more than one factor, I?ve read that the survival regression can help to test the interactions between factors, and then decide how to do the comparisons using the Log-rank test (survdiff). 1- if I chose the Weibull distribution, does the output inform the goodness of fit to it? perhaps in this part of the output... Weibull distribution Loglik(model)= -1302.8  Loglik(intercept only)= -1311      Chisq= 16.49 on 11 degrees of freedom, p= 0.12 Number of Newton-Raphson Iterations: 7 n= 873 2- one of my factors is gender (2 levels). With survreg, it appears as significant, but if I compare them with log-rank it turns not significant. Are they comparing different things? or is it a test power issue? --- end inclusion --- 1. To understand goodness of fit you need to look at the residuals in multiple ways.  (The same answer applies to ordinary linear regression.) 2. You have not given us enough information to answer the questions.  If the data is p=.049 vs p=.051, the the answers are in agreement even though the artificial label of significant changes.  The logrank test and survreg are not the same model.  If the data is p=.02 vs p=.8, then you have an error in the code. Terry Therneau __ [hidden email] 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. If you reply to this email, your message will be added to the discussion below:http://r.789695.n4.nabble.com/Survreg-output-interpretation-tp4549368p4551787.html To unsubscribe from Survreg output - interpretation, click here. NAML -- View this message in context: http://r.789695.n4.nabble.com/Survreg-output-interpretation-tp4549368p4552481.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Extended beta-binomial model in R
Dear all, I have been searching far and wide for a solution to the problem of negative intracluster correlation in the case of a binomial response variable (also known as under-dispersion). Prentice (1986) (http://www.jstor.org/stable/2289219) developed an extension of the beta-binomial model which allowed for this negative correlation. Palmquist (1997)(http://www.polmeth.wustl.edu/media/Paper/palmq97.pdf) developed a module (ebb) for Stata which implemented this solution, but this has since been discontinued and is no longer available on the web. Is there a package in R which implements the extended beta-binomial model or otherwise allows for negative intracluster correlations? The following packages and functions do not: aod, SensR, betareg, VGAM, quasibinomial (Also, if anyone has access to Palmquist's ebb module this would also be very helpful.) Many thanks in advance for any guidance! Best regards Henrik Hermansson PhD Candidate Department of Political Science Trinity College Dublin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Simple Problem: Plotting mathematical functions
Hey there, I want to plot 5 parabola functions, which happen to be f(x) = 0.25x² + 6,47x -32.6 g(x)=0.99x² -6x -195 j(x)= 0.77x² +14x -495 k(x)=0.001x² + 65x -785 l(x) = 0.9x² -2x -636 in the same graph. Sadly I even do not really understand how to plot just one graph... I found this code in the Internet, which plots a cos-function: x - seq( -10, 10, length = 1000) plot(x, *sin(x)*, xlab=x-values, ylab=f(x), type=l) lines(x, cos(x), lty=3) title( Trigonometric functions, sin(x) and cos(x)) If I replace the sin(x) thing (bold) with one of my functions, it doesn't work and reports an unwanted character. Can somebody help me with that? -- View this message in context: http://r.789695.n4.nabble.com/Simple-Problem-Plotting-mathematical-functions-tp4552668p4552668.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Applying a function to categorized data?
Welcome to R and the list. Others may suggest books ( Nutshell was my first ) but first there are some things that will help you both in programming and getting help on the list. You should post executable code in your question. So, build a toy example of the data.frame you have and show what you tried. Folks here should be able to run your toy example and show you how to get the answer you want. For your problem I'm guessing that aggregate() would be one path ?aggregate you will need to specify by to aggregate by month Steve On Thu, Apr 12, 2012 at 7:10 AM, Robert Latest boblat...@gmail.com wrote: Hi all, I'm just getting started in R. My problem is the following: I have a data frame (v1) with lots of production data measurements. Each row contains a single measurement ('ARI_MIT') with a timestamp. I want to lump the data by months with their mean and standard deviation. I have already successfully managed to do the lumping by adding another column to my data frame: v1$MONTH = strftime(v1$TIMESTAMP, %y%m) This makes a nice month-wise boxplot of my data, although I don't have an idea why: boxplot(v1$ARI_MIT ~ v1$MONTH) I don't need this plotted, though, but in the form of a new data frame with three columns: the month, the mean, and the standard deviation of all values from that month. I tried un-stacking v1 into a list of vectors and then looping over its elements, calculating the mean of each group: for (i in unstack(v1, v1$ARI_MIT ~ v1$MONTH)) { write(mean(i), ) } This works, but how do I get the data into a data frame? With the month labels in a column? They are not avaliable inside the loop body. I know I need to get a book on R. Thanks, robert __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Simple Problem: Plotting mathematical functions
Hi, At the moment I am studying R at school. But I found this site very useful to explain the plot functions to me: http://www.harding.edu/fmccown/r/ Maybe that can help you too? -- View this message in context: http://r.789695.n4.nabble.com/Simple-Problem-Plotting-mathematical-functions-tp4552668p4552744.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of warnings
Just a joke -- since you post through Nabble instead of being a list subscriber, the vast majority of us didn't see your original post and instead only saw your cry for help Michael On Thu, Apr 12, 2012 at 10:08 AM, helin_susam helin.su...@gmail.com wrote: Sorry, I did not understand. What does it mean call 999 ? -- View this message in context: http://r.789695.n4.nabble.com/number-of-warnings-tp4550325p4551999.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Organizations where IT has approved the use of R software
Slightly on topic, just yesterday, the CFPB announced they'll be using R in their work: http://blog.revolutionanalytics.com/applications/ Depending on the scale of your organization, it may not be the open-source nature that's quite the problem of the IT Gang but rather the support (or lack thereof) that's implied by the default startup message. Just like the GNU/Linux world, there exist commercially supported versions that help to fill this gap: if that's the case, and y'all can afford it, some companies have taken advantage of the support contracts provided by Revolution Analytics (whom you can google). To your question, I'd imagine almost all universities support R to one degree or another, many hosting CRAN mirrors (or the CRAN master at WU Wien or the WinBuilder at TU Dortmund ). In industry, many pharmaceutical and financial firms are using R more and more (the blog linked above records these stories nicely) -- we have many users on this list who are associated with major medical institutions as well. Perhaps you can state your general line of work and folks in the same field will come along to share war stories. Michael On Thu, Apr 12, 2012 at 2:04 PM, lynnland lynn.landria...@ontario.ca wrote: Hi Gang, I realize this post is not directly related to programing issues with R, however, it appears this may be the best place to ask my question. I am putting forward a request that R be considered approved software in my organization. Never an easy task, this is made much more difficult given that it is open source software (sends the IT gang into little fits). So, I am compiling a list of organizations (Universities, goverment, industry,etc.) that are using R and whose IT department considers it approved software. If you belong to such an organization could you please let me know? If you know of organizations that this applies to, but are not directly affiliated with them I would still be interested but please just let me know which of these two cases your response fits into. Thanks in advance. Lynn -- View this message in context: http://r.789695.n4.nabble.com/Organizations-where-IT-has-approved-the-use-of-R-software-tp4552609p4552609.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with vectorization
Perhaps ?outer -- well, not outer directly, but a multivariate outer -- I keep this one around for personal use: `mouter` - function(..., FUN = *){ dotArgs - list(...) FUN - match.fun(FUN) if(length(dotArgs) == 1L) return(unlist(dotArgs)) if (length(dotArgs) == 2L) return(do.call(base::outer, c(dotArgs, FUN = FUN))) base::outer(dotArgs[[1]], do.call(Recall, c(dotArgs[-1], FUN = FUN)), FUN) } So then something like: mouter(wl, k1, k2, k3, FUN = function(w, k1, k2, k3) k1 *exp(k2 / (w + k3))) if I understand your request correctly. Hope this helps, Michael On Thu, Apr 12, 2012 at 2:16 PM, Filoche pmassico...@hotmail.com wrote: Hi every one. I have a exponential function (3 fitting parameters) that I would like to use to produce data (6 series) without having to use a loop. Here wl = seq(300,500,1) k1 = c(1.2e-6, 4.9e-6, 9.6e-6, 2.7e-10, 6.7e-8, 7.44e-6) k2 = c(726, 352, 128, 5232, 1538, 128) k3 = c(-176, -224, -257, 88.7, -111, -256) stations = c('R5d', 'R5a', 'R9', '108', '406', '409') phiDIC = k1[1]*exp(k2[1]/(wl+k3[1])) #Here I would like to vectorize this function to create my 6 series instead of having to loop. Regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/Help-with-vectorization-tp4552638p4552638.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multivariate Multilevel Model: is R the right software for this problem
Very interesting book! However, it doesn't cover multivariate models (I have 9 moderately correlated, categorical dependent variables). Again, I'm trying to find out whether 5 time-varying variables (dichotomous; five different life events yes/no; subjects can have several life events at the same time) cause differential profiles of my 9 depression variables in a longitudinal sample, controlling for time-invariant covariates - exploratory. Is this possible in R? If so, how? I thought about multilevel multivariate mixed-effects models (random effect = subjects), but hardly find literature for R. Thanks a bunch! Eiko I recommend looking at chapter 6 of Paul Allison's *Fixed Effects Regression Models*. This chapter outlines how you can use a structural equation modeling framework to estimate a multi-level model (a random effects model). This approach is slower than just using MLM software like lmer() in the lme4 package, but has the advantage of being able to specify correlations between errors across time, the ability to control for time-invariant effects of time-invariant variables, and allows you to use the missing data maximum likelihood that comes in structural equation modeling packages. Hello, I've been trying to answer a problem I have had for some months now and came across multivariate multilevel modeling. I know MPLUS and SPSS quite well but these programs could not solve this specific difficulty. My problem: 9 correlated dependent variables (medical symptoms; categorical, 0-3), 5 measurement points, 10 time-varying covariates (life events; dichotomous, 0-1), N ~ 900. Up to 35% missing values on some variables, especially at later measurement points. My exploratory question is whether there is an interaction effect between life events and symptoms - and if so, what the effect is exactly. E.g. life event 1 could lead to more symptoms A B D whereas life event 2 could lead to more symptoms A C D and less symptoms E. My question is: would MMM in R be a viable option for this? If so, could you recommend literature? Thank you --T [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.