Re: [R] Legend Truncated Using filled.contour
Data attached - didn't realize I could do that last night. Here's the data inport piece of my code, change the pathname to your computer. asym-read.csv('/Users/kirstensimmons/Desktop/Asym04.csv') asym #put the data into a data matrix asym_matrix-data.matrix(asym) On Thu, Oct 4, 2012 at 6:35 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 3, 2012, at 12:58 PM, Kirsten wrote: Hey everyone, I'm working on a contour plot depicting asymptomatic prevalence at varying durations of infectiousness and force of infection. I've been able to work everything out except for this one - my legend title keeps getting cut off. Here's what I have: filled.contour(x=seq(2,30,length.out=nrow(asym_matrix)), y=seq(1,2,length.out=ncol(asym_matrix)), Error in nrow(asym_matrix) : object 'asym_matrix' not found asym_matrix, color = function(x)rev(heat.colors(x)), plot.title = title(main=Asymptomatic Prevalence in 0-4 Year Olds with\n Increasing Duration of Infectiousness, xlab = Duration of Infectiousness, ylab = Relative Force of Infection), key.title = title(main = Asymptomatic\n Prevalence)) My first thought was to make the legend title text smaller using cex = 0.75 (or similar), but it doesn't change the text size at all. In fact, none of the modifiers that I've tried to add to the key.title line (size, color, font, etc) seems to be making a bit of difference. key.title = title(main = Asymptomatic\n Prevalence, cex = 0.75) I assume there's an override earlier in the code, but I have no idea what it is. Any suggestions? Thanks! Kirsten -- View this message in context: http://r.789695.n4.nabble.com/Legend-Truncated-Using-filled-contour-tp4644938.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. David Winsemius, MD Alameda, CA, USA -- Kirsten Simmons, MPH Polymath interested in productivity, how ideas spread, gardening, marketing, entrepreneurship and models of social networks and disease transmission __ 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] Find the average line from several lines
Hi people, I'm looking at the influence of sample size on a dataset, so I randomly sampled from the data with different sample sizes multiple times using the sample and replicate function. For example: /replicate(1000, sample(variable name, sample size, replace=T))/. I saved the data, and now I have 1000 replicates of data of various sample sizes (2-33 in my case). If you can picture that one (of 1000) iteration is a line of mean values of the variable for each sample size, i.e. the sample size (2-33) is on the x-axis and the average variable value (number of trees, dogs, cats, whatever) is on the y-axis. This means I have 1000 replicates of a line. *I'm looking to find the average line from several lines *(1000 lines in my case). Does anybody know how to do this in R? There was a topic on this using the function approx, but I don't have missing data and my data is on the same scale range. Thanks for your time, Greg [[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] Intermittent connectivity issues for JDBC / Oracle
I have been experiencing issues with an R script hanging when connecting to an Oracle database. To help debug, I found a function here in the nabble forum and made a small test script: #!/usr/bin/Rscript --no-restore --no-save --no-init-file library(RJDBC) drv-JDBC(oracle.jdbc.OracleDriver,/home/oracle/lib/ojdbc6.jar, ') dbCheck = function(url, user='', pwd='') { j = .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, url, user, pwd, check=FALSE) x = .jgetEx() .jcheck() x } dbCheck(jdbc:oracle:thin:@192.168.3.10:1521:psrndpt1,myuser,mypass) When I run the file - sometimes it works, returning NULL, and sometimes it hangs for between 1 and 2.5 minutes before throwing an error. The database is new and stable, on the same network - with no connection issues from any other clients. This machine isn't currently doing anything else except for running this script. Output from running it several times looks like this: R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava Error in .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, : ignoring SIGPIPE signal Calls: dbCheck - .jcall - .External Execution halted R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava Error in .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, : ignoring SIGPIPE signal Calls: dbCheck - .jcall - .External Execution halted R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava Error in .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, : ignoring SIGPIPE signal Calls: dbCheck - .jcall - .External Execution halted The times that it returns NULL, it returns immediately. When it throws the error, it is a varying amount of time between roughly 1 and 2.5 minutes. Both machines are not busy at all. Any ideas would greatly appreciated. Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Intermittent-connectivity-issues-for-JDBC-Oracle-tp4644960.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] Is there any package for Vector Auto-regressive with exogenous variable other than fastVAR?
Is there any package for Vector Auto-regressive with exogenous variable other than fastVAR? Because it is not able to solve my problem of not taking the base in the model. Please suggest some appropriate solution -- View this message in context: http://r.789695.n4.nabble.com/Is-there-any-package-for-Vector-Auto-regressive-with-exogenous-variable-other-than-fastVAR-tp4644964.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] Class for time series
Dear all, I have a time serie dataset such as the following with data acquired every 15 minutes: DateHeure Profondeur Température Salinité Turbidité Chloration 1 2012-07-06 08:47:22 -0.144 22.4690.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.4760.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.4980.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.5400.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.5100.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.3720.011 19.280 0 I wonder what is the best class to use to manage such time series -- Cordialement Emmanuel Poizot Cnam/Intechmer B.P. 324 50103 Cherbourg Cedex Web : http://www.geoceano.fr Phone (Direct) : (00 33)(0)233887342 ou 41 Fax : (00 33)(0)233887339 __ 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] Class for time series
Mr. Emmanuel, On 4 October 2012 02:43, Poizot Emmanuel emmanuel.poi...@cnam.fr wrote: Dear all, I have a time serie dataset such as the following with data acquired every 15 minutes: DateHeure Profondeur Température Salinité Turbidité Chloration 1 2012-07-06 08:47:22 -0.144 22.4690.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.4760.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.4980.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.5400.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.5100.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.3720.011 19.280 0 I wonder what is the best class to use to manage such time series Use xts whenever dealing with timeseries, to construct: xts(data.in[,-1:2], order.by=as.POSIXct(paste(data.in[,1:2]))) Also, when you post help requests, use dput on your data set. I'm assuming it's a data.frame, but I'd be able to actually test my code if there were dput output in your question. -- H -- Sent from my mobile device Envoyait de mon portable [[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] Class for time series
On Thu, 4 Oct 2012, Poizot Emmanuel wrote: Dear all, I have a time serie dataset such as the following with data acquired every 15 minutes: DateHeure Profondeur Température Salinité Turbidité Chloration 1 2012-07-06 08:47:22 -0.144 22.4690.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.4760.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.4980.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.5400.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.5100.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.3720.011 19.280 0 I wonder what is the best class to use to manage such time series See the Time Series task view for guidance: http://CRAN.R-project.org/view=TimeSeries -- Cordialement Emmanuel Poizot Cnam/Intechmer B.P. 324 50103 Cherbourg Cedex Web : http://www.geoceano.fr Phone (Direct) : (00 33)(0)233887342 ou 41 Fax : (00 33)(0)233887339 __ 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] Creating vegetation distance groups from one column
Hi R listers, I am trying to group distances of nests to the vegetation into classes that are define by (0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m, 31-35m, 36-40m, 41-45m, 46-50m, 51-55m, 56-60m). Each row is a nest and all the distances to the vegetation is in a column. In plyr, I have tried - below script but I think I am going about this the wrong way and am not successful. #Veg index star = resp Veg.index - function(values, weights=c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70)) { star - values*weights return(apply(star, 1, sum) / apply(values, 1, sum)) } data.to.analyze$VegIndex - Veg.index(data.to.analyze[,c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70)]) write.csv(data.to.analyze, 3turtlehatch.csv, row.names=FALSE) Please advise, Jean -- View this message in context: http://r.789695.n4.nabble.com/Creating-vegetation-distance-groups-from-one-column-tp4644970.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] Ops.factor(point1, point2) : - not meaningful for factors
Hi, can anyone help me in this problem :(. I am a total beginner in R software. It took me 2 days just to look into this problem. Due to this problem. I cant do looping. i want to find the distance between x and DSi DSi i Si 1 1 (5, 20) 2 2 (20, 2) 3 3 (25, 32) 4 4 (8, 39) 5 5 (10, 17) 6 6 (35, 20) 7 7 (38, 10) str (DSi) 'data.frame': 7 obs. of 2 variables: $ i : int 1 2 3 4 5 6 7 $ Si: Factor w/ 7 levels (10, 17),(20, 2),..: 6 2 3 7 1 4 5 x - c(15, 45) y - DSi [,2] dist - function (point1, point2) + { + diff - point1-point2 + distance - sqrt(sum(diff^2)) + distance + } dist (x, y) [1] NA Warning message: In Ops.factor(point1, point2) : - not meaningful for factors Regards, Nadiah -- View this message in context: http://r.789695.n4.nabble.com/Ops-factor-point1-point2-not-meaningful-for-factors-tp4644971.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 to limit memory on a server
I think R keeps all the data in RAM ? The function memory.limit() refers to the RAM size ? I will try to configure the OS. Thanks. Best regards Cyril Hervy -Message d'origine- De : Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Envoyé : mercredi 3 octobre 2012 17:22 À : Hervy Cyril Cc : R-help (r-help@r-project.org) Objet : Re: [R] How to limit memory on a server On 03/10/2012 16:12, Hervy Cyril wrote: My OS is a 64-bit Windows Server 2008 SP2 and I would like to limit RAM usage on the server. Ask your sysadmins, as Duncan Murdoch advised. R only know about virtual memory usage, not RAM usage. Thank you. Best regards Cyril Hervy -Message d'origine- De : Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Envoyé : mercredi 3 octobre 2012 15:43 À : Hervy Cyril Cc : R-help (r-help@r-project.org) Objet : Re: [R] How to limit memory on a server And your OS is? See the footer and the 'at a minimum' information the posting guide asks for. I think you are confusing 'memory' and 'RAM': the two concepts are distinct. But R is not a special case, and you do it the same way as you do this for any other process, by your OS facilities. On 03/10/2012 10:12, Hervy Cyril wrote: Hello, In our structure, users connect to a server (64GB of memory) where they launch R. How can I limit the amount of RAM that could use a user. The function memory.limit(size=...) can limit the amount of memory but I would like users can't change this option in R. Is it possible? Thank you. Cyril Hervy [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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 limit memory on a server
On 04/10/2012 10:07, Hervy Cyril wrote: I think R keeps all the data in RAM ? The function memory.limit() refers to the RAM size ? I will try to configure the OS. You are still confused. No, memory.limit() refers to virtual memory, and a process on a tolerably recent OS does not even know if VM is mapped or not without using OS-specific system calls (which R does not). ?memory.limit talks about 'obtainable memory', not RAM. Because Windows manages VM poorly, R for Windows is set up to try to keep its VM usage less than an amount that is likely to be mapped at once. But you can alter that, and with a fast SSD it may be worthwhile to do so. It is not even true that 'R keeps all the data in' *memory*: that's the point of lazy-loading. R objects in packages (including most of R itself) are kept on disc databases until actually used. Thanks. Best regards Cyril Hervy -Message d'origine- De : Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Envoyé : mercredi 3 octobre 2012 17:22 À : Hervy Cyril Cc : R-help (r-help@r-project.org) Objet : Re: [R] How to limit memory on a server On 03/10/2012 16:12, Hervy Cyril wrote: My OS is a 64-bit Windows Server 2008 SP2 and I would like to limit RAM usage on the server. Ask your sysadmins, as Duncan Murdoch advised. R only know about virtual memory usage, not RAM usage. Thank you. Best regards Cyril Hervy -Message d'origine- De : Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Envoyé : mercredi 3 octobre 2012 15:43 À : Hervy Cyril Cc : R-help (r-help@r-project.org) Objet : Re: [R] How to limit memory on a server And your OS is? See the footer and the 'at a minimum' information the posting guide asks for. I think you are confusing 'memory' and 'RAM': the two concepts are distinct. But R is not a special case, and you do it the same way as you do this for any other process, by your OS facilities. On 03/10/2012 10:12, Hervy Cyril wrote: Hello, In our structure, users connect to a server (64GB of memory) where they launch R. How can I limit the amount of RAM that could use a user. The function memory.limit(size=...) can limit the amount of memory but I would like users can't change this option in R. Is it possible? Thank you. Cyril Hervy [[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. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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] Failed installWithVers from local tar.gz
On 03/10/2012 20:42, kkarr wrote: Hi, I am having trouble installing a previous version of a package, and multiple version of the package in R 2.12 or 2.15. I have download the tar.gz packages from the CRAN archive, and created an folder holding all the files. install.packages(changepoint_0.3.tar.gz, lib=~/Rtools/dir/of/pkgs/, repos=NULL, dependencies=FALSE, contriburl=~/Rtools/dir/of/pkgs/changepoint_0.3.tar.gz, installWithVers= TRUE) installWithVers was made obsolete years ago. And you really do not want to install to the directory containing the tarballs. I have received several different errors, depending on which version of R I am using Version 2.12: This list does not support ancient versions of R (and as the posting guide says, there was no '2.12'). Please update as you were asked to do before posting. warning: unable to access index for repository 'lib = ~/Documents/Rtools/dir/of/pkgs/' is not writable Whatever instructions you are following are misleading you. Use the official manuals instead. Thanks for any thought. Cheers __ 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 PLEASE do. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@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] t-test
Dear Group, I want to do a t-test calculation on a large data set. I am pasting some part of it structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(CTK100, CTK103, CTK121), class = factor), Score = c(236.9726, 207.0055, 237.3464, 224.4774, 236.5034, 206.7382, 233.94, 240.31, 240.9, 235.15, 223.36, 248.67, 249.25, 201.4051, 244.1689, 182.2756, 229.001, 241.3211, 196.0453, 232.6055, 225.0783, 196.0453, 232.6055, 225.0783 )), .Names = c(Name, Score), class = data.frame, row.names = c(NA, 24L)) I want to compare groups with CTK100 and with all the groups and want to save the p-values and mean for each of that particular group (for example: mean for CTK and all) Similarly, for other groups like that CTK121 etc... Is there any way to automate this process? Thanks for your advice ! Nico [[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] random sampling inside a dataset
Hi again to everybody, I incountered the following error when I try to make a sample inside a dataset. My code is: data_ostrya - sample(ostrya,200, replace=F) Error in `[.data.frame`(x, .Internal(sample(length(x), size, replace, : cannot take a sample larger than the population when 'replace = FALSE' Why it does not work? The whole dataset is composed of 536 rows and I just want to sample randomly 200 of them... Thank you in advance, Gian On 13 September 2012 14:01, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:43 AM, Gian Maria Niccolò Benucci wrote: Thank you Duncan, I got the result of sampling, but it gave me only the row numbers. Is it possible to have the entire row with variables and other information? Because I need to re-sample inside my matrix the whole rows in reason to have 20 samples (i.e., rows) each year. Thank you for your invaluable help! Use those row numbers to index the dataframe or matrix, e.g. a[rows,] Duncan Murdoch Gian On 13 September 2012 13:32, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:18 AM, Gian Maria NiccolÅ Benucci wrote: Thank you very much for your help, I was wondering if is possible to sample randomly specifying to select in a particular group of data inside the matrix, for example only within the whole samples collected in 2011 I would randomly choose 20 random samples... You need two steps: find the rows that meet your condition, then sample from those. For example, rows - which( a$year == 2011 ) sample(rows, 20) There is one thing to watch out for: if you have a condition that only matches one row, you will get unexpected results here, because the sample will be taken from 1:rows. See the examples in ?sample for the workaround that uses sample.int. Duncan Murdoch Thanks a again, Gian On 13 September 2012 12:26, anna freni sterrantino annafr...@yahoo.it wrote: Hello Gian, sure sample function will do it for your sampling. a=as.data.frame(matrix(1:20,4)) sample(rownames(a),2) see ?sample for more details. Hope it helps Cheers Anna Anna Freni Sterrantino Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. -- *Da:* Gian Maria NiccolÅ Benucci gian.benu...@gmail.com *A:* r-help@r-project.org *Inviato:* GiovedÄ 13 Settembre 2012 10:42 *Oggetto:* [R] random sampling inside a dataset Hi all, I am wondering if do exist a function in R that allow me to sample or choose randomly the rows (i.e., samples) inside a given matrix. Thank you very much in advance. Cheers, -- Gian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.R-project.org/**posting-guide.html http://www.**R-project.org/posting-guide.**htmlhttp://www.R-project.org/posting-guide.html http://www.**r-project.org/**posting-guide.**htmlhttp://r-project.org/posting-guide.**html http://**www.r-project.org/posting-**guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This body part will be downloaded on demand. [[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] random sampling inside a dataset
Hello, If the dataset 'data_ostrya' is kept in a data.frame, then length(data_ostrya) is equal to the number of columns, not the number of rows. This is because a data.frame is a special type of list and length(some_list) is the number of its elements (obvious). if you want to sample rows, try sampling row numbers: row_ostrya - sample(nrow(ostrya),200, replace=F) Hope this helps, Rui Barradas Em 04-10-2012 11:06, Gian Maria Niccolò Benucci escreveu: Hi again to everybody, I incountered the following error when I try to make a sample inside a dataset. My code is: data_ostrya - sample(ostrya,200, replace=F) Error in `[.data.frame`(x, .Internal(sample(length(x), size, replace, : cannot take a sample larger than the population when 'replace = FALSE' Why it does not work? The whole dataset is composed of 536 rows and I just want to sample randomly 200 of them... Thank you in advance, Gian On 13 September 2012 14:01, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:43 AM, Gian Maria Niccolò Benucci wrote: Thank you Duncan, I got the result of sampling, but it gave me only the row numbers. Is it possible to have the entire row with variables and other information? Because I need to re-sample inside my matrix the whole rows in reason to have 20 samples (i.e., rows) each year. Thank you for your invaluable help! Use those row numbers to index the dataframe or matrix, e.g. a[rows,] Duncan Murdoch Gian On 13 September 2012 13:32, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:18 AM, Gian Maria NiccolÅ^ Benucci wrote: Thank you very much for your help, I was wondering if is possible to sample randomly specifying to select in a particular group of data inside the matrix, for example only within the whole samples collected in 2011 I would randomly choose 20 random samples... You need two steps: find the rows that meet your condition, then sample from those. For example, rows - which( a$year == 2011 ) sample(rows, 20) There is one thing to watch out for: if you have a condition that only matches one row, you will get unexpected results here, because the sample will be taken from 1:rows. See the examples in ?sample for the workaround that uses sample.int. Duncan Murdoch Thanks a again, Gian On 13 September 2012 12:26, anna freni sterrantino annafr...@yahoo.it wrote: Hello Gian, sure sample function will do it for your sampling. a=as.data.frame(matrix(1:20,4)) sample(rownames(a),2) see ?sample for more details. Hope it helps Cheers Anna Anna Freni Sterrantino Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. -- *Da:* Gian Maria NiccolÅ^ Benucci gian.benu...@gmail.com *A:* r-help@r-project.org *Inviato:* GiovedÄ 13 Settembre 2012 10:42 *Oggetto:* [R] random sampling inside a dataset Hi all, I am wondering if do exist a function in R that allow me to sample or choose randomly the rows (i.e., samples) inside a given matrix. Thank you very much in advance. Cheers, -- Gian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.R-project.org/**posting-guide.html http://www.**R-project.org/posting-guide.**htmlhttp://www.R-project.org/posting-guide.html http://www.**r-project.org/**posting-guide.**htmlhttp://r-project.org/posting-guide.**html http://**www.r-project.org/posting-**guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This body part will be downloaded on demand. [[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] random sampling inside a dataset
On 12-10-04 6:06 AM, Gian Maria Niccolò Benucci wrote: Hi again to everybody, I incountered the following error when I try to make a sample inside a dataset. My code is: data_ostrya - sample(ostrya,200, replace=F) Error in `[.data.frame`(x, .Internal(sample(length(x), size, replace, : cannot take a sample larger than the population when 'replace = FALSE' Why it does not work? The whole dataset is composed of 536 rows and I just want to sample randomly 200 of them... The sample() works on vectors, not dataframes. Since dataframes are lists containing the columns, it was trying to sample columns, not rows. This would give you a sample of rows: ostrya[sample(1:536, 200, replace=FALSE),] Duncan Murdoch Thank you in advance, Gian On 13 September 2012 14:01, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:43 AM, Gian Maria Niccolò Benucci wrote: Thank you Duncan, I got the result of sampling, but it gave me only the row numbers. Is it possible to have the entire row with variables and other information? Because I need to re-sample inside my matrix the whole rows in reason to have 20 samples (i.e., rows) each year. Thank you for your invaluable help! Use those row numbers to index the dataframe or matrix, e.g. a[rows,] Duncan Murdoch Gian On 13 September 2012 13:32, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:18 AM, Gian Maria Niccolň Benucci wrote: Thank you very much for your help, I was wondering if is possible to sample randomly specifying to select in a particular group of data inside the matrix, for example only within the whole samples collected in 2011 I would randomly choose 20 random samples... You need two steps: find the rows that meet your condition, then sample from those. For example, rows - which( a$year == 2011 ) sample(rows, 20) There is one thing to watch out for: if you have a condition that only matches one row, you will get unexpected results here, because the sample will be taken from 1:rows. See the examples in ?sample for the workaround that uses sample.int. Duncan Murdoch Thanks a again, Gian On 13 September 2012 12:26, anna freni sterrantino annafr...@yahoo.it wrote: Hello Gian, sure sample function will do it for your sampling. a=as.data.frame(matrix(1:20,4)) sample(rownames(a),2) see ?sample for more details. Hope it helps Cheers Anna Anna Freni Sterrantino Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. -- *Da:* Gian Maria Niccolň Benucci gian.benu...@gmail.com *A:* r-help@r-project.org *Inviato:* GiovedÄ› 13 Settembre 2012 10:42 *Oggetto:* [R] random sampling inside a dataset Hi all, I am wondering if do exist a function in R that allow me to sample or choose randomly the rows (i.e., samples) inside a given matrix. Thank you very much in advance. Cheers, -- Gian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.R-project.org/**posting-guide.html http://www.**R-project.org/posting-guide.**htmlhttp://www.R-project.org/posting-guide.html http://www.**r-project.org/**posting-guide.**htmlhttp://r-project.org/posting-guide.**html http://**www.r-project.org/posting-**guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This body part will be downloaded on demand. [[alternative HTML version deleted]] This body part will be downloaded on demand. __ 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] random sampling inside a dataset
Hi, I guess it is because when you have the FALSE option the sample function take off the number from the whole population so your data_frame becomes different in length. If you try with the option TRUE it works (of course) but then you have the possibility that you sample the same row twice. Hope this can help On 4 October 2012 11:06, Gian Maria Niccolò Benucci gian.benu...@gmail.comwrote: Hi again to everybody, I incountered the following error when I try to make a sample inside a dataset. My code is: data_ostrya - sample(ostrya,200, replace=F) Error in `[.data.frame`(x, .Internal(sample(length(x), size, replace, : cannot take a sample larger than the population when 'replace = FALSE' Why it does not work? The whole dataset is composed of 536 rows and I just want to sample randomly 200 of them... Thank you in advance, Gian On 13 September 2012 14:01, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:43 AM, Gian Maria Niccolò Benucci wrote: Thank you Duncan, I got the result of sampling, but it gave me only the row numbers. Is it possible to have the entire row with variables and other information? Because I need to re-sample inside my matrix the whole rows in reason to have 20 samples (i.e., rows) each year. Thank you for your invaluable help! Use those row numbers to index the dataframe or matrix, e.g. a[rows,] Duncan Murdoch Gian On 13 September 2012 13:32, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 12-09-13 7:18 AM, Gian Maria NiccolÅ Benucci wrote: Thank you very much for your help, I was wondering if is possible to sample randomly specifying to select in a particular group of data inside the matrix, for example only within the whole samples collected in 2011 I would randomly choose 20 random samples... You need two steps: find the rows that meet your condition, then sample from those. For example, rows - which( a$year == 2011 ) sample(rows, 20) There is one thing to watch out for: if you have a condition that only matches one row, you will get unexpected results here, because the sample will be taken from 1:rows. See the examples in ?sample for the workaround that uses sample.int. Duncan Murdoch Thanks a again, Gian On 13 September 2012 12:26, anna freni sterrantino annafr...@yahoo.it wrote: Hello Gian, sure sample function will do it for your sampling. a=as.data.frame(matrix(1:20,4)) sample(rownames(a),2) see ?sample for more details. Hope it helps Cheers Anna Anna Freni Sterrantino Department of Statistics University of Bologna, Italy via Belle Arti 41, 40124 BO. -- *Da:* Gian Maria NiccolÅ Benucci gian.benu...@gmail.com *A:* r-help@r-project.org *Inviato:* GiovedÄ 13 Settembre 2012 10:42 *Oggetto:* [R] random sampling inside a dataset Hi all, I am wondering if do exist a function in R that allow me to sample or choose randomly the rows (i.e., samples) inside a given matrix. Thank you very much in advance. Cheers, -- Gian [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help https://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**help https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html http://www.R-project.org/**posting-guide.html http://www.**R-project.org/posting-guide.**html http://www.R-project.org/posting-guide.html http://www.**r-project.org/**posting-guide.**html http://r-project.org/posting-guide.**html http://**www.r-project.org/posting-**guide.html http://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This body part will be downloaded on demand. [[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] Intermittent connectivity issues for JDBC / Oracle
On Thu, Oct 4, 2012 at 4:29 AM, dh_ss da...@serendipityscience.com wrote: I have been experiencing issues with an R script hanging when connecting to an Oracle database. To help debug, I found a function here in the nabble forum and made a small test script: #!/usr/bin/Rscript --no-restore --no-save --no-init-file library(RJDBC) drv-JDBC(oracle.jdbc.OracleDriver,/home/oracle/lib/ojdbc6.jar, ') dbCheck = function(url, user='', pwd='') { j = .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, url, user, pwd, check=FALSE) x = .jgetEx() .jcheck() x } dbCheck(jdbc:oracle:thin:@192.168.3.10:1521:psrndpt1,myuser,mypass) When I run the file - sometimes it works, returning NULL, and sometimes it hangs for between 1 and 2.5 minutes before throwing an error. The database is new and stable, on the same network - with no connection issues from any other clients. This machine isn't currently doing anything else except for running this script. Output from running it several times looks like this: R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava Error in .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, : ignoring SIGPIPE signal Calls: dbCheck - .jcall - .External Execution halted R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava Error in .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, : ignoring SIGPIPE signal Calls: dbCheck - .jcall - .External Execution halted R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava NULL R@ss-dev:~/scripts$ ./dbCheck.R Loading required package: methods Loading required package: DBI Loading required package: rJava Error in .jcall(java/sql/DriverManager, Ljava/sql/Connection;, getConnection, : ignoring SIGPIPE signal Calls: dbCheck - .jcall - .External Execution halted The times that it returns NULL, it returns immediately. When it throws the error, it is a varying amount of time between roughly 1 and 2.5 minutes. Both machines are not busy at all. Any ideas would greatly appreciated. Thanks. I'd suggest you take this to the R-SIG-DB (Databases) mailing list instead. I don't think it's mirrored on the abomination that is Nabble, so you'll have to subscribe and post there: https://stat.ethz.ch/mailman/listinfo/r-sig-db Note that they'll most certainly want your OS, rJava version, JVM version, R version, and relevant info about the Oracle DB as well. Cheers, Michael __ 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] t-test
Hello, I'm not quite sure I understand, but something like this? tapply(dat$Score, dat$Name, FUN = mean) sapply(unique(dat$Name), function(un){ with(dat, t.test(Score[Name == un], Score[Name != un])$p.value)}) My doubt is in what you mean by mean for CTK and all. The ?t.test gives a confidence interval for the difference in the means, so maybe you'll have to look there for what you want. Hope this helps, Rui Barradas Em 04-10-2012 10:34, Nico Met escreveu: Dear Group, I want to do a t-test calculation on a large data set. I am pasting some part of it structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(CTK100, CTK103, CTK121), class = factor), Score = c(236.9726, 207.0055, 237.3464, 224.4774, 236.5034, 206.7382, 233.94, 240.31, 240.9, 235.15, 223.36, 248.67, 249.25, 201.4051, 244.1689, 182.2756, 229.001, 241.3211, 196.0453, 232.6055, 225.0783, 196.0453, 232.6055, 225.0783 )), .Names = c(Name, Score), class = data.frame, row.names = c(NA, 24L)) I want to compare groups with CTK100 and with all the groups and want to save the p-values and mean for each of that particular group (for example: mean for CTK and all) Similarly, for other groups like that CTK121 etc... Is there any way to automate this process? Thanks for your advice ! Nico [[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] integrate / Vectorize question
Dag Rui, Yes, it helped a lot! Thanks and greetings, Gerrit. Op 10/4/2012 12:06 AM, Rui Barradas schreef: Hello, Try Fnum - function(x, beta){ sapply(x, function(x) integrate(f,lower=-x,upper=0,beta=beta)$value) } And all results were the same. Hope this helps, Rui Barradas Em 03-10-2012 21:59, Gerrit Draisma escreveu: Dear R-users, I want to use the function Fnum below in another integrate procedure. How do I write Fnum so that it returns a vector of values? And will the last integrate return the right answer? (I tried Vectorize() in several places, but got all sorts of errors.) Thanks for helping out. Gerrit. This my code = beta=c(3,0.3)*1E-2 mu-5 f-function(x,beta){beta[1]+beta[2]*x} Fnum-function(x,beta){ integrate(f,lower=-x,upper=0,beta=beta)$value } Fsym-function(x,beta){x*(beta[1]-beta[2]/2*x)} y-1:4 Fsym(y,beta) Fnum(y,beta) g-function(y,mu){exp(-y/mu)/mu} integrate((function(y,beta,mu){Fsym(y,beta)*g(y,mu)}),lower=0,upper=2*mu, beta=beta,mu=mu) #This fails integrate((function(y,beta,mu){Fnum(y,beta)*g(y,mu)}),lower=0,upper=2*mu, beta=beta,mu=mu) t-seq(0,2*mu, by=0.2) 0.2*sum(tapply(t,t,function(y,beta,mu){Fnum(y,beta)*g(y,mu)}, beta=beta,mu=mu)) __ 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] t-test
Dear Rui, Many thanks for help. mean for CTK and all = comparison between mean of all groups ( which means second col) vs. each groups like CTK100, CTK121 etc. Regards Nico On Thu, Oct 4, 2012 at 12:28 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, I'm not quite sure I understand, but something like this? tapply(dat$Score, dat$Name, FUN = mean) sapply(unique(dat$Name), function(un){ with(dat, t.test(Score[Name == un], Score[Name != un])$p.value)}) My doubt is in what you mean by mean for CTK and all. The ?t.test gives a confidence interval for the difference in the means, so maybe you'll have to look there for what you want. Hope this helps, Rui Barradas Em 04-10-2012 10:34, Nico Met escreveu: Dear Group, I want to do a t-test calculation on a large data set. I am pasting some part of it structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(CTK100, CTK103, CTK121), class = factor), Score = c(236.9726, 207.0055, 237.3464, 224.4774, 236.5034, 206.7382, 233.94, 240.31, 240.9, 235.15, 223.36, 248.67, 249.25, 201.4051, 244.1689, 182.2756, 229.001, 241.3211, 196.0453, 232.6055, 225.0783, 196.0453, 232.6055, 225.0783 )), .Names = c(Name, Score), class = data.frame, row.names = c(NA, 24L)) I want to compare groups with CTK100 and with all the groups and want to save the p-values and mean for each of that particular group (for example: mean for CTK and all) Similarly, for other groups like that CTK121 etc... Is there any way to automate this process? Thanks for your advice ! Nico [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] Ops.factor(point1, point2) : - not meaningful for factors
Hello, First of all, it's not a good idea to use 'dist' and 'diff' since they already are names of R functions. As for the problem, your column DSi$Si is not a column of 2-dim points, it's not even a vector of numbers, it's a categorical variable, a factor, like you can see in the output of str(). See the difference with an example, using your first two points. mydist - function (point1, point2){ dff - point1 - point2 distance - sqrt(sum(dff^2)) distance } x - c(5, 20) # these are vectors representing y - c(20, 2) # 2-dim points dist(matrix(c(x, y), ncol=2)) mydist(x, y) Also, it's better to post data using ?dput(). Hope this helps, Rui Barradas Em 04-10-2012 09:07, nadiah escreveu: Hi, can anyone help me in this problem :(. I am a total beginner in R software. It took me 2 days just to look into this problem. Due to this problem. I cant do looping. i want to find the distance between x and DSi DSi i Si 1 1 (5, 20) 2 2 (20, 2) 3 3 (25, 32) 4 4 (8, 39) 5 5 (10, 17) 6 6 (35, 20) 7 7 (38, 10) str (DSi) 'data.frame': 7 obs. of 2 variables: $ i : int 1 2 3 4 5 6 7 $ Si: Factor w/ 7 levels (10, 17),(20, 2),..: 6 2 3 7 1 4 5 x - c(15, 45) y - DSi [,2] dist - function (point1, point2) + { + diff - point1-point2 + distance - sqrt(sum(diff^2)) + distance + } dist (x, y) [1] NA Warning message: In Ops.factor(point1, point2) : - not meaningful for factors Regards, Nadiah -- View this message in context: http://r.789695.n4.nabble.com/Ops-factor-point1-point2-not-meaningful-for-factors-tp4644971.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] Class for time series
On Thu, Oct 4, 2012 at 3:07 AM, Hasan Diwan hasan.di...@gmail.com wrote: Mr. Emmanuel, On 4 October 2012 02:43, Poizot Emmanuel emmanuel.poi...@cnam.fr wrote: Dear all, I have a time serie dataset such as the following with data acquired every 15 minutes: DateHeure Profondeur Température Salinité Turbidité Chloration 1 2012-07-06 08:47:22 -0.144 22.4690.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.4760.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.4980.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.5400.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.5100.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.3720.011 19.280 0 I wonder what is the best class to use to manage such time series Use xts whenever dealing with timeseries, to construct: xts(data.in[,-1:2], order.by=as.POSIXct(paste(data.in[,1:2]))) If you are using xts and reading in the data from an external file then note that xts loads the zoo package and read.zoo can be used to do the actually reading: Lines - DateHeure Profondeur Température Salinité Turbidité Chloration 1 2012-07-06 08:47:22 -0.144 22.4690.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.4760.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.4980.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.5400.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.5100.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.3720.011 19.280 0 library(xts) # also pulls in zoo # z - read.zoo(myfile.dat, header = TRUE, index = 1:2, tz = ) z - read.zoo(text = Lines, header = TRUE, index = 1:2, tz = ) x - as.xts(z) Here index = 1:2 says that the date/time index is in the first two columns and tz = says to interpret it as POSIXct with the indicated time zone. tz = GMT is another possibility. For more info on read.zoo see ?read.zoo . Also there is a document entirely devoted to read.zoo examples obtained by issuing: vignette(zoo-read) . -- 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.
Re: [R] Creating vegetation distance groups from one column
Jean, Take a look at the cut() function, ?cut For example ... mydf - data.frame(nest=1:100, d2veg=runif(100, 0, 60)) mydf$dgroup - cut(mydf$d2veg, breaks=seq(0, 70, 5), include.lowest=TRUE) head(mydf) (another) Jean Jhope jeanwaij...@gmail.com wrote on 10/04/2012 02:27:38 AM: Hi R listers, I am trying to group distances of nests to the vegetation into classes that are define by (0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m, 31-35m, 36-40m, 41-45m, 46-50m, 51-55m, 56-60m). Each row is a nest and all the distances to the vegetation is in a column. In plyr, I have tried - below script but I think I am going about this the wrong way and am not successful. #Veg index star = resp Veg.index - function(values, weights=c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70)) { star - values*weights return(apply(star, 1, sum) / apply(values, 1, sum)) } data.to.analyze$VegIndex - Veg.index(data.to.analyze[,c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70)]) write.csv(data.to.analyze, 3turtlehatch.csv, row.names=FALSE) Please advise, Jean [[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] Problem with colors in contour plot
Dear R users, I have a 51 by 51 matrix of p-values (named as pvalue_MA). I want to present graphically this matrix in a plot (filled contour plot) where both axes represent probabilities. I have also added a grid in this plot. I want to highlight in white the cells of the grid that represent p-values smaller than the (common) significance threshold, 0.05. The code from this plot is colored in blue (I had to copy-pasted all this code in order to reach to the plot). I suspect that the problem might be in the col parameter of the filled.contour function. Honestly, I cannot understand why the plot appears to be completely white!! I checked the values of my variable and it has a great range from 0 to 1. Any suggestion/ comment would really help me to move on with my project. All the best, Loukia __ 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] Creating vegetation distance groups from one column
Hello, Without sample data it's difficult to give an answer but see ?cut. To give a data example, the best way is to use ?dput(). dput( head(mydata, 30) ) # Paste the output of this in a post Hope this helps, Rui Barradas Em 04-10-2012 08:27, Jhope escreveu: Hi R listers, I am trying to group distances of nests to the vegetation into classes that are define by (0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m, 31-35m, 36-40m, 41-45m, 46-50m, 51-55m, 56-60m). Each row is a nest and all the distances to the vegetation is in a column. In plyr, I have tried - below script but I think I am going about this the wrong way and am not successful. #Veg index star = resp Veg.index - function(values, weights=c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70)) { star - values*weights return(apply(star, 1, sum) / apply(values, 1, sum)) } data.to.analyze$VegIndex - Veg.index(data.to.analyze[,c(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70)]) write.csv(data.to.analyze, 3turtlehatch.csv, row.names=FALSE) Please advise, Jean -- View this message in context: http://r.789695.n4.nabble.com/Creating-vegetation-distance-groups-from-one-column-tp4644970.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] Problem with mutli-dimensional array
Thank you very much!! Apparently, If I had defined my main variable (results) as a list a priori, I hadn't had consumed so much time writing and running codes after codes! Your comments were very useful both for the code and my document! Thank you! On Wed, Oct 3, 2012 at 4:35 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, I'm glad it helped. Now you have what is a data structure problem. The computations are the same but in a different output. First of all a terminology issue. In R the correct names for the data structures you've refered to are 'list', 'matrix' and 'array'. To make it short, vector --- 1-dim matrix --- 2-dim array --- n-dim and list --- no dim attribute, can hold any type of data structure. Your first sentence of this last post would read (changes in uppercase) Actually I am trying to make an LIST of length 7, where each LIST ELEMENT IS AN ARRAY containing a different number of 2 by 2 matrices. In what follows, for the 3-dim array case I'll use the naming convention [row, column, slice]. Each of your output list elements is an array with a possibly varying number of slices. Right now all of them have 64 slices. 1. You need a list of 7 elements, each of them indexed by your current 'i'; 2. Each of those elements is a 3-dim array, each slice is a 2x2 matrix and each slice is indexed by your current 'l'. 3. Let's try it. Nx - rep(0, length(x)) Ny - rep(0, length(y)) n - (x+1)*(y+1) results - vector(list, 7) for(i in 1:length(x)){ Nx[i] - length(1:(x[i]+1)) Ny[i] - length(1:(y[i]+1)) results[[i]] - array(dim = c(2, 2, n[i])) l - 1 for(j in 1:(Nx[i])){ for(k in 1:(Ny[i])){ tmp - c((0:x[i])[j], (0:y[i])[k],-(0:x[i])[j], -(0:y[i])[k]) results[[i]][,, l] - mat.stat[,,i] + matrix(tmp, nrow=2, ncol=2,byrow=T) l - l + 1 } } } results I think this is it. Let us now if not. Rui Barradas Em 03-10-2012 08:48, Loukia Spineli escreveu: Thank you very much for your suggestions. They both worked! Actually I am trying to make an array of length 7, where each array contains a different number of 2 by 2 matrices. The vector n defines the different number of matrices across the arrays. Therefore, the parameter l has to change in every array i. Of course I cannot put the vector n directly into the dimensions of the array (under the name results). First, I wanted to see if the code gives rational results assuming that each array has the same number of 2 by 2 matrices. Fortunately, the results are rational (thanks to your help, as well). Now I am taking the problem to the next level and I want to construct this array of different number of 2 by 2 matrices! Any suggestions would be really very helpful! On Tue, Oct 2, 2012 at 6:23 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, See if this is it. Nx - rep(0,length(x)) Ny - rep(0,length(y)) n - (x+1)*(y+1) results - array(0, dim=c(2,2,64,7)) # l - 1 # --- This changed place for(i in 1:length(x)){ Nx[i] - length(1:(x[i]+1)) Ny[i] - length(1:(y[i]+1)) l - 1 # --- To here for(j in 1:(Nx[i])){ for(k in 1:(Ny[i])){ Hope this helps, Rui Barradas Em 02-10-2012 15:20, Loukia Spineli escreveu: I want to make a multi-dimensional array. To be specific I want to make the following array results-array(0,dim=c(2,2,64,7)) This is the code I have created but it gives no result due to the error subscript out of bound. x-rep(7,7) # Missingness in intervention y-rep(7,7) # Missingness in control arraynames-list(Group=c(Success,Failure),Outcome=c( Intervention,Control),Trial=c(1:7)) mat.stat-array(c(9,16,10,15,66,12,44,23,102,88,66,104,**277,** 60,247,119,23,43,20,41,201,162,122, 263,14,41,4,41),dim=c(2,2,7),dimnames=arraynames);mat.stat Nx-rep(0,length(x)) Ny-rep(0,length(y)) n-(x+1)*(y+1) results-array(0,dim=c(2,2,64,7)) l-1 for(i in 1:length(x)){ Nx[i] - length(1:(x[i]+1)) Ny[i] - length(1:(y[i]+1)) for(j in 1:(Nx[i])){ for(k in 1:(Ny[i])){ results[,,l,i]-mat.stat[,,i]+matrix(c(c(0:x[i])[j],c(0:y[**i]** )[k],-c(0:x[i])[j], -c(0:y[i])[k]),nrow=2,ncol=2,byrow=T) l-l+1 } } } results Any suggestion would be really welcome! Thank you very much! Loukia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-helphttps://stat.ethz.ch/mailman/**listinfo/r-help https://stat.**ethz.ch/mailman/listinfo/r-**helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html http://www.R-project.org/**posting-guide.htmlhttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Text to Speech In R
Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks, - Alex [[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] t-test
HI, Try this: sapply(split(dat,dat$Name),function(x) t.test(x[,2],dat[,2])$p.value) # CTK100 CTK103 CTK121 #0.86330310 0.32706859 0.02023357 A.K. - Original Message - From: Nico Met nicome...@gmail.com To: Rui Barradas ruipbarra...@sapo.pt Cc: r-help@r-project.org; r-help r-h...@stat.math.ethz.ch Sent: Thursday, October 4, 2012 6:37 AM Subject: Re: [R] t-test Dear Rui, Many thanks for help. mean for CTK and all = comparison between mean of all groups ( which means second col) vs. each groups like CTK100, CTK121 etc. Regards Nico On Thu, Oct 4, 2012 at 12:28 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, I'm not quite sure I understand, but something like this? tapply(dat$Score, dat$Name, FUN = mean) sapply(unique(dat$Name), function(un){ with(dat, t.test(Score[Name == un], Score[Name != un])$p.value)}) My doubt is in what you mean by mean for CTK and all. The ?t.test gives a confidence interval for the difference in the means, so maybe you'll have to look there for what you want. Hope this helps, Rui Barradas Em 04-10-2012 10:34, Nico Met escreveu: Dear Group, I want to do a t-test calculation on a large data set. I am pasting some part of it structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(CTK100, CTK103, CTK121), class = factor), Score = c(236.9726, 207.0055, 237.3464, 224.4774, 236.5034, 206.7382, 233.94, 240.31, 240.9, 235.15, 223.36, 248.67, 249.25, 201.4051, 244.1689, 182.2756, 229.001, 241.3211, 196.0453, 232.6055, 225.0783, 196.0453, 232.6055, 225.0783 )), .Names = c(Name, Score), class = data.frame, row.names = c(NA, 24L)) I want to compare groups with CTK100 and with all the groups and want to save the p-values and mean for each of that particular group (for example: mean for CTK and all) Similarly, for other groups like that CTK121 etc... Is there any way to automate this process? Thanks for your advice ! Nico [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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-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] Text to Speech In R
Why do you think this is something R should be able to do? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R�console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks, - Alex [[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] Class for time series
Hi, library(xts) xts(dat1[,-1:2],order.by=as.POSIXct(paste(dat1[,1],dat1[,2],sep= ),format=%Y-%m-%d %H:%M:%S)) #Error in .subset(x, j) : only 0's may be mixed with negative subscripts xts(dat1[,3:7],order.by=as.POSIXct(paste(dat1[,1],dat1[,2],sep= ),format=%Y-%m-%d %H:%M:%S)) # Profondeur Température Salinité Turbidité Chloration #2012-07-06 00:00:22 -0.145 22.468 0.011 0.000 0 #2012-07-06 00:02:21 -0.143 22.475 0.011 0.000 0 #2012-07-06 01:17:21 -0.132 22.456 0.011 0.323 0 #2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 #2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 #2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 #2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 #2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 #2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0 A.K. - Original Message - From: Hasan Diwan hasan.di...@gmail.com To: Poizot Emmanuel emmanuel.poi...@cnam.fr Cc: r-help@r-project.org Sent: Thursday, October 4, 2012 3:07 AM Subject: Re: [R] Class for time series Mr. Emmanuel, On 4 October 2012 02:43, Poizot Emmanuel emmanuel.poi...@cnam.fr wrote: Dear all, I have a time serie dataset such as the following with data acquired every 15 minutes: Date Heure Profondeur Température Salinité Turbidité Chloration 1 2012-07-06 08:47:22 -0.144 22.469 0.011 0.000 0 2 2012-07-06 09:02:21 -0.147 22.476 0.011 0.000 0 3 2012-07-06 09:17:21 -0.139 22.498 0.011 19.323 0 4 2012-07-06 09:32:21 -0.136 22.540 0.011 19.343 0 5 2012-07-06 09:47:21 -0.141 22.510 0.011 19.321 0 6 2012-07-06 10:02:21 -0.139 22.372 0.011 19.280 0 I wonder what is the best class to use to manage such time series Use xts whenever dealing with timeseries, to construct: xts(data.in[,-1:2], order.by=as.POSIXct(paste(data.in[,1:2]))) Also, when you post help requests, use dput on your data set. I'm assuming it's a data.frame, but I'd be able to actually test my code if there were dput output in your question. -- H -- Sent from my mobile device Envoyait de mon portable [[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] Text to Speech In R
On Thu, Oct 4, 2012 at 1:31 PM, Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks On Mac OS X, you can access the system faculties to do so with system(say hello) or what have you. M - Alex [[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] Problem with colors in contour plot
Hello, Something like this? myRamp - colorRampPalette(c(lightblue, darkblue)) mypal - myRamp(20) mypal[1] - rgb(1, 1, 1) #?filled.contour ## Persian Rug Art: x - y - seq(-4*pi, 4*pi, len = 27) r - sqrt(outer(x^2, y^2, +)) filled.contour(cos(r^2)^2, frame.plot = FALSE, plot.axes = {}, col = mypal) grid() Hope this helps, Rui Barradas Em 04-10-2012 13:25, Loukia Spineli escreveu: Dear R users, I have a 51 by 51 matrix of p-values (named as pvalue_MA). I want to present graphically this matrix in a plot (filled contour plot) where both axes represent probabilities. I have also added a grid in this plot. I want to highlight in white the cells of the grid that represent p-values smaller than the (common) significance threshold, 0.05. The code from this plot is colored in blue (I had to copy-pasted all this code in order to reach to the plot). I suspect that the problem might be in the col parameter of the filled.contour function. Honestly, I cannot understand why the plot appears to be completely white!! I checked the values of my variable and it has a great range from 0 to 1. Any suggestion/ comment would really help me to move on with my project. All the best, Loukia __ 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] Text to Speech In R
Jeff - so, do you mean that you are sure it can NOT AND SHOULD NOT? Thanks, - Alex From: Jeff Newmiller jdnew...@dcn.davis.ca.us To: Alex Zhang alex.zh...@ymail.com; Alex Zhang alex.zh...@ymail.com; r-help@r-project.org r-help@r-project.org Sent: Thursday, October 4, 2012 8:46 AM Subject: Re: [R] Text to Speech In R Why do you think this is something R should be able to do? --- Jeff Newmiller            The  .   . Go Live... DCN:jdnew...@dcn.davis.ca.us    Basics: ##.#.   ##.#. Live Go...                    Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries      O.O#.   #.O#. with /Software/Embedded Controllers)       .OO#.   .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R�console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks, - Alex    [[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] Text to Speech In R
Thanks, Mike! I am on Windows for this project tho... - Alex From: R. Michael Weylandt michael.weyla...@gmail.com To: Alex Zhang alex.zh...@ymail.com Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, October 4, 2012 8:50 AM Subject: Re: [R] Text to Speech In R On Thu, Oct 4, 2012 at 1:31 PM, Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks On Mac OS X, you can access the system faculties to do so with system(say hello) or what have you. M - Alex [[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] t-test
Hi John, You are right. With more than two groups, the type 1 error rate should be a problem. A.K. - Original Message - From: John Kane jrkrid...@inbox.com To: arun smartpink...@yahoo.com Cc: Sent: Thursday, October 4, 2012 8:40 AM Subject: Re: [R] t-test My stats are lousy but isnt Nico doing some multiple t-tests when an anova with some post hoc comparisons complete with a Tukey or Bonferroni correction looks more suitable? Of course I have no idea of the topic area and maybe he has already done thi. John Kane Kingston ON Canada -Original Message- From: smartpink...@yahoo.com Sent: Thu, 4 Oct 2012 05:31:55 -0700 (PDT) To: nicome...@gmail.com Subject: Re: [R] t-test HI, Try this: sapply(split(dat,dat$Name),function(x) t.test(x[,2],dat[,2])$p.value) # CTK100 CTK103 CTK121 #0.86330310 0.32706859 0.02023357 A.K. - Original Message - From: Nico Met nicome...@gmail.com To: Rui Barradas ruipbarra...@sapo.pt Cc: r-help@r-project.org; r-help r-h...@stat.math.ethz.ch Sent: Thursday, October 4, 2012 6:37 AM Subject: Re: [R] t-test Dear Rui, Many thanks for help. mean for CTK and all = comparison between mean of all groups ( which means second col) vs. each groups like CTK100, CTK121 etc. Regards Nico On Thu, Oct 4, 2012 at 12:28 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, I'm not quite sure I understand, but something like this? tapply(dat$Score, dat$Name, FUN = mean) sapply(unique(dat$Name), function(un){ with(dat, t.test(Score[Name == un], Score[Name != un])$p.value)}) My doubt is in what you mean by mean for CTK and all. The ?t.test gives a confidence interval for the difference in the means, so maybe you'll have to look there for what you want. Hope this helps, Rui Barradas Em 04-10-2012 10:34, Nico Met escreveu: Dear Group, I want to do a t-test calculation on a large data set. I am pasting some part of it structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(CTK100, CTK103, CTK121), class = factor), Score = c(236.9726, 207.0055, 237.3464, 224.4774, 236.5034, 206.7382, 233.94, 240.31, 240.9, 235.15, 223.36, 248.67, 249.25, 201.4051, 244.1689, 182.2756, 229.001, 241.3211, 196.0453, 232.6055, 225.0783, 196.0453, 232.6055, 225.0783 )), .Names = c(Name, Score), class = data.frame, row.names = c(NA, 24L)) I want to compare groups with CTK100 and with all the groups and want to save the p-values and mean for each of that particular group (for example: mean for CTK and all) Similarly, for other groups like that CTK121 etc... Is there any way to automate this process? Thanks for your advice ! Nico [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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-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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! Check it out at http://www.inbox.com/marineaquarium __ 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] Is there any package for Vector Auto-regressive with exogenous variable other than fastVAR?
Package dse also does vector auto-regression with exogenous variables (and also vector ARMA and state-space models with exogenous variables). But I don't understand what you mean by not taking the base in the model so I don't know if it will solve your problem. Paul On 12-10-04 06:00 AM, r-help-requ...@r-project.org wrote: Date: Wed, 3 Oct 2012 23:08:54 -0700 (PDT) From: Sankalpsankalpsing...@gmail.com To:r-help@r-project.org Subject: [R] Is there any package for Vector Auto-regressive with exogenous variable other than fastVAR? Message-ID:1349330934183-4644964.p...@n4.nabble.com Content-Type: text/plain; charset=us-ascii Is there any package for Vector Auto-regressive with exogenous variable other than fastVAR? Because it is not able to solve my problem of not taking the base in the model. Please suggest some appropriate solution -- View this message in context:http://r.789695.n4.nabble.com/Is-there-any-package-for-Vector-Auto-regressive-with-exogenous-variable-other-than-fastVAR-tp4644964.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] Text to Speech In R
Please don't shout. Speech synthesis is associated in my mind with sound generation, which is rather platform-specific. R is a platform agnostic research tool. R can be interfaced with many kinds of external libraries, so many things are possible. However, they aren't necessarily simple, and hiding operating system differences can take a lot of work. Your expectation that this be simple is what seems unwarranted to me. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alex Zhang alex.zh...@ymail.com wrote: Jeff - so, do you mean that you are sure it can NOT AND SHOULD NOT? Thanks, - Alex From: Jeff Newmiller jdnew...@dcn.davis.ca.us To: Alex Zhang alex.zh...@ymail.com; Alex Zhang alex.zh...@ymail.com; r-help@r-project.org r-help@r-project.org Sent: Thursday, October 4, 2012 8:46 AM Subject: Re: [R] Text to Speech In R Why do you think this is something R should be able to do? --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R�console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks, - Alex [[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] Text to Speech In R
Integrating question and my 2 cents. Use R2WD to print your output in word file Use TTS facility of windows to do the speech Never implemented myself but may work Best Regards, Bhupendrasinh Thakre Sent from my iPhone On Oct 4, 2012, at 7:55 AM, Alex Zhang alex.zh...@ymail.com wrote: Thanks, Mike! I am on Windows for this project tho... - Alex From: R. Michael Weylandt michael.weyla...@gmail.com To: Alex Zhang alex.zh...@ymail.com Cc: r-help@r-project.org r-help@r-project.org Sent: Thursday, October 4, 2012 8:50 AM Subject: Re: [R] Text to Speech In R On Thu, Oct 4, 2012 at 1:31 PM, Alex Zhang alex.zh...@ymail.com wrote: Dear all, Excuse me for my searching skills: I just couldn't figure out how to do any simple text to speech in R console. What I want to do is, out put simple English words or sentences to speaker as voice. No fanciness. For example, I want the R console to speak Hello world or Howdy. Do you know of any related function/package? Thanks On Mac OS X, you can access the system faculties to do so with system(say hello) or what have you. M - Alex [[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-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] (minor) R syntax error in help page to the function makeCluster of library(snow)
Dear list, I just realized that one of the examples given in the help page to the function makeCluster of the library(snow) has a small syntax error : ## to get started library(snow) ?makeCluster .. will open a halp page containing the command towards the end of the examples : cl - makeCluster(c(rep(list(macOptions), 2), rep(list(lnxOptions), 2), rep(list(winOptions), 2), type = SOCK) .. which is missing a closing parenthesis. For the rest I'd like to congratulate the developpers of this library for the great job they have done !! Best regards, Wolfgang For completness (according to the posing guide): sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C [3] LC_TIME=fr_FR.UTF-8LC_COLLATE=fr_FR.UTF-8 [5] LC_MONETARY=fr_FR.UTF-8LC_MESSAGES=fr_FR.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] parallel stats graphics grDevices utils datasets methods [8] base loaded via a namespace (and not attached): [1] snow_0.3-10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD IGBMC, 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France wolfgang.raffelsberger (a t) igbmc.fr [[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] smoothScatter plot
Hi, Do you mean something like this? = scatter.smooth(x,y)scatter.smooth(x,y) = It looks like invoking that dcols - densCols(x,y) is callling in some package that is masking the basic::smoothScatter() and applying some other version of smoothScatter, but I am not expert enough to be sure. Another way to get the same result as mine with smoothScatter is to use the ggplot2 package. it looks a bit more complicated but it is very good and in some ways easier to see exactly what is happening. To try it you would need to install the ggplot2 package (install.packages(ggplot2) then with your original x and y data frames === library(ggplot2) xy - cbind(x, y) names(xy) - c(xx, yy) p - ggplot(xy , aes(xx, yy )) + geom_point( ) + geom_smooth( method=loess, se =FALSE) p Thanks for the data set. However it really is easier to use dput() To use dput() simply issue the command dput(myfile) where myfile is the file you are working with. It will give you something like this: == 1 dput(x) structure(c(0.4543462924, 0.2671718761, 0.1641577016, 1.1593356462, 0.0421177346, 0.3127782861, 0.4515537795, 0.5332559665, 0.0913911528, 0.1472054054, 0.1340672893, 1.2599304224, 0.3872026125, 0.0368560053, 0.0371828779, 0.3999714282, 0.0175815783, 0.8871547761, 0.2706762487, 0.7401904063, 0.0991320236, 0.2565567348, 0.5854167363, 0.7515717421, 0.7220388222, 1.3528297744, 0.9339971349, 0.0128652431, 0.4102527051 ), .Dim = c(29L, 1L), .Dimnames = list(NULL, V1)) 1 dput(y) structure(list(V1 = c(0.8669898448, 0.6698647266, 0.1641577016, 0.4779091929, 0.2109900366, 0.2915241414, 0.2363116664, 0.3808731568, 0.379908928, 0.2565868263, 0.1986675964, 0.7589866876, 0.6496236922, 0.1327986663, 0.4196107999, 0.3436442638, 0.1910728051, 0.5625817464, 0.1429791079, 0.6441837334, 0.1477153617, 0.369079266, 0.3839842979, 0.39044223, 0.4186374286, 0.7611640016, 0.446291999, 0.2943343355, 0.3019098386)), .Names = V1, class = data.frame, row.names = c(NA, -29L)) 1 === That is your x in dput() form. You just copy it from the R terminal and paste it into your email message. It is handy if you add the x - and y - to the output. Your method works just fine but it's a bit more cumbersome with a lot of data. Also, please reply to the R-help list as well. It is a source of much more expertise than me and it also can reply when a single person is unavailable. I hope this helps John Kane Kingston ON Canada -Original Message- From: zhyjiang2...@hotmail.com Sent: Thu, 4 Oct 2012 05:19:14 +0800 To: jrkrid...@inbox.com Subject: RE: [R] smoothScatter plot Hi John, Thanks for your reply. But I cannot figure out how to use dput(). I included data and code below. Is that possible to make a plot similar to attached smoothing effect. Zhengyu ### x-read.table(text=0.4543462924 0.2671718761 0.1641577016 1.1593356462 0.0421177346 0.3127782861 0.4515537795 0.5332559665 0.0913911528 0.1472054054 0.1340672893 1.2599304224 0.3872026125 0.0368560053 0.0371828779 0.3999714282 0.0175815783 0.8871547761 0.2706762487 0.7401904063 0.0991320236 0.2565567348 0.5854167363 0.7515717421 0.7220388222 1.3528297744 0.9339971349 0.0128652431 0.4102527051,header=FALSE) y-read.table(text=0.8669898448 0.6698647266 0.1641577016 0.4779091929 0.2109900366 0.2915241414 0.2363116664 0.3808731568 0.379908928 0.2565868263 0.1986675964 0.7589866876 0.6496236922 0.1327986663 0.4196107999 0.3436442638 0.1910728051 0.5625817464 0.1429791079 0.6441837334 0.1477153617 0.369079266 0.3839842979 0.39044223 0.4186374286 0.7611640016 0.446291999 0.2943343355 0.3019098386,header=FALSE) x-data.matrix(x) y-data.matrix(y) dcols - densCols(x,y) smoothScatter(x,y, col = dcols, pch=20,xlab=A,ylab=B) Date: Tue, 2 Oct 2012 05:19:27 -0800 From: jrkrid...@inbox.com Subject: RE: [R] smoothScatter plot To: zhyjiang2...@hotmail.com; r-help@r-project.org It's hard to know what's wrong with your code since you did not supply it. Please supply a small working example and some data. To supply data use the dput() function, see ?dput() for details. John Kane Kingston ON Canada -Original Message- From: zhyjiang2...@hotmail.com Sent: Tue, 2 Oct 2012 11:38:31 +0800 To:
[R] How to convert array dim names to expressions for plotting?
Hi, I would like to use the dim names of an array as labels in a plot. In the case of character labels, this is no problem. However, if I would like to pass expressions through array dim names, they only appear as character labels in the plot and are not evaluated as expressions (see the minimal example below). How can this be done? Cheers, Marius require(grid) tau - c(0.25, 0.75) alpha - c(0.95, 0.99, 0.999) a - array(1:6, dim=c(2,3), dimnames=list(tau=tau, alpha=alpha)) taulabs - as.expression(lapply(tau, function(t) bquote(tau==.(t dimnames(a)$tau - taulabs # does not create expressions dimnames(a) # = no expressions dimnames(a)$tau[[1]] - taulabs[1] dimnames(a)$tau[[2]] - taulabs[2] dimnames(a) # = now characters gl - grid.layout(1, 2, default.units=inch, widths=c(2,2), heights=c(2,2)) ## grid.show.layout(gl) pushViewport(viewport(layout=gl)) pushViewport(viewport(layout.pos.row=1, layout.pos.col=1)) grid.rect(gp=gpar(col=NA, fill=gray80)) grid.text(dimnames(a)[[tau]][1], x=0.5, y=0.5) upViewport() pushViewport(viewport(layout.pos.row=1, layout.pos.col=2)) grid.rect(gp=gpar(col=NA, fill=gray50)) grid.text(dimnames(a)[[tau]][2], x=0.5, y=0.5) upViewport() __ 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 convert array dim names to expressions for plotting?
It is not clear to me what you mean by expressions in this context. Dimension names but be character strings -- see ?dimnames, which says: The dimnames of a matrix or array can be NULL or a list of the same length as dim(x). If a list, its components are either NULL or a character vector with positive length of the appropriate dimension of x. If somehow you expect plotmath type drawn objects or R expression objects, then you are confused. If I am just misunderstanding what you want, then I am confused. -- Bert On Thu, Oct 4, 2012 at 7:27 AM, Hofert Jan Marius marius.hof...@math.ethz.ch wrote: Hi, I would like to use the dim names of an array as labels in a plot. In the case of character labels, this is no problem. However, if I would like to pass expressions through array dim names, they only appear as character labels in the plot and are not evaluated as expressions (see the minimal example below). How can this be done? Cheers, Marius require(grid) tau - c(0.25, 0.75) alpha - c(0.95, 0.99, 0.999) a - array(1:6, dim=c(2,3), dimnames=list(tau=tau, alpha=alpha)) taulabs - as.expression(lapply(tau, function(t) bquote(tau==.(t dimnames(a)$tau - taulabs # does not create expressions dimnames(a) # = no expressions dimnames(a)$tau[[1]] - taulabs[1] dimnames(a)$tau[[2]] - taulabs[2] dimnames(a) # = now characters gl - grid.layout(1, 2, default.units=inch, widths=c(2,2), heights=c(2,2)) ## grid.show.layout(gl) pushViewport(viewport(layout=gl)) pushViewport(viewport(layout.pos.row=1, layout.pos.col=1)) grid.rect(gp=gpar(col=NA, fill=gray80)) grid.text(dimnames(a)[[tau]][1], x=0.5, y=0.5) upViewport() pushViewport(viewport(layout.pos.row=1, layout.pos.col=2)) grid.rect(gp=gpar(col=NA, fill=gray50)) grid.text(dimnames(a)[[tau]][2], x=0.5, y=0.5) upViewport() __ 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] (minor) R syntax error in help page to the function makeCluster of library(snow)
On Thu, Oct 4, 2012 at 2:30 PM, Wolfgang Raffelsberger wolfgang.raffelsber...@gmail.com wrote: Dear list, I just realized that one of the examples given in the help page to the function makeCluster of the library(snow) has a small syntax error : ## to get started library(snow) ?makeCluster .. will open a halp page containing the command towards the end of the examples : cl - makeCluster(c(rep(list(macOptions), 2), rep(list(lnxOptions), 2), rep(list(winOptions), 2), type = SOCK) .. which is missing a closing parenthesis. You should report this to the maintainer of snow (the completely awesome and altogether remarkable Luke Tierney) who I don't believe reads R-help regularly. Use the maintainer() function to get his email. Cheers, Michael __ 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] t-test
Hi, You can also have a look at this paper (no subscription needed): Herberich, E.; Sikorski, J.; and Hothorn, T. (2010). A Robust Procedure for Comparing Multiple Means under Heteroscedasticity in Unbalanced Designs. PLoSONE, Vol. 5, Issue 3, e9788. doi:10.1371/journal.pone.0009788 In this paper, Herberich et al have included a piece of R code to run their procedure. Their procedure is a modification of Tukey, and as it says in the title of the paper, it can be used regardless of whether the samples had different sizes or distributions. José José Iparraguirre Chief Economist Age UK T 020 303 31482 E jose.iparragui...@ageuk.org.uk Twitter @jose.iparraguirre@ageuk Tavis House, 1- 6 Tavistock Square London, WC1H 9NB www.ageuk.org.uk | ageukblog.org.uk | @ageukcampaigns For a copy of our new Economic Monitor and the full Chief Economist's report, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/ For evidence and statistics on the older population, visit the Age UK Knowledge Hub http://www.ageuk.org.uk/professional-resources-home/knowledge-hub-evidence-statistics/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of arun Sent: 04 October 2012 13:59 To: John Kane Cc: R help Subject: Re: [R] t-test Hi John, You are right. With more than two groups, the type 1 error rate should be a problem. A.K. - Original Message - From: John Kane jrkrid...@inbox.com To: arun smartpink...@yahoo.com Cc: Sent: Thursday, October 4, 2012 8:40 AM Subject: Re: [R] t-test My stats are lousy but isnt Nico doing some multiple t-tests when an anova with some post hoc comparisons complete with a Tukey or Bonferroni correction looks more suitable? Of course I have no idea of the topic area and maybe he has already done thi. John Kane Kingston ON Canada -Original Message- From: smartpink...@yahoo.com Sent: Thu, 4 Oct 2012 05:31:55 -0700 (PDT) To: nicome...@gmail.com Subject: Re: [R] t-test HI, Try this: sapply(split(dat,dat$Name),function(x) t.test(x[,2],dat[,2])$p.value) # CTK100 CTK103 CTK121 #0.86330310 0.32706859 0.02023357 A.K. - Original Message - From: Nico Met nicome...@gmail.com To: Rui Barradas ruipbarra...@sapo.pt Cc: r-help@r-project.org; r-help r-h...@stat.math.ethz.ch Sent: Thursday, October 4, 2012 6:37 AM Subject: Re: [R] t-test Dear Rui, Many thanks for help. mean for CTK and all = comparison between mean of all groups ( which means second col) vs. each groups like CTK100, CTK121 etc. Regards Nico On Thu, Oct 4, 2012 at 12:28 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, I'm not quite sure I understand, but something like this? tapply(dat$Score, dat$Name, FUN = mean) sapply(unique(dat$Name), function(un){ with(dat, t.test(Score[Name == un], Score[Name != un])$p.value)}) My doubt is in what you mean by mean for CTK and all. The ?t.test gives a confidence interval for the difference in the means, so maybe you'll have to look there for what you want. Hope this helps, Rui Barradas Em 04-10-2012 10:34, Nico Met escreveu: Dear Group, I want to do a t-test calculation on a large data set. I am pasting some part of it structure(list(Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c(CTK100, CTK103, CTK121), class = factor), Score = c(236.9726, 207.0055, 237.3464, 224.4774, 236.5034, 206.7382, 233.94, 240.31, 240.9, 235.15, 223.36, 248.67, 249.25, 201.4051, 244.1689, 182.2756, 229.001, 241.3211, 196.0453, 232.6055, 225.0783, 196.0453, 232.6055, 225.0783 )), .Names = c(Name, Score), class = data.frame, row.names = c(NA, 24L)) I want to compare groups with CTK100 and with all the groups and want to save the p-values and mean for each of that particular group (for example: mean for CTK and all) Similarly, for other groups like that CTK121 etc... Is there any way to automate this process? Thanks for your advice ! Nico [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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] convert multi dimensional array to list
I have an 4D named array (the result of recast() on a dataframe) and would like to convert it to a list with the names retained. Example: my.df-expand.grid(name=c(Alf,Que), month=c(May,Jun), year=c(2011,2012)) my.df$tmax-sample(15:20,4) my.df$tmin-sample(10:15,4) my.df.melt=melt(my.df) my.df.cast=cast(my.df.melt, year~name~month~variable) I want to convert it to a list so I can access the elements by name like my.df.cast$tmax$May to get the corresponding year-name matrix This assuming, lists provide an easier way to handle this data. Does it? Also, may be there is a way to get the list I want from my.df without going through the melt and cast. Any suggestions are welcome. Thanks in advance Anto PS: I came across threads for converting list to array but not the other way round. -- View this message in context: http://r.789695.n4.nabble.com/convert-multi-dimensional-array-to-list-tp4645011.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] running a regression
Hi all, When I run a regression, I got the following response. your help is appreciated. Error in constants (lhs, cnames_symb) : The hypothesis Cost_PKL-QK.X_(Intercept)=0 is not well formed: contains bad coefficient/variable names. In addition: Warning message: In constants(lhs, cnames_symb) : NAs introduced by coercion Dereje [[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] (no subject)
producing a multi-figure plot, i am try to add beta_1, beta_2,.. beta_9 to ylab using expression or substitution, but cannot work out like for (i in 1:9){ plot(seq(1/m, 1-1/m, 1/m), beta.q[,i], type=l, col=1, ylim=range(beta.q), xlab=quantile, ylab=expresion(beta[i])) } any suggestions will be greatly appreciated. DL [[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] Rainflow, range pair counting
Hello I got some question about R. Im searching for a function or R-code which makes me some collectives. In the literature they are called: level crossing counting rainflow counting range pair counting Cant believe thats not available for R. May I just looking for the wrong word. There functions are used to count the cycles (Range and Means) of a time serie. Thx for helping :) [[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] Error in installing package wordcloud in R
Dear Sir, I faced problem during the installation of wordcloud package in R -2.15 . I have mentioned the error below. After selecting the cran mirror it shows the error. I will be thankful for your response to this solution. Error Selection: 34 Warning: unable to access index for repository http://ftp.iitm.ac.in/cran/src/contrib Error in apply(available[p1, dependencies, drop = FALSE], 1L, function(x) paste(x[!is.na(x)], : subscript out of bounds In addition: Warning messages: 1: In open.connection(con, r) : unable to resolve 'cran.r-project.org' 2: package âwordcloudâ is not available (for R version 2.15.1) Regards Bindu M =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you [[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] convert multi dimensional array to list
On Thu, Oct 4, 2012 at 2:54 PM, anto.r anto.ra...@gmail.com wrote: I have an 4D named array (the result of recast() on a dataframe) and would like to convert it to a list with the names retained. Example: my.df-expand.grid(name=c(Alf,Que), month=c(May,Jun), year=c(2011,2012)) my.df$tmax-sample(15:20,4) my.df$tmin-sample(10:15,4) my.df.melt=melt(my.df) my.df.cast=cast(my.df.melt, year~name~month~variable) I want to convert it to a list so I can access the elements by name like my.df.cast$tmax$May to get the corresponding year-name matrix This assuming, lists provide an easier way to handle this data. Does it? I might actually stick with an array, but avoid the dollar sign syntax: my.df.cast[,,May,] would be one way. Cheers, M Also, may be there is a way to get the list I want from my.df without going through the melt and cast. Any suggestions are welcome. Thanks in advance Anto PS: I came across threads for converting list to array but not the other way round. -- View this message in context: http://r.789695.n4.nabble.com/convert-multi-dimensional-array-to-list-tp4645011.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] Subsetting a group of data
Hi, I am making my way down the learning curve of R, and find it a great language with so many helpful users! Below is an example of what I'm trying to do, but can't quite figure out the right path to go down. Here's what I have: Main is a time series of data with columns Cola and Colb Cola Colb 1 1 1 2 1 1 3 1 1 4 -11 5 -1-1 6 -1-1 7 1 -1 8 -1-1 9 -1-1 10 -1-1 What I would like is to subset the data into groups - rows 1-3 into one group (Cola and Colb both =1), then row 4 by itself, then rows 5-6, then row 7, then rows 8-10. Group 1 Cola Colb 1 1 1 2 1 1 3 1 1 Group 2 Cola Colb 1 -11 Group 3 Cola Colb 1 -1-1 2 -1-1 Thank you for your help! Ian [[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] RPostgreSQL Date format problem
Hi, I've just started using RPostgreSQL within R to interrogate a PostgreSQL database. The problem I have is that a column containing dates shows up differently in R than in the database: here is the output direct from the psql database in Linux: db= select pat_dob_dt from patients where pat_dob_dt like '%1980'; pat_dob_dt 04/05/1980 01/12/1980 04/05/1980 02/10/1980 05/01/1980 25/09/1980 14/12/1980 22/07/1980 24/01/1980 01/07/1980 (10 rows) and here is output from within R: R version 2.15.1 (2012-06-22) -- Roasted Marshmallows Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-redhat-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(RPostgreSQL) Loading required package: DBI dbhost - Sys.getenv(PGHOST) m - dbDriver(PostgreSQL) con - dbConnect(m, dbname = db, host = dbhost) query - SELECT pat_dob_dt from patients where pat_dob_dt like '%1980'; pat_data - dbGetQuery(con, statement = query) pat_data pat_dob_dt 1 4-05-19 2 1-12-19 3 4-05-19 4 2-10-19 5 5-01-19 625-09-19 714-12-19 822-07-19 924-01-19 101-07-19 As you can see it strips off the last two digits in the year, and converts the / to a -. The as.Date function does not help as it cannot magically make the 2 digits appear.is this a setting in RPostgreSQL? Completely stuckgoogle not helped. thanks in advance Scott -- View this message in context: http://r.789695.n4.nabble.com/RPostgreSQL-Date-format-problem-tp4644997.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] Error in installing package wordcloud in R
Try using a different repo: something seems off about whichever one you've tried. M On Thu, Oct 4, 2012 at 9:33 AM, M Bindu/TVM/TCS m.bi...@tcs.com wrote: Dear Sir, I faced problem during the installation of wordcloud package in R -2.15 . I have mentioned the error below. After selecting the cran mirror it shows the error. I will be thankful for your response to this solution. Error Selection: 34 Warning: unable to access index for repository http://ftp.iitm.ac.in/cran/src/contrib Error in apply(available[p1, dependencies, drop = FALSE], 1L, function(x) paste(x[!is.na(x)], : subscript out of bounds In addition: Warning messages: 1: In open.connection(con, r) : unable to resolve 'cran.r-project.org' 2: package ‘wordcloud’ is not available (for R version 2.15.1) Regards Bindu M =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you [[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] R combining vectors into a data frame but without a continuous common variable
Hello, I have two different files which I'd like to combine to make one data frame but I've no idea how to do it! The first file has two columns; one is the date, the following is a binary code for debris flow events. Then my other file has also two columns; the date and then precipitation data. The thing is, is that the two date columns don't all contain the same dates. The binary one is every day from April - October from 1900 - 2005, yet the precipitation file has dates from from say, 1911 to 2004, with some missing data on certain months and during certain years. So my question is how to make a data frame which would have the date, the binary 0 or 1, and then the corresponding precip value from that particular date. I only want the precip information for the days where I have information in the binary file; the others can be disregarded. I have tried using codes which I found in answer to other questions asked but none of them work with my issue. If I'm honest I don't really know if this is what I need. I'm hoping to end up doing a logistic regression. I've uploaded the two files in case I've not been very clear... I'd be really grateful if anyone could help me and suggest a way to do it! I'm also really not very technical and am not at all comfortable with R so if you could be really basic in your advice I'd appreciate it! Many thanks in advance, Lucy Landeck_vec.txt http://r.789695.n4.nabble.com/file/n4644986/Landeck_vec.txt Kaurnetal_vec.txt http://r.789695.n4.nabble.com/file/n4644986/Kaurnetal_vec.txt -- View this message in context: http://r.789695.n4.nabble.com/R-combining-vectors-into-a-data-frame-but-without-a-continuous-common-variable-tp4644986.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 to convert array dim names to expressions for plotting?
Dear Bert, thanks, I was confused (of course). So the right question would have been: How to convert strings to expressions (plotmath expressions). But that I could easily find, thanks. Cheers, Marius Here is the working example (showing plotmath and just-character labels): require(grid) tau - c(0.25, 0.75) alpha - c(0.95, 0.99, 0.999) a - array(1:6, dim=c(2,3), dimnames=list(tau=tau, alpha=alpha)) dimnames(a)$tau[1] - tau==0.25 ## dimnames(a)$tau - paste0(tau==, tau) dimnames(a) gl - grid.layout(1, 2, default.units=inch, widths=c(2,2), heights=c(2,2)) ## grid.show.layout(gl) pushViewport(viewport(layout=gl)) pushViewport(viewport(layout.pos.row=1, layout.pos.col=1)) grid.rect(gp=gpar(col=NA, fill=gray80)) grid.text(parse(text=dimnames(a)[[tau]][1]), x=0.5, y=0.5) upViewport() pushViewport(viewport(layout.pos.row=1, layout.pos.col=2)) grid.rect(gp=gpar(col=NA, fill=gray50)) grid.text(parse(text=dimnames(a)[[tau]][2]), x=0.5, y=0.5) upViewport() From: Bert Gunter [gunter.ber...@gene.com] Sent: Thursday, October 04, 2012 4:42 PM To: Hofert Jan Marius Cc: mailman, r-help Subject: Re: [R] How to convert array dim names to expressions for plotting? It is not clear to me what you mean by expressions in this context. Dimension names but be character strings -- see ?dimnames, which says: The dimnames of a matrix or array can be NULL or a list of the same length as dim(x). If a list, its components are either NULL or a character vector with positive length of the appropriate dimension of x. If somehow you expect plotmath type drawn objects or R expression objects, then you are confused. If I am just misunderstanding what you want, then I am confused. -- Bert On Thu, Oct 4, 2012 at 7:27 AM, Hofert Jan Marius marius.hof...@math.ethz.ch wrote: Hi, I would like to use the dim names of an array as labels in a plot. In the case of character labels, this is no problem. However, if I would like to pass expressions through array dim names, they only appear as character labels in the plot and are not evaluated as expressions (see the minimal example below). How can this be done? Cheers, Marius require(grid) tau - c(0.25, 0.75) alpha - c(0.95, 0.99, 0.999) a - array(1:6, dim=c(2,3), dimnames=list(tau=tau, alpha=alpha)) taulabs - as.expression(lapply(tau, function(t) bquote(tau==.(t dimnames(a)$tau - taulabs # does not create expressions dimnames(a) # = no expressions dimnames(a)$tau[[1]] - taulabs[1] dimnames(a)$tau[[2]] - taulabs[2] dimnames(a) # = now characters gl - grid.layout(1, 2, default.units=inch, widths=c(2,2), heights=c(2,2)) ## grid.show.layout(gl) pushViewport(viewport(layout=gl)) pushViewport(viewport(layout.pos.row=1, layout.pos.col=1)) grid.rect(gp=gpar(col=NA, fill=gray80)) grid.text(dimnames(a)[[tau]][1], x=0.5, y=0.5) upViewport() pushViewport(viewport(layout.pos.row=1, layout.pos.col=2)) grid.rect(gp=gpar(col=NA, fill=gray50)) grid.text(dimnames(a)[[tau]][2], x=0.5, y=0.5) upViewport() __ 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] Problem with colors in contour plot
The contpour plot is very impressive!!! The contour plot I want to display should have only 2 colors: white a grey. I have created this plot for only one trial (see, ppts) and now I am attempting to do the same for many trials. On Thu, Oct 4, 2012 at 3:51 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Something like this? myRamp - colorRampPalette(c(lightblue, darkblue)) mypal - myRamp(20) mypal[1] - rgb(1, 1, 1) #?filled.contour ## Persian Rug Art: x - y - seq(-4*pi, 4*pi, len = 27) r - sqrt(outer(x^2, y^2, +)) filled.contour(cos(r^2)^2, frame.plot = FALSE, plot.axes = {}, col = mypal) grid() Hope this helps, Rui Barradas Em 04-10-2012 13:25, Loukia Spineli escreveu: Dear R users, I have a 51 by 51 matrix of p-values (named as pvalue_MA). I want to present graphically this matrix in a plot (filled contour plot) where both axes represent probabilities. I have also added a grid in this plot. I want to highlight in white the cells of the grid that represent p-values smaller than the (common) significance threshold, 0.05. The code from this plot is colored in blue (I had to copy-pasted all this code in order to reach to the plot). I suspect that the problem might be in the col parameter of the filled.contour function. Honestly, I cannot understand why the plot appears to be completely white!! I checked the values of my variable and it has a great range from 0 to 1. Any suggestion/ comment would really help me to move on with my project. All the best, Loukia __r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/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] Subsetting a group of data
On Thu, Oct 4, 2012 at 3:20 PM, Ian Arvin i...@innovativequant.com wrote: Hi, I am making my way down the learning curve of R, and find it a great language with so many helpful users! Up it hopefully, no? Below is an example of what I'm trying to do, but can't quite figure out the right path to go down. Here's what I have: Main is a time series of data with columns Cola and Colb Cola Colb 1 1 1 2 1 1 3 1 1 4 -11 5 -1-1 6 -1-1 7 1 -1 8 -1-1 9 -1-1 10 -1-1 What I would like is to subset the data into groups - rows 1-3 into one group (Cola and Colb both =1), then row 4 by itself, then rows 5-6, then row 7, then rows 8-10. Group 1 Cola Colb 1 1 1 2 1 1 3 1 1 Group 2 Cola Colb 1 -11 Group 3 Cola Colb 1 -1-1 2 -1-1 Short answer is to ask why you want to do this? There are many functions which operate on the split--apply--combine paradigm (see the JSS article of that name for a short intro) but I find it easier to do this in conjunction with specifying what my data transformation is. To directly answer your question, you'll probably need to combine split() and interaction() in some way. Cheers, Michael __ 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] Explore SPSS function in R
Hi everyone, Does anybody knows if there is an equivalent R function that gives the same outcome as in Explore function in SPSS ? (Analize-Descriptive Statistics-Explore) It does a categorical vs quantitative variables analysis. ( But not linear regression) I need to compare intragroup (categorical variable with 4 values) means and confidence intervals of a quantitative variable. Just like Explore function does. Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Explore-SPSS-function-in-R-tp4645013.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] running a regression
You'll need to supply a reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Cheers, Michael On Thu, Oct 4, 2012 at 2:19 PM, Dereje Bacha d_ba...@yahoo.com wrote: Hi all, When I run a regression, I got the following response. your help is appreciated. Error in constants (lhs, cnames_symb) : The hypothesis Cost_PKL-QK.X_(Intercept)=0 is not well formed: contains bad coefficient/variable names. In addition: Warning message: In constants(lhs, cnames_symb) : NAs introduced by coercion Dereje [[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] Help with R Fitting an inverse Gamma
On Thu, Oct 4, 2012 at 11:42 AM, kmammasis mammasi...@hotmail.com wrote: Dear all, I am new in R and would like to ask for someone's help in understanding where I go wrong with the following code: # rm(list=ls()) # Please don't include this line into your postings: it's quite rude to clobber the data of folks trying to help you. # Required packages library(MCMCpack) # Simulated data set.seed(1) data = rinvgamma(n=250, shape = 5, scale = 2) + 2 # Bad name for a data variable: see library(fortunes) fortune(dog) hist(data) # log-likelihood ll = function(par){ if(par[1]0 par[2]0 par[3]min(data)) return( -sum(log(dinvgamma(data- par[3],par[1],par[2]))) ) else return(Inf) } # MLE mle = optim(c(5,2,2),ll) params = mle$par # Fit hist(data,probability=T,ylim=c(0,2.5)) points(seq(2,4.5,0.001),dinvgamma(seq(2,4.5,0.001)-params[3],params[1],params[2]),type=l,col=red) This code fits an Inverse Gamma distribution to the randomly generated data and plots the associated histogram. My problem is that when I try to import a dataset saved locally it gives me an error. Here is the modification of the code: # Required packages library(MCMCpack) data=my.csv.data$V1 hist(data) # log-likelihood ll = function(par){ if(par[1]0 par[2]0 par[3]min(data)) return( -sum(log(dinvgamma(data- par[3],par[1],par[2]))) ) else return(Inf) } # MLE mle = optim(c(5,2,2),ll) params = mle$par # Fit hist(data,probability=T,ylim=c(0,2.5)) points(seq(2,4.5,0.001),dinvgamma(seq(2,4.5,0.001)-params[3],params[1],params[2]),type=l,col=red) I have attached the file which I import directly from the menu, named: excel250.csv. When I run the code it gives me the following error: No you haven't. The R-help servers scrub most attachments. Use dput() to make a nice reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example Cheers, M Error in optim(c(5, 2, 2), ll) : function cannot be evaluated at initial parameters Totally random guess: your function isn't being evaluated properly either because i) you used the name data() which is also a function and R is having trouble finding your data; ii) your data is such that dinvgamma() gives bad value at the initial point c(5,2,2) Cheers, Michael I would appreciate your help. Thank you. Konstantinos nabble_a href=excel250.csvexcel250.csv -- View this message in context: http://r.789695.n4.nabble.com/Help-with-R-Fitting-an-inverse-Gamma-tp4644984.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] problems with plotting and printing aareg
Hi all, I've ventured into the world of nonparametric survival and I would like to use the maxtime option for printing and plotting my aareg fit. However, my fit does not have test.var2 and this stops the print and plot when adding a maxtime. My code is as follows: Response-Surv(Time,Event) Model-aareg(Response~Factor1*Factor2) Model2-aareg(Response~Factor1+Factor2) #Just did this to see if the interaction term had anything to do with it Model, print(Model), summary(Model), and plot(Model) seem to work fine, but as soon as I try summary/print/plot(Model, maxtime=400) it tells me that test.var2 is not found and when I look at summary(Model), there is indeed a NULL under test.var2. Anyone know why it doesn't include test.var2? Is this a compatibility problem? I'm using R version 2.13 (I know it's quite old, but updating is a pain when you don't have admin rights to your computer) and just updated the survival package (no warning messages). Any input would be much appreciated. Cheers, Freya [[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] Explore SPSS function in R
On Thu, Oct 4, 2012 at 3:28 PM, MARIA RODRIGUEZ mrodrigu...@imim.es wrote: Hi everyone, Does anybody knows if there is an equivalent R function that gives the same outcome as in Explore function in SPSS ? (Analize-Descriptive Statistics-Explore) It does a categorical vs quantitative variables analysis. ( But not linear regression) I'm afraid I don't know what that means like a t.test()? Or ANOVA? I need to compare intragroup (categorical variable with 4 values) means and confidence intervals of a quantitative variable. Just like Explore function does. Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Explore-SPSS-function-in-R-tp4645013.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] Rainflow, range pair counting
R is used by many many folks, and most of us don't have the domain knowledge to make heads or tails of what you're mentioning here. You'll need to greatly clarify and perhaps ask on the appropriate R-SIG-* list. (Ecology maybe?) Perhaps rseek.org is also of help. Cheers, Michael On Thu, Oct 4, 2012 at 1:19 PM, Dandy Ehlert dandy.ehl...@gmail.com wrote: Hello I got some question about R. Im searching for a function or R-code which makes me some collectives. In the literature they are called: level crossing counting rainflow counting range pair counting Cant believe that’s not available for R. May I just looking for the wrong word. There functions are used to count the cycles (Range and Means) of a time serie. Thx for helping :) [[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] Failure of sas7bdat package
R 2.15.1 OS 10.7 Colleagues I have been an enthusiastic user of the sas7bdat package in R. However, several recent sas7bdat files sent to me from different sources cannot be read by the package. The error message is: Error in read.sas7bdat(FILENAME) : unknown host W32_7PRO please report bugs to sas7bdatrb...@gmail.com I examined the file with a text editor and it contains 9.0301M1W32_7PRO in the second line. An older file that works successfully with the package contains 9.0101M3XP_PRO in the same position. Is this causing the failure? Is this something easy to fix? For the moment, I am using StatTransfer to convert the files. StatTransfer has no problem with the newer files suggesting that the problem might be trivial. I have contacted the package maintainer (matt.shotw...@vanderbilt.edu) twice without a response. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.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] Subsetting a group of data
Hello, Try the following. dat - read.table(text= Cola Colb 1 1 1 2 1 1 3 1 1 4 -11 5 -1-1 6 -1-1 7 1 -1 8 -1-1 9 -1-1 10 -1-1 , header=TRUE) idx - dat$Cola != dat$Colb split(dat, 2*cumsum(idx) - idx) Hope this helps, Rui Barradas Em 04-10-2012 15:20, Ian Arvin escreveu: Hi, I am making my way down the learning curve of R, and find it a great language with so many helpful users! Below is an example of what I'm trying to do, but can't quite figure out the right path to go down. Here's what I have: Main is a time series of data with columns Cola and Colb Cola Colb 1 1 1 2 1 1 3 1 1 4 -11 5 -1-1 6 -1-1 7 1 -1 8 -1-1 9 -1-1 10 -1-1 What I would like is to subset the data into groups - rows 1-3 into one group (Cola and Colb both =1), then row 4 by itself, then rows 5-6, then row 7, then rows 8-10. Group 1 Cola Colb 1 1 1 2 1 1 3 1 1 Group 2 Cola Colb 1 -11 Group 3 Cola Colb 1 -1-1 2 -1-1 Thank you for your help! Ian [[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] Failure of sas7bdat package
I can't help troubleshoot the read.sas7bdat function, but if you have the fixed-width data and a SAS importation script, the SAScii package might help you work around this issue. :) On Thu, Oct 4, 2012 at 11:55 AM, Fisher Dennis fis...@plessthan.com wrote: R 2.15.1 OS 10.7 Colleagues I have been an enthusiastic user of the sas7bdat package in R. However, several recent sas7bdat files sent to me from different sources cannot be read by the package. The error message is: Error in read.sas7bdat(FILENAME) : unknown host W32_7PRO please report bugs to sas7bdatrb...@gmail.com I examined the file with a text editor and it contains 9.0301M1W32_7PRO in the second line. An older file that works successfully with the package contains 9.0101M3XP_PRO in the same position. Is this causing the failure? Is this something easy to fix? For the moment, I am using StatTransfer to convert the files. StatTransfer has no problem with the newer files suggesting that the problem might be trivial. I have contacted the package maintainer (matt.shotw...@vanderbilt.edu) twice without a response. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.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. [[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] Explore SPSS function in R
Can you tell us what Explore gives you for the following dataset? d-data.frame(Quant=round(log2(1:24), 2), Categ=LETTERS[rep(1:4,c(8,7,6,3))]) write.table(d, row.names=FALSE, sep=\t) Quant Categ 0 A 1 A 1.58A 2 A 2.32A 2.58A 2.81A 3 A 3.17B 3.32B 3.46B 3.58B 3.7 B 3.81B 3.91B 4 C 4.09C 4.17C 4.25C 4.32C 4.39C 4.46D 4.52D 4.58D Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of MARIA RODRIGUEZ Sent: Thursday, October 04, 2012 7:29 AM To: r-help@r-project.org Subject: [R] Explore SPSS function in R Hi everyone, Does anybody knows if there is an equivalent R function that gives the same outcome as in Explore function in SPSS ? (Analize-Descriptive Statistics-Explore) It does a categorical vs quantitative variables analysis. ( But not linear regression) I need to compare intragroup (categorical variable with 4 values) means and confidence intervals of a quantitative variable. Just like Explore function does. Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Explore-SPSS-function-in- R-tp4645013.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] Analysis of Means in R
Hi, Does anyone know of a package for doing Analysis of Means in R? Or have any functions they would like to share? Thanks, Walt Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 (V) 609-936-8999 (F) 609-936-3733 w...@dataanalyticscorp.com www.dataanalyticscorp.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] convert multi dimensional array to list
Hi Michael thanks! That was the option if I kept it an array. The list format with $ sign since it leaves me feeling that the names are there and can be easily accessed. Why would you rather not use the $ sign? I use R-Studio and there names can be selected from a drop-down list, I have found it easier but that could be my lack of proper training in R. Cheers Anto -- View this message in context: http://r.789695.n4.nabble.com/convert-multi-dimensional-array-to-list-tp4645011p4645036.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] Find the average line from several lines
On Oct 3, 2012, at 10:31 PM, Greg Lollback wrote: Hi people, I'm looking at the influence of sample size on a dataset, so I randomly sampled from the data with different sample sizes multiple times using the sample and replicate function. For example: /replicate(1000, sample(variable name, sample size, replace=T))/. That does not look like it is valid R code. I saved the data, and now I have 1000 replicates of data of various sample sizes (2-33 in my case). If you can picture that one (of 1000) iteration is a line of mean values of the variable for each sample size, i.e. the sample size (2-33) is on the x-axis and the average variable value (number of trees, dogs, cats, whatever) is on the y-axis. This means I have 1000 replicates of a line. *I'm looking to find the average line from several lines *(1000 lines in my case). If your code to do this had been provided we might now have an idea about what the structure of you objects might be. Does anybody know how to do this in R? There was a topic on this using the function approx, but I don't have missing data and my data is on the same scale range. It sounds as though you are redoing the invention of the bootstrap. You could look at package 'boot', although in this case it does sound rather simple. (And it sounds like homework and this mailing list frowns on being used as a surreptitious help line.) -- David Winsemius, MD Alameda, CA, USA __ 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] Explore SPSS function in R
Hi Maria, I suggest starting with the by() function. Here is an example to get you started: by(mtcars$mpg, INDICES = mtcars[c(cyl, am)], FUN = function(x) { list(summary = summary(x), mean.CI95 = confint(lm(x ~ 1))), }) Best, Ista On Thu, Oct 4, 2012 at 10:28 AM, MARIA RODRIGUEZ mrodrigu...@imim.es wrote: Hi everyone, Does anybody knows if there is an equivalent R function that gives the same outcome as in Explore function in SPSS ? (Analize-Descriptive Statistics-Explore) It does a categorical vs quantitative variables analysis. ( But not linear regression) I need to compare intragroup (categorical variable with 4 values) means and confidence intervals of a quantitative variable. Just like Explore function does. Thanks a lot -- View this message in context: http://r.789695.n4.nabble.com/Explore-SPSS-function-in-R-tp4645013.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] Failure of sas7bdat package
On Thu, Oct 4, 2012 at 4:55 PM, Fisher Dennis fis...@plessthan.com wrote: R 2.15.1 OS 10.7 Colleagues I have been an enthusiastic user of the sas7bdat package in R. However, several recent sas7bdat files sent to me from different sources cannot be read by the package. The error message is: Error in read.sas7bdat(FILENAME) : unknown host W32_7PRO please report bugs to sas7bdatrb...@gmail.com I examined the file with a text editor and it contains 9.0301M1W32_7PRO in the second line. An older file that works successfully with the package contains 9.0101M3XP_PRO in the same position. Is this causing the failure? Is this something easy to fix? For the moment, I am using StatTransfer to convert the files. StatTransfer has no problem with the newer files suggesting that the problem might be trivial. Just having a look at the source code for Matt's sas7bdat package, there's a special bug report email: sas7bdat:::BUGREPORT [1] please report bugs to sas7bdatrb...@gmail.com Further, if you read the vignette(sas7bdat) you'll see a lot of technical stuff that has been reverse engineered about the sas format. The source code contains this chunk: # Host systems known to work KNOWNHOST - c(WIN_PRO, WIN_NT, WIN_NTSV, WIN_SRV, WIN_ASRV, XP_PRO, XP_HOME, NET_ASRV, NET_DSRV, NET_SRV, WIN_98, W32_VSPR, WIN, WIN_95, X64_VSPR, X64_ESRV) and it seems your data doesn't have a known host code. I suspect Matt has never seen a SAS file from a Windows 7 Pro box. Now, the code currently doesn't do anything dependent on the host, there's just a cautionary stop() that you have hit. You could edit read.sas7bdat, remove the stop (or add W32_7PRO to the known hosts), reinstall, and see if it works. Or more hackerly, edit the file and replace W32_7PRO with a valid KNOWNHOST of exactly the same length (so as not to upset the delicate binary balance). W32_VSPR would work. Be careful editing binary files with a text editor - it might try to wrap lines or mung your file in nasty ways. Barry __ 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] Failure of sas7bdat package
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Barry Rowlingson Sent: Thursday, October 04, 2012 9:52 AM To: Fisher Dennis Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Failure of sas7bdat package On Thu, Oct 4, 2012 at 4:55 PM, Fisher Dennis fis...@plessthan.com wrote: R 2.15.1 OS 10.7 Colleagues I have been an enthusiastic user of the sas7bdat package in R. However, several recent sas7bdat files sent to me from different sources cannot be read by the package. The error message is: Error in read.sas7bdat(FILENAME) : unknown host W32_7PRO please report bugs to sas7bdatrb...@gmail.com I examined the file with a text editor and it contains 9.0301M1W32_7PRO in the second line. An older file that works successfully with the package contains 9.0101M3XP_PRO in the same position. Is this causing the failure? Is this something easy to fix? For the moment, I am using StatTransfer to convert the files. StatTransfer has no problem with the newer files suggesting that the problem might be trivial. Just having a look at the source code for Matt's sas7bdat package, there's a special bug report email: sas7bdat:::BUGREPORT [1] please report bugs to sas7bdatrb...@gmail.com Further, if you read the vignette(sas7bdat) you'll see a lot of technical stuff that has been reverse engineered about the sas format. The source code contains this chunk: # Host systems known to work KNOWNHOST - c(WIN_PRO, WIN_NT, WIN_NTSV, WIN_SRV, WIN_ASRV, XP_PRO, XP_HOME, NET_ASRV, NET_DSRV, NET_SRV, WIN_98, W32_VSPR, WIN, WIN_95, X64_VSPR, X64_ESRV) and it seems your data doesn't have a known host code. I suspect Matt has never seen a SAS file from a Windows 7 Pro box. Now, the code currently doesn't do anything dependent on the host, there's just a cautionary stop() that you have hit. You could edit read.sas7bdat, remove the stop (or add W32_7PRO to the known hosts), reinstall, and see if it works. Or more hackerly, edit the file and replace W32_7PRO with a valid KNOWNHOST of exactly the same length (so as not to upset the delicate binary balance). W32_VSPR would work. Be careful editing binary files with a text editor - it might try to wrap lines or mung your file in nasty ways. Barry Dennis, Looking at the source code on github, Matt has already added W32_7PRO to the list of known hosts. So, you could download the source tarball and build the package yourself, or just extract the SAS7bdat.R file from the tarball and source it into your R session. Otherwise, you will probably need to wait for the next update to be submitted to CRAN. Hope this is helpful, 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] Failure of sas7bdat package
On Thu, Oct 4, 2012 at 6:07 PM, Nordlund, Dan (DSHS/RDA) nord...@dshs.wa.gov wrote: Looking at the source code on github, Matt has already added W32_7PRO to the list of known hosts. So, you could download the source tarball and build the package yourself, or just extract the SAS7bdat.R file from the tarball and source it into your R session. Otherwise, you will probably need to wait for the next update to be submitted to CRAN. Easy peasy. No need to wait. Just use devtools: install.packages(devtools) # from CRAN library(devtools) install_github(sas7bdat,BioStatMatt) Barry __ 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] Legend Truncated Using filled.contour
On Oct 3, 2012, at 12:58 PM, Kirsten wrote: Hey everyone, I'm working on a contour plot depicting asymptomatic prevalence at varying durations of infectiousness and force of infection. I've been able to work everything out except for this one - my legend title keeps getting cut off. Here's what I have: filled.contour(x=seq(2,30,length.out=nrow(asym_matrix)), y=seq(1,2,length.out=ncol(asym_matrix)), asym_matrix, color = function(x)rev(heat.colors(x)), plot.title = title(main=Asymptomatic Prevalence in 0-4 Year Olds with\n Increasing Duration of Infectiousness, xlab = Duration of Infectiousness, ylab = Relative Force of Infection), key.title = title(main = Asymptomatic\n Prevalence)) My first thought was to make the legend title text smaller using cex = 0.75 (or similar), but it doesn't change the text size at all. In fact, none of the modifiers that I've tried to add to the key.title line (size, color, font, etc) seems to be making a bit of difference. key.title = title(main = Asymptomatic\n Prevalence, cex = 0.75) I couldn't see it until now (that I got your csv file) but you should not be qusoting the cex parameter. Also it should be `cex.main` rather than just `cex`. As explained in the filled.contour help page (which you clearly have read) the legend is really a second plot and you should be using the title function(as you clearly have figured out.) But the details and examples are in ?title . Try: ..., key.title = title(main = Asymptomatic\n Prevalence, cex.main=0.70) ) # 0.75 still got cut off a bit. =, and I think we are both on Macs so this should be the same on a default quartz() window. I assume there's an override earlier in the code, but I have no idea what it is. Any suggestions? People who choose to go to Nabble , a distinctly smaller group, would have been able to find you data, but most people could not. You should have used a .txt extension so you mailer would not improperly label it as something other than MIME-text. Or you could have simply copied the output of dput() into your email. -- David Winsemius, MD Alameda, CA, USA __ 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] Rainflow, range pair counting
A quick Google search suggests that the methods are used in material fatigue studies where varying stress loads are placed upon the material, which puts this into a materials engineering context. Using rseek.org does not give any joy. Perhaps someone with experience in that domain will chime in. Regards, Marc Schwartz On Oct 4, 2012, at 10:27 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: R is used by many many folks, and most of us don't have the domain knowledge to make heads or tails of what you're mentioning here. You'll need to greatly clarify and perhaps ask on the appropriate R-SIG-* list. (Ecology maybe?) Perhaps rseek.org is also of help. Cheers, Michael On Thu, Oct 4, 2012 at 1:19 PM, Dandy Ehlert dandy.ehl...@gmail.com wrote: Hello I got some question about R. Im searching for a function or R-code which makes me some collectives. In the literature they are called: level crossing counting rainflow counting range pair counting Cant believe that’s not available for R. May I just looking for the wrong word. There functions are used to count the cycles (Range and Means) of a time serie. Thx for helping :) __ 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 combining vectors into a data frame but without a continuous common variable
Hello, Try the following. url1 - http://r.789695.n4.nabble.com/file/n4644986/Landeck_vec.txt; url2 - http://r.789695.n4.nabble.com/file/n4644986/Kaurnetal_vec.txt; dat1 - read.table(url1, header = TRUE) dat2 - read.table(url2, header = TRUE) str(dat1) str(dat2) # Precip is a factor, so convert to numeric dat2$Precip - as.numeric(levels(dat2$Precip)[dat2$Precip]) dat1$Landeck - as.Date(dat1$Landeck, format = %d.%m.%Y) dat2$Date - as.Date(dat2$Date, format = %d.%m.%Y) dat3 - merge(dat1, dat2, by.x = Landeck, by.y = Date) str(dat3) head(dat3, 20) # See first 20 rows Hope this helps, Rui Barradas Em 04-10-2012 12:18, lucy88 escreveu: Hello, I have two different files which I'd like to combine to make one data frame but I've no idea how to do it! The first file has two columns; one is the date, the following is a binary code for debris flow events. Then my other file has also two columns; the date and then precipitation data. The thing is, is that the two date columns don't all contain the same dates. The binary one is every day from April - October from 1900 - 2005, yet the precipitation file has dates from from say, 1911 to 2004, with some missing data on certain months and during certain years. So my question is how to make a data frame which would have the date, the binary 0 or 1, and then the corresponding precip value from that particular date. I only want the precip information for the days where I have information in the binary file; the others can be disregarded. I have tried using codes which I found in answer to other questions asked but none of them work with my issue. If I'm honest I don't really know if this is what I need. I'm hoping to end up doing a logistic regression. I've uploaded the two files in case I've not been very clear... I'd be really grateful if anyone could help me and suggest a way to do it! I'm also really not very technical and am not at all comfortable with R so if you could be really basic in your advice I'd appreciate it! Many thanks in advance, Lucy Landeck_vec.txt http://r.789695.n4.nabble.com/file/n4644986/Landeck_vec.txt Kaurnetal_vec.txt http://r.789695.n4.nabble.com/file/n4644986/Kaurnetal_vec.txt -- View this message in context: http://r.789695.n4.nabble.com/R-combining-vectors-into-a-data-frame-but-without-a-continuous-common-variable-tp4644986.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] Errors when saving output from WinBUGS to R
So have you closed WinBUGS regularly (and not via Esc in R) now? Uwe Ligges On 03.10.2012 21:29, yiyiwang wrote: Sorry for any cross messaging. Here are what I've tried and more info. The error sticks :( I installed the latest R2.15.1 (64bit) on my machine, per Uwe's comments. The same error happened. Log file of WinBUGS look perfectly normal: ### display(log) check(C:/Jinmodel/test_codes/model_poisson.txt) model is syntactically correct data(C:/Users/Yiyi/AppData/Local/Temp/RtmpSAhD25/data.txt) data loaded compile(1) model compiled inits(1,C:/Users/Yiyi/AppData/Local/Temp/RtmpSAhD25/inits1.txt) model is initialized gen.inits() command #Bugs:gen.inits cannot be executed (is greyed out) thin.updater(1) update(0) set(beta0) set(beta1) set(beta2) set(beta3) set(deviance) dic.set() update(30) coda(*,C:/Users/Yiyi/AppData/Local/Temp/RtmpSAhD25/coda) stats(*) Node statistics nodemeansd MC error 2.5%median 97.5% start sample beta0 1.652 0.7417 0.3092 1.025 1.381 4.121 1 30 beta1 1.383 0.1343 0.05416 0.8926 1.442 1.491 30 beta2 -0.8984 0.1197 0.0496 -1.008 -0.9378 -0.4977 1 30 beta3 1.745 0.2898 0.1212 0.7972 1.874 1.988 1 30 deviance2461.0 4410.0 1458.0 745.0 880.1 23240.0 1 30 dic.stats() DIC Dbar = post.mean of -2logL; Dhat = -2LogL at post.mean of stochastic nodes DbarDhatpD DIC Y20 2461.0401205.0701255.9703717.010 total 2461.0401205.0701255.9703717.010 history(*,C:/Users/Yiyi/AppData/Local/Temp/RtmpSAhD25/history.odc) ### -- View this message in context: http://r.789695.n4.nabble.com/Errors-when-saving-output-from-WinBUGS-to-R-tp4644899p4644936.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] Error in if (any(ch)) { : missing value where TRUE/FALSE needed
On 03.10.2012 19:47, liang@us.pwc.com wrote: Can someone please help with the error message below? Not really, the message says it all: You cannot improve the AIC since it is numerically -Inf already! Uwe Ligges thanks! Start: AIC=-Inf value ~ 1 + Core_CPI__ + GDP_change + Unemployment + housing + interest + S_P + d1 + d2 + d3 Error in if (any(ch)) { : missing value where TRUE/FALSE needed In addition: Warning message: attempting model selection on an essentially perfect fit is nonsense __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[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] Rainflow, range pair counting
I'm going to make a wild guess that this might have something to do with bump hunting =local conditional extrema. If so, the prim package might be applicable. Otherwise (...cycles in time series) time series methods might be appropriate. But I basically agree with others that the OP has not clearly specified the issue. Cheers, Bert On Thu, Oct 4, 2012 at 10:34 AM, Marc Schwartz marc_schwa...@me.com wrote: A quick Google search suggests that the methods are used in material fatigue studies where varying stress loads are placed upon the material, which puts this into a materials engineering context. Using rseek.org does not give any joy. Perhaps someone with experience in that domain will chime in. Regards, Marc Schwartz On Oct 4, 2012, at 10:27 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: R is used by many many folks, and most of us don't have the domain knowledge to make heads or tails of what you're mentioning here. You'll need to greatly clarify and perhaps ask on the appropriate R-SIG-* list. (Ecology maybe?) Perhaps rseek.org is also of help. Cheers, Michael On Thu, Oct 4, 2012 at 1:19 PM, Dandy Ehlert dandy.ehl...@gmail.com wrote: Hello I got some question about R. Im searching for a function or R-code which makes me some collectives. In the literature they are called: level crossing counting rainflow counting range pair counting Cant believe that’s not available for R. May I just looking for the wrong word. There functions are used to count the cycles (Range and Means) of a time serie. Thx for helping :) __ 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] convert multi dimensional array to list
Hi, You can try this: list2-lapply(1:dim(my.df.cast)[3],function(i) my.df.cast[,,i,]) names(list2)-unlist(dimnames(my.df.cast)[3]) list2$May #, , variable = tmax # # name #year Alf Que # 2011 18 16 # 2012 18 16 #, , variable = tmin # # name #year Alf Que # 2011 12 11 # 2012 12 11 list2$May[,,tmax] # name #year Alf Que # 2011 18 16 # 2012 18 16 A.K. - Original Message - From: anto.r anto.ra...@gmail.com To: r-help@r-project.org Cc: Sent: Thursday, October 4, 2012 11:57 AM Subject: Re: [R] convert multi dimensional array to list Hi Michael thanks! That was the option if I kept it an array. The list format with $ sign since it leaves me feeling that the names are there and can be easily accessed. Why would you rather not use the $ sign? I use R-Studio and there names can be selected from a drop-down list, I have found it easier but that could be my lack of proper training in R. Cheers Anto -- View this message in context: http://r.789695.n4.nabble.com/convert-multi-dimensional-array-to-list-tp4645011p4645036.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] Failure of sas7bdat package
-Original Message- From: b.rowling...@gmail.com [mailto:b.rowling...@gmail.com] On Behalf Of Barry Rowlingson Sent: Thursday, October 04, 2012 10:12 AM To: Nordlund, Dan (DSHS/RDA) Cc: Fisher Dennis; r-h...@stat.math.ethz.ch Subject: Re: [R] Failure of sas7bdat package On Thu, Oct 4, 2012 at 6:07 PM, Nordlund, Dan (DSHS/RDA) nord...@dshs.wa.gov wrote: Looking at the source code on github, Matt has already added W32_7PRO to the list of known hosts. So, you could download the source tarball and build the package yourself, or just extract the SAS7bdat.R file from the tarball and source it into your R session. Otherwise, you will probably need to wait for the next update to be submitted to CRAN. Easy peasy. No need to wait. Just use devtools: install.packages(devtools) # from CRAN library(devtools) install_github(sas7bdat,BioStatMatt) Barry Thanks Barry. I haven't done this before so this saves me from figuring it out myself. :-) 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.
[R] can stepAIC be customized to exclude coefficients with p-value less than certain values?
For example, if coefficient's p-value is less than 0.1 I want the stepwise to automatically drop that variable. Can the stepAIC be customized to do that? SAS seems to be able to customized stepwise function with p-value or cooks'd. thanks! __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[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] Broken Links on http://www.r-project.org
On 26.09.2012 10:56, Viechtbauer Wolfgang (STAT) wrote: I was not sure who I should contact about this, so I am posting this here. There are a few broken links on the R website. 1) http://www.r-project.org/search.html - link to the Nabble R Forum. I belive the correct/new URL should be: http://r.789695.n4.nabble.com/ 2) http://www.r-project.org/other-docs.html - link to Auswertung ökologischer Daten. Not sure if there is a new URL. 3) http://www.r-project.org/other-projects.html - link to Jim Lindsey's R page. I believe the correct/new URL should be: http://www.commanster.eu/rcode.html Thank for letting us know. Changed in the master sources and will go online within 24 hours, Uwe Ligges Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of Psychiatry and Psychology School for Mental Health and Neuroscience Faculty of Health, Medicine, and Life Sciences Maastricht University, P.O. Box 616 (VIJV1) 6200 MD Maastricht, The Netherlands +31 (43) 388-4170 | http://www.wvbauer.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] R combining vectors into a data frame but without a continuous common variable
Hi Lucy, No problem. Just a correction to my earlier email. dat1-read.table(Landeck_vec.txt,sep=,header=TRUE,stringsAsFactors=FALSE) dat2-read.table(Kaurnetal_vec.txt,sep=,header=TRUE,stringsAsFactors=FALSE) colnames(dat1)[1]-Date (Rui: #dat2 Date format is inconsistent.) dat2$Date-gsub(\\.,\\/,dat2$Date) dat1$Date-as.POSIXct(dat1$Date,format=%d.%m.%Y) dat2$Date-as.POSIXct(dat2$Date,format=%d/%m/%Y) str(dat1) #'data.frame': 22623 obs. of 2 variables: # $ Date : POSIXct, format: 1900-04-01 1900-04-02 ... # $ Event: int 0 0 0 0 0 0 0 0 0 0 ... str(dat2) #'data.frame': 36598 obs. of 2 variables: # $ Date : POSIXct, format: 1900-01-01 1900-01-02 ... # $ Precip: chr 0 0 0 0 ... Precip is character, which I convert it to numeric #dat2-within(dat2,{Precip-as.numeric(Precip)}) #Warning message: #In eval(expr, envir, enclos) : NAs introduced by coercion The reason is that there are datapoints which has some unusual characters. which(is.na(dat2$Precip)) # [1] 7060 8584 8798 11235 12848 13701 14006 14038 14098 14311 16016 16748 #[13] 18575 19307 19489 19702 19764 21196 dat2[8584,] # Date Precip #8584 1923-09-01 NA When I looked into the data, I found this: 01/09/1923 L�cke count(is.na(dat2$Precip)) # x freq #1 FALSE 36580 #2 TRUE 18 #Removed those rows. dat3-subset(dat2,!is.na(Precip)) nrow(dat3) #[1] 36580 dat4-merge(dat1,dat3,by=Date) dat5-subset(dat4,Event!=0) nrow(dat5) #[1] 132 rownames(dat5)-1:nrow(dat5) head(dat5) # Date Event Precip #1 1901-06-02 1 0.0 #2 1905-06-02 1 0.0 #3 1906-08-03 1 15.6 #4 1908-05-08 1 0.0 #5 1911-06-02 1 3.0 #6 1911-09-15 1 23.2 A.K. - Original Message - From: lucy88 lucy.fog...@gmail.com To: r-help@r-project.org Cc: Sent: Thursday, October 4, 2012 7:18 AM Subject: [R] R combining vectors into a data frame but without a continuous common variable Hello, I have two different files which I'd like to combine to make one data frame but I've no idea how to do it! The first file has two columns; one is the date, the following is a binary code for debris flow events. Then my other file has also two columns; the date and then precipitation data. The thing is, is that the two date columns don't all contain the same dates. The binary one is every day from April - October from 1900 - 2005, yet the precipitation file has dates from from say, 1911 to 2004, with some missing data on certain months and during certain years. So my question is how to make a data frame which would have the date, the binary 0 or 1, and then the corresponding precip value from that particular date. I only want the precip information for the days where I have information in the binary file; the others can be disregarded. I have tried using codes which I found in answer to other questions asked but none of them work with my issue. If I'm honest I don't really know if this is what I need. I'm hoping to end up doing a logistic regression. I've uploaded the two files in case I've not been very clear... I'd be really grateful if anyone could help me and suggest a way to do it! I'm also really not very technical and am not at all comfortable with R so if you could be really basic in your advice I'd appreciate it! Many thanks in advance, Lucy Landeck_vec.txt http://r.789695.n4.nabble.com/file/n4644986/Landeck_vec.txt Kaurnetal_vec.txt http://r.789695.n4.nabble.com/file/n4644986/Kaurnetal_vec.txt -- View this message in context: http://r.789695.n4.nabble.com/R-combining-vectors-into-a-data-frame-but-without-a-continuous-common-variable-tp4644986.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] Broken Links on http://www.r-project.org
The R Graphics Gallery has moved to http://gallery.r-enthusiasts.com/ and there's another R Graphics Manual at http://rgm2.lab.nig.ac.jp/RGM2 -- H On 26 September 2012 04:56, Viechtbauer Wolfgang (STAT) wolfgang.viechtba...@maastrichtuniversity.nl wrote: I was not sure who I should contact about this, so I am posting this here. There are a few broken links on the R website. 1) http://www.r-project.org/search.html - link to the Nabble R Forum. I belive the correct/new URL should be: http://r.789695.n4.nabble.com/ 2) http://www.r-project.org/other-docs.html - link to Auswertung ökologischer Daten. Not sure if there is a new URL. 3) http://www.r-project.org/other-projects.html - link to Jim Lindsey's R page. I believe the correct/new URL should be: http://www.commanster.eu/rcode.html Best, Wolfgang -- Wolfgang Viechtbauer, Ph.D., Statistician Department of Psychiatry and Psychology School for Mental Health and Neuroscience Faculty of Health, Medicine, and Life Sciences Maastricht University, P.O. Box 616 (VIJV1) 6200 MD Maastricht, The Netherlands +31 (43) 388-4170 | http://www.wvbauer.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. -- Sent from my mobile device Envoyait de mon portable [[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] problem with the installation of r commander on a mac
Dear list members, Im trying to install R Commander under Mac OSX Mountain Lion (10.8.2). After following all the steps described in the installation notes (http://socserv.socsci.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html), I got this error message: = Loading required package: tcltk Loading Tcl/Tk interface ... done Loading required package: car Loading required package: MASS Loading required package: nnet Error : .onLoad failed in loadNamespace() for 'Rcmdr', details: call: structure(.External(dotTclObjv, objv, PACKAGE = tcltk), class = tclObj) error: [tcl] invalid command name tk_messageBox. In addition: Warning message: In fun(libname, pkgname) : couldn't connect to display :0 Error: package/namespace load failed for Rcmdr = The strange thing is that Ive installed Tcl/Tk and XQuark as recommended. Ive also tried uninstalling R, reinstalling the latest version (2.15.1 signed) and all packages, and following the same official steps again. It didnt work neither. Could you please help me? R Commander always worked fine on my iMac, until I updated to Mountain Lion. Best regards, Marco Prof. Dr. Marco A. R. Mello Universidade Federal de Minas Gerais ICB - Depto. Biologia Geral http://marcomello.casadosmorcegos.org marme...@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] R combining vectors into a data frame but without a continuous common variable
Oh my word, you're a genius!! That is absolutely perfect, thank you so much!! I've no idea how you've learnt these things but I would never ever have been able to do that. You've just made my day so much better after the horror of confusion before. Thank you!! -- View this message in context: http://r.789695.n4.nabble.com/R-combining-vectors-into-a-data-frame-but-without-a-continuous-common-variable-tp4644986p4645049.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] (no subject)
Hi I would like to learn how the R function hclust deals with ties. It is written in Fortran, so I cannot access the code. Thanks!! [[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] data structure for plsr
I am having a similar problem understanding the data structure of the yarn dataset described in the [R] data structure for plsr posts. I have spectroscopic data I'd like to run through a PLSR and have read the tutorial series, but still do not understand the data format required for the code to process my data. My current data structure consists of a .csv file read into R containing 15 columns (a charcoal dilution series going from 100% to 0%) and 1050 rows of absorbance data from 400 nm to 2500 nm at 2 nm interval. I think I need to transpose the data such that the specific wavelengths become my columns and dilutions are defined in rows, but after that point I am lost. Should I (and how do I) make my absorbance data into individual matrices that read into a data frame with only two columns (dilution vs spectra or something of the sort that both the yarn and gasoline data use)? Thank you for any pointers. Emma [[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] Coda, HPDinterval and multiple chains
Dear all, I'm not 100% sure if this question is best directed at the r-list, or a mailing list concerned with Bayesian analysis, so please accept my apologies if another audience may be more appropriate. I have been using the rjags package to run Jags models with multiple chains and store the results in a Coda based mcmc list. For instance, having created a jags model and done initial adapting and updating, I run the following command: coda_odp_gini_only - coda.samples(odp_gini_only, variable.names=c(beta,sigma2.u2, deviance), n.iter=itercount, thin=thincount) This create an object with 4 separate chains as requested in my initial call to Jags which created the object odp_gini_only. I then use the Coda package to look at the results stored in coda_odp_gini_only. Prior to running any analysis with Coda, I used the command, coda.options(combine.plots=TRUE, combine.stats=TRUE) to ask for results that combine the four separate chains. Sure enough, if I enter summary(coda_odp_gini_only), I am given a single set of output combining the four chains. However, if I enter HPDinterval(coda_odp_gini_only) I receive 4 sets of HPD figures, one for each chain. Is it possible to combine the four chains together to receive a single set of HPD estimates? In a similar vein, is it possible to use the Coda object to estimate the proportion of a given parameters distribution which is above (or below) a given value, for instance, the proportion of the distribution of beta[1] greater than zero? Again, in doing so, is it possible to combine the results of the four chains into a single estimate? Kind regards, and many thanks in advance for any advice anyone can offer me. Paul Dr Paul Norris Lecturer in Social Policy University of 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.
[R] P value discrepancy plots
Hello R-users, I am trying to plot P value discrepancy plots as describe by Russell Davidson and James G. MacKinnon in Graphical Methods for Investigating the Size and Power of Hypothesis Tests (1998). I know ecdf () to obtain the empirical cumulative distribution frequencies and knots() to extract its values. Supposing p.value as a vector obtained by DGP (out of the loop); is there anyone who already write this short function to obtain the same graph than presented in the mentioned paper (figures P value discrepancy plots)? I am sorry in advance because I know it's not correct to ask the list to do something. But I am pretty sure this could be useful for some of us. TFH -- View this message in context: http://r.789695.n4.nabble.com/P-value-discrepancy-plots-tp4645065.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 help - Adding a column in a data frame with multiple conditions
Hi, I am trying to add a column of numbers to a data frame in R with multiple conditions. Here is a simplified example df: [A] [B] [C] [D] [E] [1] 1 X 90 88 [2] 1 Y 72 70 [3] 1 Z 67 41 [4] 2 X 74 49 [5] 2 Y 42 50 [6] 2 Z 81 56 [7] 3 X 92 59 [8] 3 Y 94 80 [9] 3 Z 80 82 I would like column [E] to have a certain value (found either in [C] or [D]) based on conditions in columns [A] *and* [B]. E.g. : if [A] = 1 and [B] = X, then [E] = the entry in [C] for that row (i.e., 90) if [A] = 1 and [B] = Y, then [E] = the entry in [D] for that row (i.e., 70) if [A] = 1 and [B] = Z, then [E] = the entry in [C] for that row (i.e., 67) if [A] = 2 and [B] = X, then [E] = the entry in [C] for that row (i.e., 74) if [A] = 2 and [B] = Y, then [E] = the entry in [D] for that row (i.e., 50) if [A] = 2 and [B] = Z, then [E] = the entry in [C] for that row (i.e., 81) and so on. ATTEMPT TO RESOLVE: The following code allowed me to add values for column [E] when [A] ==1, but I can't figure out how to keep the code going in order to get a value for column [E] based on all of the numbers in column [A] and the secondary condition for [B] ([A] goes from 1:48). df$[E] - ifelse((df$A == 1) (df$B == X), df$C[df$A == 1], ifelse((df$A == 1) (df$B == Y), df$D[df$A == 1], ifelse((df$A == 1) (df$B == Z), df$C[df$A == 1], NA Thank you for any advice you can give. Libby G libbymg[at]utexas.edu [[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] (no subject)
On Thu, Oct 4, 2012 at 1:40 PM, Chia-Yi Chiu chia-yi.c...@gse.rutgers.edu wrote: Hi I would like to learn how the R function hclust deals with ties. It is written in Fortran, so I cannot access the code. Thanks!! Sure you can. Just download the source from r-project.org. -- Sarah Goslee http://www.functionaldiversity.org __ 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] Creating vegetation distance groups from one column
Hi, Allow me to recap my question. In plyr I am trying to group distances of nests to the vegetation into classes that are defined by (0-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26-30m, 31-35m). Each row is a nest and all the distances to the vegetation is in a column. As well I would like to create classes from the HTL starting at (-5-0m, 1-5m, 6-10m, 11-15m, 16-20m, 21-25m, 26m-30m). I have included a sample of the data through dput() - see below. If that is too tiresome, I've also included head(data.to.analyze) below that. Best, Jean dput(head(data.to.analyze, 30)) structure(list(QuadratEvent = c(8.1A, 10.1A, 14.1A, 19.1A, 23.1A, 24.1A, 25.1A, 29.1A, 30.1A, 31.1A, 32.1A, 33.1A, 38.1A, 39.1A, 41.1A, 47.1A, 48.1A, 50.1A, 52.1A, 53.1A, 58.1A, 63.1A, 68.1A, 73.1A, 75.1A, 79.1A, 29BA, 90.1B, 90.2B, 82.1B), ExDate = c(Nov. 26, 2010, Nov. 26, 2010, Nov. 18, 2010, Nov. 22, 2010, Nov. 20, 2010, Nov. 28, 2010, Nov. 28, 2010, Nov. 27, 2010, Nov. 20, 2010, Nov. 20, 2010, Nov. 26, 2010, Nov. 26, 2010, Nov. 20, 2010, Nov. 26, 2010, Nov. 27, 2010, Nov. 27, 2010, Nov. 26, 2010, Nov. 27, 2010, Nov. 27, 2010, Nov. 27, 2010, Nov. 27, 2010, Nov. 26, 2010, Nov. 26, 2010, Nov. 28, 2010, Nov. 28, 2010, Nov. 26, 2010, Nov. 28, 2010, Jan. 1, 2011, Jan. 1, 2011, Dec. 23, 2010), Sector = c(14, 13, 20, 79, 34, 34, 34, 36, 67, 66, 67, 67, 67, 66, 70, 70, 68, 57, 55, 56, 40, 27, 26, 27, 28, 19, 36, 70, 70, 47), Quadrat = c(8, 10, 14, 19, 23, 24, 25, 29, 30, 31, 32, 33, 38, 39, 41, 47, 48, 50, 52, 53, 58, 63, 68, 73, 75, 79, 29B, 90, 90, 82), Aeventexhumed = c(A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, B, B, B), ST0 = c(6L, 4L, 6L, 0L, 135L, 660L, 321L, 608L, 50L, 5L, 88L, 48L, 7L, 60L, 0L, 69L, 195L, 68L, 162L, 47L, 595L, 144L, 111L, 478L, 636L, 136L, 515L, 213L, 0L, 175L), ST1 = c(0L, 0L, 0L, 0L, 23L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L, 1L, 2L, 0L, 39L, 2L, 1L, 4L, 9L, 1L, 5L, 25L, 4L, 139L, 0L, 0L, 0L), ST2 = c(1L, 0L, 2L, 0L, 1L, 2L, 2L, 0L, 153L, 0L, 0L, 0L, 117L, 93L, 3L, 2L, 0L, 0L, 6L, 2L, 0L, 17L, 1L, 11L, 67L, 0L, 31L, 68L, 0L, 0L), ST3 = c(98L, 109L, 26L, 0L, 6L, 0L, 0L, 0L, 1L, 3L, 11L, 88L, 3L, 342L, 9L, 3L, 4L, 72L, 7L, 81L, 0L, 33L, 103L, 0L, 0L, 218L, 162L, 0L, 74L, 0L), ST4 = c(1L, 1L, 11L, 0L, 0L, 0L, 0L, 0L, 27L, 1L, 0L, 0L, 7L, 0L, 8L, 6L, 0L, 0L, 5L, 4L, 0L, 38L, 150L, 0L, 0L, 19L, 5L, 0L, 0L, 0L), Shells = c(72L, 74L, 106L, 102L, 125L, 4L, 15L, 0L, 31L, 111L, 0L, 0L, 86L, 48L, 21L, 35L, 0L, 0L, 12L, 13L, 0L, 23L, 20L, 3L, 4L, 115L, 5L, 2L, 0L, 0L), Hatchlings = c(3L, 4L, 1L, 1L, 48L, 0L, 0L, 0L, 45L, 99L, 0L, 0L, 93L, 9L, 0L, 0L, 0L, 6L, 2L, 6L, 0L, 9L, 13L, 0L, 0L, 9L, 0L, 0L, 0L, 0L), MaxHatch = c(72L, 74L, 106L, 102L, 125L, 4L, 15L, 0L, 45L, 111L, 0L, 0L, 93L, 48L, 21L, 35L, 0L, 6L, 12L, 13L, 0L, 23L, 20L, 3L, 4L, 118L, 5L, 2L, 0L, 0L), DeadHatch = c(2L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 1L, 5L, 0L, 0L, 0L, 0L, 0L, 2L, 0L, 0L, 0L, 0L, 0L, 6L, 0L, 0L, 0L, 0L), Oldeggs = c(0L, 21L, 165L, 0L, 0L, 36L, 0L, 0L, 96L, 45L, 5L, 142L, 10L, 81L, 103L, 92L, 0L, 0L, 0L, 0L, 108L, 0L, 0L, 0L, 93L, 0L, 0L, 0L, 0L, 0L), TotalEggs = c(178L, 188L, 151L, 102L, 290L, 666L, 338L, 608L, 280L, 120L, 99L, 136L, 227L, 543L, 42L, 117L, 199L, 185L, 194L, 148L, 599L, 264L, 386L, 497L, 732L, 495L, 857L, 283L, 74L, 175L), QuadratID = structure(c(107L, 4L, 22L, 38L, 43L, 44L, 46L, 54L, 57L, 58L, 60L, 61L, 67L, 69L, 72L, 79L, 80L, 81L, 83L, 85L, 91L, 94L, 97L, 103L, 105L, 106L, 56L, 109L, NA, 108L), .Label = c(, 1.1, 1.2, 10.1, 10.2, 100.1, 100.2, 108.1, 108.2, 110.1, 110.2, 114.1, 114.2, 121.1, 121.2, 127.1, 127.2, 128.1, 128.2, 135.1, 135.2, 14.1, 15.1, 15.2, 151.1, 151.2, 152.1, 152.2, 153.1, 153.2, 154.1, 154.2, 155.1, 155.2, 16.1, 16.2, 18.1, 19.1, 21.1, 21.2, 22.1, 22.2, 23.1, 24.1, 24.2, 25.1, 25.2, 26.1, 26.2, 27.1, 27.2, 28.1, 28.2, 29.1, 29.2, 29B, 30.1, 31.1, 31.2, 32.1, 33.1, 33.2, 35.1, 35.2, 37.1, 37.2, 38.1, 38.2, 39.1, 40.1, 40.2, 41.1, 42.1, 42.2, 43.1, 43.2, 46.1, 46.2, 47.1, 48.1, 50.1, 50.2, 52.1, 52.2, 53.1, 53.2, 54.1, 54.2, 56.1, 56.2, 58.1, 62.1, 62.2, 63.1, 65.1, 65.2, 68.1, 68.2, 68.3, 68.4, 69.1, 70.1, 73.1, 74.1, 75.1, 79.1, 8.1, 82.1, 90.1, 94.1, 94.2), class = factor), Sector = c(14L, 13L, 20L, 79L, 34L, 34L, 34L, 36L, 67L, 66L, 67L, 67L, 67L, 66L, 70L, 70L, 68L, 57L, 55L, 56L, 40L, 27L, 26L, 27L, 28L, 19L, 36L, 70L, NA, 47L), Aeventexhumed = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, NA, 3L), .Label = c(, A, B, C), class = factor), Veg = c(9.75, 16.34, 3.15, 5.7, 12.2, 4.82, 3.3, 1.85, 17.75, 27.13, 0.84, 8.45, 16.42, 20.4, 22.4, 25, 25.4, 15.1, 13.7, 17.1, NA, 17.3, 24.3, 9.35, 5.4, 15.5, 1.85, 11, NA, 3), Berm = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 10, NA, 11), HTL = c(4.66, -2.47, 16, NA, 2.35, 22.85, 24, 15.7, 9.55, 4.2, 9.65,
Re: [R] (no subject)
Please use a relevant subject line. You can easily download source code for all CRAN packages and read it yourself. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Chia-Yi Chiu chia-yi.c...@gse.rutgers.edu wrote: Hi I would like to learn how the R function hclust deals with ties. It is written in Fortran, so I cannot access the code. Thanks!! [[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] geoRglm with factor variable as covariable
Dear R users. I'm trying to fit a generalised linear spatial mode using the geoRglm package. To do so, I'm preparing my data (geodata) as follow: geoData9093 = as.geodata(data9093, coords.col= 17:18, data.col=15,* covar.col=16*) where covar.col is a factor variable (years in this case 90-91-92-93)). Then I run the model as follow: / model.5 = list(cov.pars=c(1,1), cov.model='exponential', beta=1, family=poisson) mcmc.5 = mcmc.control(S.scale = 0.25, n.iter = 3, burn.in=5, thin = 100) #trial error outmcmc.5 = glsm.mcmc(geoData9093, model= model.5, mcmc.input = mcmc.5) mcmcobj.5 = prepare.likfit.glsm(outmcmc.5) lik.5 = likfit.glsm(mcmcobj.5, ini.phi = 0.3, fix.nugget.rel = F)/ And the summary of lik.5 is: likfit.glsm: estimated model parameters: beta sigmasq phi tausq.rel 1.2781 0.5193 0.0977 0.0069 likfit.glsm : maximised log-likelihood = 43.62 I'm fairly new to geostatistics, but I thought using a factor variable as covariable would give me 4 intercepts (beta) as I have 4 levels in my covar. But looking at the summary, we see that I only have 1 beta which is equal to 1.28. I guess I made mistakes in specifying the model description, but I can't find where. Any advices would be welcome. With regards, Phil -- View this message in context: http://r.789695.n4.nabble.com/geoRglm-with-factor-variable-as-covariable-tp4645067.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] (no subject)
On Thu, Oct 4, 2012 at 8:55 PM, Sarah Goslee sarah.gos...@gmail.com wrote: On Thu, Oct 4, 2012 at 1:40 PM, Chia-Yi Chiu chia-yi.c...@gse.rutgers.edu wrote: Hi I would like to learn how the R function hclust deals with ties. It is written in Fortran, so I cannot access the code. Thanks!! Sure you can. Just download the source from r-project.org. Or browse online here: https://svn.r-project.org/R/trunk/src/library/stats/src/hclust.f RMW __ 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 help - Adding a column in a data frame with multiple conditions
Hi Libby, You had an accumulation of small errors, from an extra ) to an unclear understanding of how indexing works in R. Also, you shouldn't call your dataframe df, or use square brackets in column names. That said, what about: sampledata - structure(list(A = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L), B = c(X, Y, Z, X, Y, Z, X, Y, Z), C = c(90L, 72L, 67L, 74L, 42L, 81L, 92L, 94L, 80L), D = c(88L, 70L, 41L, 49L, 50L, 56L, 59L, 80L, 82L)), .Names = c(A, B, C, D), class = data.frame, row.names = c(NA, -9L)) E - ifelse((sampledata$A == 1) (sampledata$B == X), sampledata$C, ifelse((sampledata$A == 1) (sampledata$B == Y), sampledata$D, ifelse((sampledata$A == 1) (sampledata$B == Z), sampledata$C, NA))) sampledata - data.frame(sampledata, E) Sarah On Thu, Oct 4, 2012 at 2:47 PM, Libby M Gertken libb...@utexas.edu wrote: Hi, I am trying to add a column of numbers to a data frame in R with multiple conditions. Here is a simplified example df: [A] [B] [C] [D] [E] [1] 1 X 90 88 [2] 1 Y 72 70 [3] 1 Z 67 41 [4] 2 X 74 49 [5] 2 Y 42 50 [6] 2 Z 81 56 [7] 3 X 92 59 [8] 3 Y 94 80 [9] 3 Z 80 82 I would like column [E] to have a certain value (found either in [C] or [D]) based on conditions in columns [A] *and* [B]. E.g. : if [A] = 1 and [B] = X, then [E] = the entry in [C] for that row (i.e., 90) if [A] = 1 and [B] = Y, then [E] = the entry in [D] for that row (i.e., 70) if [A] = 1 and [B] = Z, then [E] = the entry in [C] for that row (i.e., 67) if [A] = 2 and [B] = X, then [E] = the entry in [C] for that row (i.e., 74) if [A] = 2 and [B] = Y, then [E] = the entry in [D] for that row (i.e., 50) if [A] = 2 and [B] = Z, then [E] = the entry in [C] for that row (i.e., 81) and so on. ATTEMPT TO RESOLVE: The following code allowed me to add values for column [E] when [A] ==1, but I can't figure out how to keep the code going in order to get a value for column [E] based on all of the numbers in column [A] and the secondary condition for [B] ([A] goes from 1:48). df$[E] - ifelse((df$A == 1) (df$B == X), df$C[df$A == 1], ifelse((df$A == 1) (df$B == Y), df$D[df$A == 1], ifelse((df$A == 1) (df$B == Z), df$C[df$A == 1], NA Thank you for any advice you can give. Libby G libbymg[at]utexas.edu [[alternative HTML version deleted]] -- Sarah Goslee http://www.functionaldiversity.org __ 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.