Re: [R] Warning message
Hi: A univariate t-distribution with 1 df is equivalent to the standard Cauchy distribution, for which it is well established that the population mean does not exist. You're basically simulating a vector version of the Cauchy distribution (an IID 8-dimensional version), so the same problem is likely to arise. This is exhibited in the tail behavior of the (simulated) distribution of means. It's a little more convenient to do this in terms of arrays rather than lists: library(mvtnorm) # Generate 10 multivariate t samples in 8D and replicate the process 1000 times # result is a 3D array of size 10 x 8 x 1000. rs - array(replicate(1000, rmvt(10, sigma = diag(8), df = 1)), c(10, 8, 1000)) # Average over the 10 samples in each replicate, yielding an 8 x 1000 matrix - # i.e., average over the first dimension of the array rsm - apply(rs, c(2, 3), mean) # Transpose the matrix, convert it to a data frame, and melt it using the # reshape package; this generates an 8000 x 2 data frame, where the first # variable is an indicator for each component of the vector (V1 - V8) and # the value represents the sample values. library(reshape) rr - melt(as.data.frame(t(rsm))) # Use the histogram function in lattice to generate the histograms for each # component of the sample vector: library(lattice) histogram(~ value | variable, data = rr, xlab = 'x', type = 'density') Since your original post averaged over the entire matrix in each replicate, let's do that - just because... rmns - apply(rs, 3, mean) hist(rmns, breaks = 20, probability = TRUE) #or in lattice, histogram(~ rmns, breaks = 20, density = TRUE) [Hint: If you use the median rather than the mean as an estimator, its sampling distribution will behave somewhat closer to what you may expect...] HTH, Dennis On Sun, May 9, 2010 at 10:37 PM, Shant Ch sha1...@yahoo.com wrote: Hello, I want to draw a histogram of the mean of sample observations drawn from multivariate t distribution. I am getting the following error corresponding to the code I used. Though I am getting the graph, but I am curious to know the warning message. Warning messages: 1: In if (freq) x$counts else { : the condition has length 1 and only the first element will be used 2: In if (!freq) Density else Frequency : the condition has length 1 and only the first element will be used --- library(mvtnorm); s12-c(1:1000); var21-lapply(s12,function(x){ rs-rmvt(10, sigma=diag(8), df=1); my-mean(rs); sy-sqrt(var(rs)) return(cbind(my,sy)) }); data1-do.call(rbind,var21); dataMat-data.frame(data1); W-dataMat$my; hist(W,breaks=20,probability=T) --- Thanks. Shant [[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] Warning message
Shant Ch wrote: Warning messages: 1: In if (freq) x$counts else { : the condition has length 1 and only the first element will be used ... hist(W,breaks=20,probability=T) A variable called T lying around with length(T) != 1 ? Try probability=TRUE instead. -- Peter Dalgaard Center for Statistics, Copenhagen Business School Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@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.
[R] How to identify seasonality in time series data??
Dear ALL R Experts, I have a time series and I want to detect presence of seasonality in this time series. I know the method of plotting the Autocorrelation function(acf) and if there are significant lags after period s,2s,3s,... then s is the period for the time series. But my problem is instead of plotting the ACF function, I need to automatically test the presence of seasonality. How this could be done?? Since I have many time series, I need to automate this function which would detect the presence of seasonality along with the period. Is there any package readily available which could do this?? Or there is anyway to do this. Any help would e greatly appreciated Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/How-to-identify-seasonality-in-time-series-data-tp2165031p2165031.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to get p-value from ave
Hi there, I checked google for aov. usually one uses summary to see whether the p-value is small. but I want to put aov in my script. how can I get the p-value, (0.1115, 0.6665, 0.6665 in the following example)? thanks YU datafilename=http://personality-project.org/r/datasets/R.appendix2.data; data.example2=read.table(datafilename,header=T) aov.ex2 = aov(Alertness~Gender*Dosage,data=data.example2) summary(aov.ex2) Df Sum Sq Mean Sq F value Pr(F) Gender 1 76.562 76.562 2.9518 0.1115 Dosage 1 5.062 5.062 0.1952 0.6665 Gender:Dosage 1 0.063 0.063 0.0024 0.6665 Residuals 12 311.250 25.938 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get p-value from ave
Hi: str() is usually helpful: str(summary(aov.ex2)) List of 1 $ :Classes anova and 'data.frame': 4 obs. of 5 variables: ..$ Df : num [1:4] 1 1 1 12 ..$ Sum Sq : num [1:4] 76.5625 5.0625 0.0625 311.25 ..$ Mean Sq: num [1:4] 76.5625 5.0625 0.0625 25.9375 ..$ F value: num [1:4] 2.95181 0.19518 0.00241 NA ..$ Pr(F) : num [1:4] 0.111 0.666 0.962 NA - attr(*, class)= chr [1:2] summary.aov listof summary.lm() outputs a list object with one component and five subcomponents. [[1]] extracts the first component of the list; [[1]][5] extracts the fifth subcomponent. This suggests either of the following ways to extract the p-values: # By component number summary(aov.ex2)[[1]][5] Pr(F) Gender0.1114 Dosage0.6665 Gender:Dosage 0.9617 Residuals # By name summary(aov.ex2)[[1]]$'Pr(F)' [1] 0.1114507 0.6664956 0.9616567NA HTH, Dennis On Mon, May 10, 2010 at 12:17 AM, Yuan Jian jayuan2...@yahoo.com wrote: Hi there, I checked google for aov. usually one uses summary to see whether the p-value is small. but I want to put aov in my script. how can I get the p-value, (0.1115, 0.6665, 0.6665 in the following example)? thanks YU datafilename=http://personality-project.org/r/datasets/R.appendix2.data data.example2=read.table(datafilename,header=T) aov.ex2 = aov(Alertness~Gender*Dosage,data=data.example2) summary(aov.ex2) Df Sum Sq Mean Sq F value Pr(F) Gender 1 76.562 76.562 2.9518 0.1115 Dosage 1 5.062 5.062 0.1952 0.6665 Gender:Dosage 1 0.063 0.063 0.0024 0.6665 Residuals 12 311.250 25.938 [[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] r matrix inconsistencies?
-- View this message in context: http://r.789695.n4.nabble.com/r-matrix-inconsistencies-tp2165121p2165121.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] median of two groups
Thank you very much for that. What is then if I have unpaired and unbalanced samples? Best regards, Cheba 2010/5/7 Bert Gunter gunter.ber...@gene.com Perhaps this might help clarify: sample A: 10 15 20 sample B: 12 15 22 Median of sample A = 15; median of sample B = 15. Sample medians are =. But: B-A differences are 2,0,2 with a median of 2. So the median difference does not equal the difference of the medians. Clarity in what you wish to test (and why!) is essential to determine how. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of cheba meier Sent: Friday, May 07, 2010 12:46 PM To: Joris Meys Cc: R-help@r-project.org; Thomas Lumley Subject: Re: [R] median of two groups Hi all, Thank you for your reply. if done properly! What does this mean? The R-code I have is using the R-function sample without replacement. Am I doing this properly? median of the differences is zero! Does this mean if I run 1000 permutation and for each permutation I compute the median difference and as a result I have 1000 differences. Is the the H0: median(1000 differences) =0? If yes, which conclusion one would have from this H0? Best wishes, Cheba 2010/5/7 Joris Meys jorism...@gmail.com depends on how you interprete absolute median difference. Is that the absolute difference of the medians, or the median of the absolute differences. Probably the latter one, so you would be right. If it's the former one, then it is testing whether the difference of the medians is zero. Cheers Joris On Fri, May 7, 2010 at 6:52 PM, Thomas Lumley tlum...@u.washington.eduwrote: On Fri, 7 May 2010, cheba meier wrote: Dear Thomas, I have been running simulations in order me to understand this problem! I have found something online where the absolute median difference is computed and permutations are ran to compute a p-value. Is such a test (if I can call it a test) tests the null hypothesis that median group 1 = median group 2? No, that is testing whether the median of the differences is zero. This is not the same as testing whether the difference of the medians is zero. -thomas Thank you in advance for your help. Regards, Cheba 2010/4/6 Thomas Lumley tlum...@u.washington.edu None of them. - mood.test() looks promising until you read the help page and see that it does not do Mood's test for equality of quantiles, it does Mood's test for equality of scale parameters. - wilcox.test() is not a test for equal medians - ks.test() is not a test for equal medians. Mood's test for the median involves dichotomizing the data at the pooled median and then doing Fisher's exact test to see if the binary variable has the same mean in the two samples. median.test-function(x,y){ z-c(x,y) g - rep(1:2, c(length(x),length(y))) m-median(z) fisher.test(zm,g)$p.value } Like most exact tests, it is quite conservative at small sample sizes. -thomas On Tue, 6 Apr 2010, cheba meier wrote: Dear all, What is the right test to test whether the median of two groups are statistically significant? Is it the wilcox.test, mood.test or the ks.test? In the text book I have got there is explanation for the Wilcoxon (Mann Whitney) test which tests ob the two variable are from the same population and also ks.test! Regards, Cheba [[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. Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle [[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. Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000
Re: [R] update R 2.11.0,there is error when usi ng plot(), how can I do?
On 09.05.2010 18:37, bbslover wrote: a-1:5 b-2:6 plot(a,b) Error in function (width, height, pointsize, record, rescale, xpinch, : Graphics API version mismatch before, R 2.10 , plot() is ok. Now, R 2.11.0 does not work YYou have probably an old version of the graphics package in your search path. Just look into your libraries and delete any graphics package that are not in your R_HOME/library Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] scope of a function + lazy evaluation
Hey guys, I have a doubt here , It is something simple I guess, what am I missing out here ?? f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) tmp[[1]]() # returns 5; z - f(6) tmp[[1]]() # still returns 5; it should return 6 ideally right ??? Even if I dont evaluate the function tmp[[1]] before i.e I do rm(list=ls()) f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) z - f(6) tmp[[1]]() # it still returns 5; it should return 6 ideally right ??? [[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] tapply function with NA
See ?colSums On Mon, May 10, 2010 at 12:44 AM, vincent.deluard vincent.delu...@trimtabs.com wrote: Hi R users, I have a matrix m of the type: m X4.20.2010 X4.19.2010 X4.16.2010 [1,] 0.008319468 0. -0.008250825 [2,] 0.005574136 0.01816118 0.073081608 [3,] -0.047830688 0.01612903 -0.030239833 [4,] NA NA NA [5,] 0.008746356 0.02848576 -0.025566107 [6,] -0.007990868 0. -0.02667 I want to get the sum of each column. Normally I would do: apply(m,2,sum) but I get: apply(m,2,sum) X4.20.2010 X4.19.2010 X4.16.2010 NA NA NA This is because of the presence of NA in m. How do you the equivalent of sum(m[1:6,1],na.rm=TRUE) using apply? Many thanks! -- View this message in context: http://r.789695.n4.nabble.com/tapply-function-with-NA-tp2164930p2164930.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] hash-2.0.0
The hash-2.0.0 has been released to CRAN. This package implements a data structure similar to hashes in Perl and dictionaries in Python but with a purposefully R flavor. For objects of appreciable size, access using hashes outperforms native named lists and vectors. This version accounts for changes in R-2.11.0 and is optimized for both speed and usabiity. Some references: http://opendatagroup.com/2010/04/26/hash-2-0-0/ http://opendatagroup.com/2009/07/26/hash-package-for-r/ Basic Examples: h - hash( keys=letters, values=1:26 ) h - hash( letters, 1:26 ) h$a # 1 h$foo - bar h[ foo ] h[[ foo ]] clear(h) rm(h) Warmest Regards, Chris Christopher Brown Principal Open Data http://www.opendatagroup.com http://blog.opendatagroup.com [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scope of a function + lazy evaluation
You are missing 'force'. See 'The R Inferno' page 90. In this case you can define: f - function(y) { force(y); function() y} On 10/05/2010 11:06, sayan dasgupta wrote: Hey guys, I have a doubt here , It is something simple I guess, what am I missing out here ?? f- function(y) function() y tmp- vector(list, 5) for (i in 1:5) tmp[[i]]- f(i) tmp[[1]]() # returns 5; z- f(6) tmp[[1]]() # still returns 5; it should return 6 ideally right ??? Even if I dont evaluate the function tmp[[1]] before i.e I do rm(list=ls()) f- function(y) function() y tmp- vector(list, 5) for (i in 1:5) tmp[[i]]- f(i) z- f(6) tmp[[1]]() # it still returns 5; it should return 6 ideally right ??? [[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. -- Patrick Burns pbu...@pburns.seanet.com http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] Bayesian change point package bcp 2.2.0 available
Version 2.2.0 of package bcp is now available. It replaces the suggests of NetWorkSpaces (previously used for optional parallel MCMC) with the dependency on package foreach, giving greater flexibility and supporting a wider range of parallel backends (see doSNOW, doMC, etc...). For those unfamiliar with foreach (thanks to Steve Weston for this contribution), it's a beautiful and highly portable looping construct which can run sequentially or in parallel based on the user's actions (rather than the programmer's choices). We think other package authors might want to consider taking advantage of it for tasks that might be computationally intensive and could be easily done in parallel. Some vignettes are available at http://cran.r-project.org/web/packages/foreach/index.html. Jay Emerson Chandra Erdman -- John W. Emerson (Jay) Associate Professor of Statistics Department of Statistics Yale University http://www.stat.yale.edu/~jay [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] scope of a function + lazy evaluation
Hey thanks for your help , But thats not exactly the problem I have See I am fine with tmp[[1]]() being = 5 and not 1; but then for (i in 1:5) tmp[[i]] - f(i) z - f(6) tmp[[1]]() ## should give 6 right ? Because f(6) was last evaluate so in parent.frame() y should be 6 ??? On Mon, May 10, 2010 at 3:44 PM, Patrick Burns pbu...@pburns.seanet.comwrote: You are missing 'force'. See 'The R Inferno' page 90. In this case you can define: f - function(y) { force(y); function() y} On 10/05/2010 11:06, sayan dasgupta wrote: Hey guys, I have a doubt here , It is something simple I guess, what am I missing out here ?? f- function(y) function() y tmp- vector(list, 5) for (i in 1:5) tmp[[i]]- f(i) tmp[[1]]() # returns 5; z- f(6) tmp[[1]]() # still returns 5; it should return 6 ideally right ??? Even if I dont evaluate the function tmp[[1]] before i.e I do rm(list=ls()) f- function(y) function() y tmp- vector(list, 5) for (i in 1:5) tmp[[i]]- f(i) z- f(6) tmp[[1]]() # it still returns 5; it should return 6 ideally right ??? [[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. -- Patrick Burns pbu...@pburns.seanet.com http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') [[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] scope of a function + lazy evaluation
sayan dasgupta wrote: Hey guys, I have a doubt here , It is something simple I guess, what am I missing out here ?? f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) tmp[[1]]() # returns 5; z - f(6) tmp[[1]]() # still returns 5; it should return 6 ideally right ??? No, each time you call f you create a new y variable in its local evaluation frame. So all 6 of your y variables are different. However, the first 5 of them are all defined by the same expression, i.e. i. Thus the first time they are evaluated they will each get the current value of that variable. After the first evaluation, the value will be fixed, because that is when the value of y is forced. So for example, f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) tmp[[1]]() # returns 5; [1] 5 i - 10 tmp[[2]]() [1] 10 tmp[[1]]() [1] 5 Even if I dont evaluate the function tmp[[1]] before i.e I do rm(list=ls()) f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) z - f(6) tmp[[1]]() # it still returns 5; it should return 6 ideally right ??? See above. Duncan Murdoch [[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] scope of a function + lazy evaluation
When you call a function R passes a promise to it for each argument. A promise consists of the unevaluated variable together with the environment in which it should evaluate the variable when time comes to evaluate it. Thus tmp[[1]] contains function(y) y and in the environment of function(y) y there is a promise y to evaluate i the first time that y is actually used. When you write tmp[[1]]() the promise is evaluated and since i is 5 at the point that is what you get. If f had actually used y when it was called then you would have gotten 1. On Mon, May 10, 2010 at 6:06 AM, sayan dasgupta kitt...@gmail.com wrote: Hey guys, I have a doubt here , It is something simple I guess, what am I missing out here ?? f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) tmp[[1]]() # returns 5; z - f(6) tmp[[1]]() # still returns 5; it should return 6 ideally right ??? Even if I dont evaluate the function tmp[[1]] before i.e I do rm(list=ls()) f - function(y) function() y tmp - vector(list, 5) for (i in 1:5) tmp[[i]] - f(i) z - f(6) tmp[[1]]() # it still returns 5; it should return 6 ideally right ??? [[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] Problems executing cor(dataset) function in R 2.11.0 for OS X ( It works fine in R 2.10.1)
Dear all, when trying to replicate John M. Quick's example for correlations between multiple variables posted on: http://rtutorialseries.blogspot.com/2009/11/r-tutorial-series-zero-order.html with R 2.11.0 (GUI 1.33) using my MacBook Pro with OX X 10.5.8 I got the following error message datavar-read.csv(dataset_readingTests.csv) cor(datavar) Error in cor(datavar) : 'x' must be numeric The funny thing is that when I tried to do the same example using R 2.10.1, it worked fine. Any ideas regarding how to solve this problem? Many thanks in advance, Ruben __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problems executing cor(dataset) function in R 2.11.0 for OS X ( It works fine in R 2.10.1)
On 10/05/2010 7:36 AM, Ruben Garcia Berasategui wrote: Dear all, when trying to replicate John M. Quick's example for correlations between multiple variables posted on: http://rtutorialseries.blogspot.com/2009/11/r-tutorial-series-zero-order.html with R 2.11.0 (GUI 1.33) using my MacBook Pro with OX X 10.5.8 I got the following error message datavar-read.csv(dataset_readingTests.csv) cor(datavar) Error in cor(datavar) : 'x' must be numeric The funny thing is that when I tried to do the same example using R 2.10.1, it worked fine. Any ideas regarding how to solve this problem? I would think the first step would be to ask Mr. Quick what's wrong. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rd files must have a non-empty \title
Hello everybody, I'm trying to install a package I have built. This package contains three scripts with various functions (S3 as well as S4 classes) I run at first the package.skeleton command with: package.skeleton(affyAnalysis, namespace=TRUE, code_files =c(defS3.R, defS4.R, qc.R)) affyAnalysis is the name of the supposed package and the three script are listed at the end. results: Creating directories ... Creating DESCRIPTION ... Creating NAMESPACE ... Creating Read-and-delete-me ... Copying code files ... Making help files ... Done. Further steps are described in './affyAnalysis/Read-and-delete-me'. afterwards i tried to install the made package but i encountered a problem with the RD files. As I am working on windows I did it with the R CMD Install -l path/to/library affyAnalysis. As a result I'm getting the error message: C:\Dokumente und Einstellungen\balt\DesktopR CMD INSTALL affyAnalysis * installing to library 'C:\Programme\R\R-2.11.0\library' * installing *source* package 'affyAnalysis' ... ** R ** preparing package for lazy loading ** help Warning: ./man/affyAnalysis-package.Rd:35: All text must be in a section Warning: ./man/affyAnalysis-package.Rd:36: All text must be in a section Warning: ./man/z_-methods.Rd: \name should not contain !, | or @ *** installing help indices Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title. See chapter 'Writing R documentation' in manual 'Writing R Extensions'. * removing 'C:\Programme\R\R-2.11.0\library/affyAnalysis' My question is is there a way around it? I don't want to publish this package. It's just a compendium of various functions I often use, so i wrote them as a package. How can I install this package under R-2.11.0 without so much trouble as changing ALL of my RD files? THX for the help Assa R.version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 11.0 year 2010 month 04 day22 svn rev51801 language R version.string R version 2.11.0 (2010-04-22) [[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] randomForest: sampling with replacement?
See the replace argument in ?randomForest. Andy -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Dimitri Liakhovitski Sent: Friday, May 07, 2010 12:21 PM To: r-help Subject: [R] randomForest: sampling with replacement? Hello! I know that as trees are constructed, the root node contains a bootstrap sample of data of the same size as original the data set. Would you please confirm that it is a bootstrap sample with replacement? I think it is - just wanted to make sure. Thank you very much! -- Dimitri Liakhovitski Ninah.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. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Machine Learning and R
I've not seen the book myself, but Graham Williams (author of the rattle package) has been working on a book that perhaps may fit your need. http://datamining.togaware.com/survivor/index.html Andy From: Wensui Liu good question! if there is such a book, i'd also like to read as well. On Sun, May 9, 2010 at 7:41 AM, Ralf B ralf.bie...@gmail.com wrote: Hi all, I am looking for a good book that covers Machine Learning as a whole and provides examples in R while not over focusing on the math (such as in 'Elements of Statistical Learning') but rather on descriptions and examples. I am relatively new to R and ML and, while solving problems with R, I want to learn the main concepts, techniques and problem categories. Can anybody here recommend good books? Does anybody know a site that lists good books about R? Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- == WenSui Liu wens...@paypal.com statcompute.spaces.live.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. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installing randomForest on Ubuntu Errors
Hello, I've tried to install randomForest on a Ubuntu 8.04 Hardy Heron system. I've repeatedly rec'd the error: install.packages(randomForest, dependencies = TRUE) ERROR: compiliation failed for package 'randomForest' ** Removing '/home/admuser/R/i486-pc-linux-gnu-library/2.6/randomForest' The downloaded packages are in /tmp/RtmpkDsmTK/downloaded_packages Warning message: In install.packages(randomForest, dependencies = TRUE) : installation of package 'randomForest' had a non-zero exit status The package loads correctly on my windows box, but not on the linux side. Is this package available for Ubuntu Linux, if so what should I do to install it? Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installing randomForest on Ubuntu Errors
I don't know much about how permissions are managed under ubuntu, but you can try a couple of things: - Dirk had worked very hard at automating building of CRAN packages for Debian (from which Ubuntu is based). I believe randomForest is among one of those available. I'm not sure if you need to set up special respository, but the idea is that you should be able to install R packages via apt-get. - Try installing in your home directory and see if that works: Make a directory under your home directory, e.g., called Rlibs. Then in R, do install.packages(randomForest, lib.loc=~/Rlibs, depend=TRUE). If that works, then your original problem is likely caused by permission. Andy From: steve_fried...@nps.gov Hello, I've tried to install randomForest on a Ubuntu 8.04 Hardy Heron system. I've repeatedly rec'd the error: install.packages(randomForest, dependencies = TRUE) ERROR: compiliation failed for package 'randomForest' ** Removing '/home/admuser/R/i486-pc-linux-gnu-library/2.6/randomForest' The downloaded packages are in /tmp/RtmpkDsmTK/downloaded_packages Warning message: In install.packages(randomForest, dependencies = TRUE) : installation of package 'randomForest' had a non-zero exit status The package loads correctly on my windows box, but not on the linux side. Is this package available for Ubuntu Linux, if so what should I do to install it? Thanks Steve Steve Friedman Ph. D. Spatial Statistical Analyst Everglades and Dry Tortugas National Park 950 N Krome Ave (3rd Floor) Homestead, Florida 33034 steve_fried...@nps.gov Office (305) 224 - 4282 Fax (305) 224 - 4147 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rd files must have a non-empty \title
On 10/05/2010 7:43 AM, Assa Yeroslaviz wrote: Hello everybody, I'm trying to install a package I have built. This package contains three scripts with various functions (S3 as well as S4 classes) I run at first the package.skeleton command with: package.skeleton(affyAnalysis, namespace=TRUE, code_files =c(defS3.R, defS4.R, qc.R)) affyAnalysis is the name of the supposed package and the three script are listed at the end. results: Creating directories ... Creating DESCRIPTION ... Creating NAMESPACE ... Creating Read-and-delete-me ... Copying code files ... Making help files ... Done. Further steps are described in './affyAnalysis/Read-and-delete-me'. afterwards i tried to install the made package but i encountered a problem with the RD files. As I am working on windows I did it with the R CMD Install -l path/to/library affyAnalysis. As a result I'm getting the error message: C:\Dokumente und Einstellungen\balt\DesktopR CMD INSTALL affyAnalysis * installing to library 'C:\Programme\R\R-2.11.0\library' * installing *source* package 'affyAnalysis' ... ** R ** preparing package for lazy loading ** help Warning: ./man/affyAnalysis-package.Rd:35: All text must be in a section Warning: ./man/affyAnalysis-package.Rd:36: All text must be in a section Warning: ./man/z_-methods.Rd: \name should not contain !, | or @ *** installing help indices Error in Rd_info(db[[i]]) : Rd files must have a non-empty \title. See chapter 'Writing R documentation' in manual 'Writing R Extensions'. * removing 'C:\Programme\R\R-2.11.0\library/affyAnalysis' My question is is there a way around it? I don't want to publish this package. It's just a compendium of various functions I often use, so i wrote them as a package. How can I install this package under R-2.11.0 without so much trouble as changing ALL of my RD files? You could delete them all (or move them to another directory). You won't pass R CMD check, but it sounds as though you don't care about that. Alternatively, you could write a small function to replace the comment asking for a title with a junk title. Just loop over all the Rd files, read them, substitute for the default title line, and write them back. If you don't want informative help files, it's really not much work to make uninformative ones. Duncan Murdoch THX for the help Assa R.version platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 11.0 year 2010 month 04 day22 svn rev51801 language R version.string R version 2.11.0 (2010-04-22) [[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] randomForest: sampling with replacement?
Would you please confirm that it is a bootstrap sample with replacement? Someone should note that the definition of a bootstrap sample is a sample with replacement (usually of size n). I've read quite a few papers where they claim to be using the bootstrap. Upon further review (sometimes to the code) they often are doing permutation testing-type randomization. This is mostly in biological journals. There are also at least paper that describe the out of box random forests error rate... Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lattice: customising panel.segments using groups
On 9 May 2010 15:25, Ky Mathews ky.math...@sydney.edu.au wrote: Hi, I want to customise the segments on an xyplot. Below is a simple example of what I'm trying to do... #Example dataset x - c(-0.25, 0.25, 0.8) y - c(-0.5, 0, 0.75) gp - c(A, I, C) my.data - cbind.data.frame(x,y,gp) #setting up the parameters to customise the lines with. ltype - c(1,2,3) env.col - c(red, black, blue) env.lwd - c(1.25, 0.75, 1.25) # Lattice plot xyplot(y ~ x, data= my.data, groups = gp, type = l, panel= panel.superpose, panel.groups = function(x,y, subscripts=subscripts, groups=groups,...){ panel.segments(0, 0, x[groups], y[groups], lty = ltype[groups], lwd=env.lwd[groups], col = env.col[groups])}) The 'panel.groups' function is passed a special argument 'group.number', not 'groups'... (Also you do not need to subset 'x' and 'y' because they are already subsetted by 'panel.superpose'.) xyplot(y ~ x, my.data, groups = gp, type = l, panel = panel.superpose, panel.groups = function(x, y, group.number, ...) { panel.segments(0, 0, x, y, lty = ltype[group.number], lwd=env.lwd[group.number], col = env.col[group.number])}) ...however, panel.superpose does this for you automatically, so you only need to pass 'lty', 'lwd' and 'col' arguments to xyplot, and these will be split up by group.number and passed on as single values. For an even better solution, it is recommended to use par.settings (or trellis.par.set for global settings), so that 'auto.key' will work: xyplot(y ~ x, my.data, groups = gp, type = l, panel = panel.superpose, panel.groups = function(x, y, ...) panel.xyplot(c(0, x), c(0, y), ...), par.settings = simpleTheme(col = c(red, black, blue), lwd = c(1.25, 0.75, 1.25), lty = c(1,2,3)), auto.key = list(lines = TRUE, points = FALSE)) HTH -Felix #The problem: I don't seem to have this quite right, as the resulting plot seems to ignore the lty, lwd, col that I set up. I tried to do this by using trellis.par.set/get but simply got confused. If I remove lty, lwd and col specifications I simply get all segments with the same attributes. i.e. it seems to be ignoring the groups #The answer I want: Segment1 has co-ordinates (0,0, x2=-0.25, y2 = -0.5) and be solid, red and of width 1.25 Segment2 has co-ordinates (0,0, x2=0.25, y2 = 0) and be dashed, black and of width 0.75 Segment3 has co-ordinates (0,0, x2=0.8, y2 = 0.75) and be dotted, blue and of width 1.25 Any help is much appreciated. Thanks and regards, Ky Mathews [[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. -- Felix Andrews / 安福立 Postdoctoral Fellow Integrated Catchment Assessment and Management (iCAM) Centre Fenner School of Environment and Society [Bldg 48a] The Australian National University Canberra ACT 0200 Australia M: +61 410 400 963 T: + 61 2 6125 4670 E: felix.andr...@anu.edu.au CRICOS Provider No. 00120C -- http://www.neurofractal.org/felix/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 estimate whether overfitting?
On 05/10/2010 12:32 AM, bbslover wrote: many thanks . I can try to use test set with 100 samples. anther question is that how can I rationally split my data to training set and test set? (training set with 108 samples, and test set with 100 samples) as I know, the test set should the same distribute to the training set. and what method can deal with it to rationally split? and what packages in R can deal with splitting training/test set rationally question? if the split is random. it seems to need many times splits, and the average results consider as the final results. however, I want to several methods to perform split and get the firm training set and test set instead of random split. training set and test set should like this:ideally, the division must be performed sunch that points representing both traing and training set are distributed within the hole feature space occupied by the entire dataset, and each point of the test set is close to at least one point of the training set. this approach ensures that the similarity principle can be enmployed for the output prediction of the test set. Certainly,this condition can not always be satistied. thus, generally, what algorithms often be perform to split? and more rational? some paper often say, they split the data set randomly, thus, what is randomly? just selection random? or have some clear method? e.g. output order, I really know, which package can do with split data rationally? other, if one want to get the better results, some tips can be done. e.g. they can select test set again and again, and use the test set with best results as final test set and say that the test set was selectd randomly, but it is not true random, it is false. thank you, sorry to so many questions. but it puzzled me always. up to now, I have no good method to split rationally my data into training set and test set. at last, split training and test set should be done before modeling, and it seems that this can be done just from featrue? (som) ( or feature and output?(alogorithm spxy. paper:a method for calibration and validation subset partioning) or just output?(output order)). but always, often there are many features to be calculated. and some featrue is zero or low standard deviation(sd0.5), should we delete these features before split the whole data? and use the remaining feature to split data, and just using the training set to build the regression model and to perform feature selection as well as to do cross-validation, and the independent test set just used to test the built model, yes? maybe, my thinking is not clear about the whole model precess. but I think it is like this: 1) get samples 2) calculate features 3) preprocess features calculated (e.g.remove zero) 4)rational split data into training and test set (always puzzle me, how to split on earth?) 5)build model and at the same time tune parameter of model based on the resample methods using just training set. and get the final model. 6) test the model performance using independent test set (unseen samples). 7) estimate the model. good? or bad? overfitting? (generally, what case is overfitting? can you give me a example? as i know, it is overfitting when the trainging set fit good, but the independent test set is bad,but what is good ? what is bad?r2=0.94 in the training set and r2=0.70 in the test, in this case, the model is overfitting? the model can be accepted? and generally what model can be well accetpt?) 8) conclusion. how is the model. above is my thinking. and many question wait for answering. thanks kevin Kevin: I'm sorry I don't have time to deal with such a long note, but briefly data splitting is not a good idea no matter how you do it unless N perhaps 20,000. I suggest resampling, e.g., either the bootstrap with 300 resamples or 50-fold repeats of 10-fold cross-validation. Among other places these are implemented in my rms package. Frank -- Frank E Harrell Jr Professor and ChairmanSchool of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installing randomForest on Ubuntu Errors
Steve, The list r-sig-debian is a more appropriate forum for this question as it is dedicated to R on Debian / Ubuntu. On 10 May 2010 at 08:24, steve_fried...@nps.gov wrote: | | Hello, | | I've tried to install randomForest on a Ubuntu 8.04 Hardy Heron system. | | I've repeatedly rec'd the error: | | install.packages(randomForest, dependencies = TRUE) | | ERROR: compiliation failed for package 'randomForest' | ** Removing '/home/admuser/R/i486-pc-linux-gnu-library/2.6/randomForest' Can you produce the actual error? Ie why did install.packages fail? What happens when you down the source .tar.gz and try sudo R CMD INSTALL randomForest_*.tar.gz instead? Many of us happily run and install numerous packages from CRAN on Debian and/or Ubuntu and I am sure we can help out, but it would be best if you came over to r-sig-debian (and you need to subscribe first). Hth, Dirk | The downloaded packages are in |/tmp/RtmpkDsmTK/downloaded_packages | Warning message: | In install.packages(randomForest, dependencies = TRUE) : | installation of package 'randomForest' had a non-zero exit status | | | | The package loads correctly on my windows box, but not on the linux side. | | Is this package available for Ubuntu Linux, if so what should I do to | install it? | | Thanks | | Steve | | | Steve Friedman Ph. D. | Spatial Statistical Analyst | Everglades and Dry Tortugas National Park | 950 N Krome Ave (3rd Floor) | Homestead, Florida 33034 | | steve_fried...@nps.gov | Office (305) 224 - 4282 | Fax (305) 224 - 4147 | | __ | R-help@r-project.org mailing list | https://stat.ethz.ch/mailman/listinfo/r-help | PLEASE do read the posting guide http://www.R-project.org/posting-guide.html | and provide commented, minimal, self-contained, reproducible code. -- Regards, Dirk __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Comparing Survival: Mantel-Byar Test
The Mantel-Byar test is a simple modification to the logrank test. Can R perform this test or any other similar test? Raphael __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dot plot with error bands
Dear all, I'm trying to create a dot plot with error bands with Dotplot(labels ~ Cbind(estimate, lower, upper), data=For.plot) where estimate, lower and upper are numerical vectors, and labels is a character vector that contains labels. The problem is that labels are automatically sorted alphabetically, and I want them to be sorted by estimate (as in my data frame). This should be straightforward, but unfortunately being new to R I can't figure out how to do this. I'll appreciate your guidance. Best, Alexey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] smoothing parameter in locfit package
Hi, In the locfit package, could someone please let me know the automatic selection of smoothing parameter if Gauss kernel density function is used as weight function? thanks Fir [[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] Extracting a subset
Hi, I have a dataset with many variables and observations. The variable Group has two levels: C and P, the Month variable has four levels: 0, 1, 2 and 3. I want to extract a subset of the variable Weight, considering only 1 and 3 levels for Months of the Group variable. I tried the command subset but it did not work. Any suggestions? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] update R 2.11.0,there is error when usi ng plot(), how can I do?
now. it is ok. I uninstall R2.11.0, then delete an packages in the library, and install again R2.11.0. ok, it does works. thank you! -- View this message in context: http://r.789695.n4.nabble.com/update-R-2-11-0-there-is-error-when-using-plot-how-can-I-do-tp2164517p2165235.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] empty matrix
Dear r-help, Could you help me to find the function which create an empty matrix. I use matrix(), but it gives *a single value that is NA and length of this matrix is 1.* ** *Best Regards* [[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] dot plot with error bands
Dear all, I'm trying to create a dot plot with error bands with Dotplot(labels ~ Cbind(estimate, lower, upper), data=For.plot) where estimate, lower and upper are numerical vectors, and labels is a character vector that contains labels. The problem is that labels are automatically sorted alphabetically, and I want them to be sorted by estimate (as in my data frame). This should be straightforward, but unfortunately being new to R I can't figure out how to do this. I'll appreciate your guidance. Best, Alexey __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] estimating mean income
Hi: This is more a statistical question than an R question (apologies!). I have some income data as follows: $5000 : 598 $5000-$1 : 2586 $65001-$7 : 202 $70001+ : 446 I.e an open ended income class for incomes $70k. What would be the best way to estimate mean income? Something like using a Pareto distribution?. Any suggestion or references are much appreciated. Thanks very much. Erwin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extracting a subset
On 10.05.2010 14:35, Silvano wrote: Hi, I have a dataset with many variables and observations. The variable Group has two levels: C and P, the Month variable has four levels: 0, 1, 2 and 3. I want to extract a subset of the variable Weight, considering only 1 and 3 levels for Months of the Group variable. I tried the command subset but it did not work. Any suggestions? Tell us how you used it and how your data looks like and we may be in a position to help afterwards,. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Uwe Ligges Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empty matrix
On 10.05.2010 13:15, anderson nuel wrote: Dear r-help, Could you help me to find the function which create an empty matrix. Help is: ?matrix Uwe Ligges I use matrix(), but it gives *a single value that is NA and length of this matrix is 1.* ** *Best Regards* [[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] Extracting a subset
Hi, My first suggestion would be to supply a sample data (maybe using the function dput) showing what you have, what you want to do, and what you've tried (you say that subset() didn't work but we don't know how you've typed it). Then, we'll see! Ivan Le 5/10/2010 14:35, Silvano a écrit : Hi, I have a dataset with many variables and observations. The variable Group has two levels: C and P, the Month variable has four levels: 0, 1, 2 and 3. I want to extract a subset of the variable Weight, considering only 1 and 3 levels for Months of the Group variable. I tried the command subset but it did not work. Any suggestions? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empty matrix
On 10/05/2010 7:15 AM, anderson nuel wrote: Dear r-help, Could you help me to find the function which create an empty matrix. I use matrix(), but it gives *a single value that is NA and length of this matrix is 1.* Not sure what you mean by an empty matrix, but here's one interpretation: matrix(numeric(0), 0,0) This gives a 0 by 0 matrix. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] empty matrix
I think matrix(nrow=0, ncol=0) will do it. -Ista On Mon, May 10, 2010 at 7:15 AM, anderson nuel anderson@gmail.comwrote: Dear r-help, Could you help me to find the function which create an empty matrix. I use matrix(), but it gives *a single value that is NA and length of this matrix is 1.* ** *Best Regards* [[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. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org [[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] dot plot with error bands
On May 10, 2010, at 10:00 AM, Alexey Bessudnov wrote: Dear all, I'm trying to create a dot plot with error bands with Dotplot(labels ~ Cbind(estimate, lower, upper), data=For.plot) where estimate, lower and upper are numerical vectors, and labels is a character vector that contains labels. The problem is that labels are automatically sorted alphabetically, and I want them to be sorted by estimate (as in my data frame). This should be straightforward, but unfortunately being new to R I can't figure out how to do this. I'll appreciate your guidance. Have you tried making labels (an unfortunate choice for a variable name, BTW) a factor variable with levels in the order of your desire? (Also being new to R, you may not recognize the difference between a factor variable and a character vector, so producing a more explicit description of the dataframe For.plot with the str function ought to be your next contribution to this thread if the above solution is not effective. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] smoothing parameter in locfit package
See the kern argument in ?locfit.raw. Andy From: FMH Hi, In the locfit package, could someone please let me know the automatic selection of smoothing parameter if Gauss kernel density function is used as weight function? thanks Fir [[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. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Extracting a subset
Hi, I used #-- # Análise do PESO - #-- pesom1 = cbind(PESO[MÊS==1]) pesom3 = cbind(PESO[MÊS==3]) #- Grupo Placebo - pesom1p = pesom1[GRUPO=='P'] pesom3p = pesom3[GRUPO=='P'] t.test(pesom1p, pesom3p, paired=T) #- Grupo Cogumelo - pesom1c = pesom1[GRUPO=='C'] pesom3c = pesom3[GRUPO=='C'] t.test(pesom1c, pesom3c, paired=T) to compare PESO between MÊS (Months) inside GRUPO (t-paired). CICLO was fixed. But, I have two CICLOS, and I would like compare PESO between MÊS==3 (CICLO 3) and MÊS==6 (CICLO 6) inside GRUPO (1 and 2). My file has (part of data): Ciclo Mês Grupo Peso 3 0 1 62.2 3 0 1 67.0 3 0 1 71.5 3 0 2 70.0 3 0 2 71.0 3 0 2 69.5 3 1 1 60.0 3 1 1 51.2 3 1 1 70.0 3 1 2 59.0 3 1 2 56.5 3 1 2 70.0 3 2 1 68.0 3 2 1 69.0 3 2 1 66.0 3 2 2 56.0 3 2 2 53.0 3 2 2 96.0 3 3 1 67.0 3 3 1 70.0 3 3 1 67.0 3 3 2 71.5 3 3 2 70.0 3 3 2 71.0 6 0 1 66.2 6 0 1 65.0 6 0 1 73.5 6 0 2 78.0 6 0 2 71.0 6 0 2 62.5 6 1 1 63.0 6 1 1 51.2 6 1 1 72.0 6 1 2 59.0 6 1 2 57.5 6 1 2 79.0 6 2 1 78.0 6 2 1 66.0 6 2 1 63.0 6 2 2 52.0 6 2 2 54.0 6 2 2 93.0 6 3 1 62.0 6 3 1 71.0 6 3 1 63.0 6 3 2 78.5 6 3 2 75.0 6 3 2 74.0 6 4 1 63.2 6 4 1 62.0 6 4 1 73.5 6 4 2 73.0 6 4 2 72.0 6 4 2 65.5 6 5 1 67.0 6 5 1 57.2 6 5 1 70.0 6 5 2 59.0 6 5 2 56.5 6 5 2 71.0 6 6 1 61.0 6 6 1 61.0 6 6 1 61.0 6 6 2 52.0 6 6 2 53.0 6 6 2 96.0 -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 -- - Original Message - From: Ivan Calandra ivan.calan...@uni-hamburg.de To: r-help@r-project.org Sent: Monday, May 10, 2010 11:26 AM Subject: Re: [R] Extracting a subset Hi, My first suggestion would be to supply a sample data (maybe using the function dput) showing what you have, what you want to do, and what you've tried (you say that subset() didn't work but we don't know how you've typed it). Then, we'll see! Ivan Le 5/10/2010 14:35, Silvano a écrit : Hi, I have a dataset with many variables and observations. The variable Group has two levels: C and P, the Month variable has four levels: 0, 1, 2 and 3. I want to extract a subset of the variable Weight, considering only 1 and 3 levels for Months of the Group variable. I tried the command subset but it did not work. Any suggestions? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Plotting residuals from a sem object
R experts - I'm using John Fox's sem package to analyze a simple path model (two correlated predictor variables directly influencing a single criterion variable): Predictor1 - Criterion Predictor2 - Criterion Predictor1 - Predictor2 I'm giving a presentation on this material next week, and I'd like to use component-residual plots (i.e., partial residual plots) to help the audience visualize the effect of one the predictor variables on the criterion, independent of the other predictor variable. In a simple multiple regression, I'd use the cr.plots function from Fox's CAR package for this, or just plot residuals from two models regressing my predictor of interest and the criterion variable separately on the other predictor variable. Is there a way to produce similar plots for a path model (or generate the appropriate residuals to just do the plot myself)? thanks, Jesse _ Jesse W. Young, Ph.D. Assistant Professor Department of Anatomy and Neurobiology Northeastern Ohio Universities College of Medicine (NEOUCOM) Office phone: (330) 325-6304 Lab phone: (330) 325-6307 Fax: (330) 325-5916 Email: jwyo...@neoucom.edu Web page: www.jessewyoung.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] Plotting log-axis with the exponential base to a plot with the default logarithm base 10
Dear Elisabeth, I'm not sure if I have understood your question -- are you trying to use a different logarithmic base? Kind regards, Xianwen On Sun, May 9, 2010 at 8:05 PM, Elisabeth Bjerke Rastad ebr...@post.uit.no wrote: Hello! I have a problem which I have tried to solve for several days now.. I have plottet a lineplot.CI in the library sciplot, and I am trying to plot it with a logaritmic y-axis (with exponential base). The problem is that; when I type log y, the axis transforms into the logaritmic of base 10. I wonder if someeone could tell me how to specify that I would like to use the exponential logaritmic y-axis. I have tried a lot (but obviously not all, I guess this problem is possible to solve..) Hope you would like to help me! Thank you a lot in advance!! Greetings, Elisabeth B. Råstad (Master's student, Norway) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Xianwen Chen, M.Sc. Scientific assistant, BFE, UiT (www.uit.no) Tel.: +47 776 46 112 | Fax: +47 776 46 020 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 estimate whether overfitting?
(Near) non-identifiability (especially in nonlinear models, which include linear mixed effects models, Bayesian hierarchical models, etc.) is typically a strong clue; usually indicated by software complaints (e.g. convergence failures, running up against iteration limits, etc.). However this is sufficient-ish, not necessary: over-fitting frequently occurs even without such overt complaints. It should also be said that, except for identifiability, over-fitting is not a well-defined statistical term: it depends on the scientific context. Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Steve Lianoglou Sent: Sunday, May 09, 2010 6:13 PM To: David Winsemius Cc: r-help@r-project.org; bbslover Subject: Re: [R] How to estimate whether overfitting? On Sun, May 9, 2010 at 11:53 AM, David Winsemius dwinsem...@comcast.net wrote: On May 9, 2010, at 9:20 AM, bbslover wrote: 1. is there some criterion to estimate overfitting? e.g. R2 and Q2 in the training set, as well as R2 in the test set, when means overfitting. for example, in my data, I have R2=0.94 for the training set and for the test set R2=0.70, is overfitting? 2. in this scatter, can one say this overfitting? 3. my result is obtained by svm, and the sample are 156 and 52 for the training and test sets, and predictors are 96, In this case, can svm be employed to perform prediction? whether the number of the predictors are too many ? I think you need to buy a copy of Hastie, Tibshirani, and Friedman and do some self-study of chapters 7 and 12. And you don't even have to buy it before you can start studying since the PDF is available here: http://www-stat.stanford.edu/~tibs/ElemStatLearn/ Having a hard cover is always handy, tho .. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] post-hoc t-tests, for lme / lmer models
no one? any pointers would really be greatly appreciated! thanks, kay - Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck -- View this message in context: http://r.789695.n4.nabble.com/post-hoc-t-tests-for-lme-lmer-models-tp2133959p2171820.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] smoothing parameter in locfit package
Loader's book is the ultimate reference (other than the source code...). I don't have it with me right now, so can't tell you for sure. However, it seems like an odd thing to do to use a different kernel at the selection step than the final estimation step. I should think if you specify the kernel, it is used regardless of how the bandwidth is chosen. Andy From: FMH Thank you Andy. I'm aware of that but my question is about the way the locfit package use to automatically determine the bandwidth/smoothing parameter if Gauss kernel density function is used as the weight function. Does the generalized cross validation criteria is imposed here or does the value of the bandwidth is fixed (by default) in the package, unless we specify our own value? Cheers, Fir - Original Message From: Liaw, Andy andy_l...@merck.com To: FMH kagba2...@yahoo.com; r-help@r-project.org Sent: Mon, May 10, 2010 4:00:51 PM Subject: RE: [R] smoothing parameter in locfit package See the kern argument in ?locfit.raw. Andy From: FMH Hi, In the locfit package, could someone please let me know the automatic selection of smoothing parameter if Gauss kernel density function is used as weight function? thanks Fir [[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. Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates Direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. Notice: This e-mail message, together with any attachme...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [Fwd: Re: Plotting log-axis with the exponential base to a plot with the default logarithm base 10]
Hello! Thank you for answering! What I am trying to do is to plot my raw values (biomass of different species) on a logaritmic y-axis with the base of e. When I type log=y, the axis transforms into a logaritmic axis with the base of 10. Best regards, Elisabeth Dear Elisabeth, I'm not sure if I have understood your question -- are you trying to use a different logarithmic base? Kind regards, Xianwen On Sun, May 9, 2010 at 8:05 PM, Elisabeth Bjerke Rastad ebr...@post.uit.no wrote: Hello! I have a problem which I have tried to solve for several days now.. I have plottet a lineplot.CI in the library sciplot, and I am trying to plot it with a logaritmic y-axis (with exponential base). The problem is that; when I type log y, the axis transforms into the logaritmic of base 10. I wonder if someeone could tell me how to specify that I would like to use the exponential logaritmic y-axis. I have tried a lot (but obviously not all, I guess this problem is possible to solve..) Hope you would like to help me! Thank you a lot in advance!! Greetings, Elisabeth B. RÃ¥stad (Master's student, Norway) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Xianwen Chen, M.Sc. Scientific assistant, BFE, UiT (www.uit.no) Tel.: +47 776 46 112 | Fax: +47 776 46 020 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 walk
Sums of correlated increments have the same correlation as the original variables... library(mvtnorm) X- matrix(0,nrow=1000,ncol=2) for(i in 1:1000){ Y - rmvnorm(1000,mean=mu,sigma=S) X[i,] - apply(Y,2,sum) } cor(Y) [,1] [,2] [1,] 1.000 0.4909281 [2,] 0.4909281 1.000 So, unless you meant that you want the _sample_ correlation to be pre-specified, you are all set. albyn On Sun, May 09, 2010 at 09:20:25PM -0400, Sergio Andrés Estay Cabrera wrote: Hi everybody, I am trying to generate two random walks with an specific correlation, for example, two random walks of 200 time steps with a correlation 0.7. I built the random walks with: x-cumsum(rnorm(200, mean=0,sd=1)) y-cumsum(rnorm(200, mean=0,sd=1)) but I don't know how to fix the correlation between them. With white noise is easy to fix the correlation using the function rmvnorm in the package mvtnorm I surfed in the web in the searchable mail archives in the R web site but no references appears. If you have some advices to solve this problems I would be very thankful. Thanks in advance. Sergio A. Estay *CASEB * Departamento de Ecología Universidad Catolica de Chile -- “La disciplina no tiene ningún mérito en circunstancias ideales. ” – Habor Mallow __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2 and geom_pointrange
Hello: I am using the ggplot2 package on R 2.10.1. I am plotting points using geom_pointrange. Is there a way to overlay hashmarks on the points, specifically the median and the min and max of the range? Cheers, Michael [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] smoothing parameter in locfit package
Thank you Andy. I'm aware of that but my question is about the way the locfit package use to automatically determine the bandwidth/smoothing parameter if Gauss kernel density function is used as the weight function. Does the generalized cross validation criteria is imposed here or does the value of the bandwidth is fixed (by default) in the package, unless we specify our own value? Cheers, Fir - Original Message From: Liaw, Andy andy_l...@merck.com To: FMH kagba2...@yahoo.com; r-help@r-project.org Sent: Mon, May 10, 2010 4:00:51 PM Subject: RE: [R] smoothing parameter in locfit package See the kern argument in ?locfit.raw. Andy From: FMH Hi, In the locfit package, could someone please let me know the automatic selection of smoothing parameter if Gauss kernel density function is used as weight function? thanks Fir [[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. Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates Direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Supercripting text
Dear R users, I recently developed a plotting function in R and introduced it to my coworkers. The function is designed to make plotting easier and more efficient, which will in turn be more cost-effective for the company. The reviews for the function have been positive thus far, except for one issue -- addition of superscripts to the title. We need superscipts in the titles sometimes to highlight footnotes which appear at the bottom of the plots. The syntax for supersciprts, however, is rather cumbersome, especially in titles since it needs to be bolded. So far the only way of superscripting is to use the expression() function. But to go about formatting the text such that it appears bolded as a title in my plots, I would have to type in the command text(expression(bold(paste(text for title,^1)))) In some cases, the plot would require 3 footnotes to be shown, and the code would be text(expression(bold(paste(text for title,^1, ^2, ^3))).) Most of my coworkers are still in the process of picking up R, some have never used R before. The above commands may be a little too much for them to handle. Is there an easier way of superscripting texts in R? It would be great if any of you know of alternative ways other than using the expression() function. I greatly appreciate your help. Thank you. Sincerely, Shang [[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] System neutral Daylight Savings Time response?
I'm searching for an r command that will notify me if I create a time that does not exist due to Daylight Savings Time. For example, if I run the following command on a windows machine ISOdatetime(2010,03,14,2,10,0, tz = ) # My system time is set to the United States Central Time Zone [1] NA R returns NA, which is the behavior I want. However, if I run the same command on a mac, R returns a POSIXct object and I have to examine the object manually to notice that I had tried to create an impossible time. ISOdatetime(2010,03,14,2,10,0, tz = ) [1] 2010-03-14 01:10:00 CST Is there a method of creating time objects in R that will always return NA for non-existant times, no matter the operating system? Thank you sincerely, Garrett [[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] Plotting log-axis with the exponential base to a plot with the default logarithm base 10
Dear Elisabeth, log(X) shall return logarithm of X, with the base of e. If you are not sure, you can specify e to be the base, e.g.: log(X,exp(1)) . Snow in Tromsø is melting, so will your problem. King regards, Xianwen On Mon, May 10, 2010 at 6:11 PM, Elisabeth Bjerke Rastad ebr...@post.uit.no wrote: Hello! Thank you for answering! What I am trying to do is to plot my raw values (biomass of different species) on a logaritmic y-axis with the base of e. When I type log=y, the axis transforms into a logaritmic axis with the base of 10. Best regards, Elisabeth Dear Elisabeth, I'm not sure if I have understood your question -- are you trying to use a different logarithmic base? Kind regards, Xianwen On Sun, May 9, 2010 at 8:05 PM, Elisabeth Bjerke Rastad ebr...@post.uit.no wrote: Hello! I have a problem which I have tried to solve for several days now.. I have plottet a lineplot.CI in the library sciplot, and I am trying to plot it with a logaritmic y-axis (with exponential base). The problem is that; when I type log y, the axis transforms into the logaritmic of base 10. I wonder if someeone could tell me how to specify that I would like to use the exponential logaritmic y-axis. I have tried a lot (but obviously not all, I guess this problem is possible to solve..) Hope you would like to help me! Thank you a lot in advance!! Greetings, Elisabeth B. Råstad (Master's student, Norway) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Xianwen Chen, M.Sc. Scientific assistant, BFE, UiT (www.uit.no) Tel.: +47 776 46 112 | Fax: +47 776 46 020 -- Xianwen Chen, M.Sc. Scientific assistant, BFE, UiT (www.uit.no) Tel.: +47 776 46 112 | Fax: +47 776 46 020 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 walk
Dear R users and specially Albyn and Giovanni, thanks for your answers, but in fact I supposed the same at the beginning of my problem. However, when I generate the data seldom I obtain the expected correlation. For example using this code: fz-function(n,t,rho){ f-NULL for(i in 1:n){ s-rmvnorm(n=t,mean=c(0,0),sigma=matrix(c(1,rho,rho,1),ncol=2),method='svd') paso-cor(cumsum(s[,1]),cumsum(s[,2])) f-c(f,paso)} f-f } and then plot the histogram of the results, it is possible to observe that the distribution of the values is asymmetric with most of the simulations close to 1 when the value of rho is higher than 0.3 and looks like a uniform distribution with values below 0.3. I suspect than the only possibility is using a brute force algorithm. Any advice would be helpful Sergio A. Estay *CASEB * Departamento de Ecología Universidad Catolica de Chile Albyn Jones wrote: Sums of correlated increments have the same correlation as the original variables... library(mvtnorm) X- matrix(0,nrow=1000,ncol=2) for(i in 1:1000){ Y - rmvnorm(1000,mean=mu,sigma=S) X[i,] - apply(Y,2,sum) } cor(Y) [,1] [,2] [1,] 1.000 0.4909281 [2,] 0.4909281 1.000 So, unless you meant that you want the _sample_ correlation to be pre-specified, you are all set. albyn On Sun, May 09, 2010 at 09:20:25PM -0400, Sergio Andrés Estay Cabrera wrote: Hi everybody, I am trying to generate two random walks with an specific correlation, for example, two random walks of 200 time steps with a correlation 0.7. I built the random walks with: x-cumsum(rnorm(200, mean=0,sd=1)) y-cumsum(rnorm(200, mean=0,sd=1)) but I don't know how to fix the correlation between them. With white noise is easy to fix the correlation using the function rmvnorm in the package mvtnorm I surfed in the web in the searchable mail archives in the R web site but no references appears. If you have some advices to solve this problems I would be very thankful. Thanks in advance. Sergio A. Estay *CASEB * Departamento de Ecología Universidad Catolica de Chile -- “La disciplina no tiene ningún mérito en circunstancias ideales. ” – Habor Mallow __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- “La disciplina no tiene ningún mérito en circunstancias ideales. ” – Habor Mallow __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 walk
On May 10, 2010, at 2:55 PM, Sergio Andrés Estay Cabrera wrote: Dear R users and specially Albyn and Giovanni, thanks for your answers, but in fact I supposed the same at the beginning of my problem. However, when I generate the data seldom I obtain the expected correlation. For example using this code: fz-function(n,t,rho){ f-NULL for(i in 1:n){ s-rmvnorm(n=t,mean=c(0,0),sigma=matrix(c(1,rho,rho, 1),ncol=2),method='svd') paso-cor(cumsum(s[,1]),cumsum(s[,2])) f-c(f,paso)} f-f } I believe you may want to search on the term quantos model. If you have two independent Brownian processes W_1(t) and W_2(t) then W_3 = rho*W_1(t) +sqrt(1-rho^2)*W_2(t) will theoretically have correlation rho with W_1. Sampling will of course giving varying instantiation values. -- David citation: Financial Calculus, Baxter M; Rennie A (1996) and then plot the histogram of the results, it is possible to observe that the distribution of the values is asymmetric with most of the simulations close to 1 when the value of rho is higher than 0.3 and looks like a uniform distribution with values below 0.3. I suspect than the only possibility is using a brute force algorithm. Any advice would be helpful Sergio A. Estay *CASEB * Departamento de Ecología Universidad Catolica de Chile Albyn Jones wrote: Sums of correlated increments have the same correlation as the original variables... library(mvtnorm) X- matrix(0,nrow=1000,ncol=2) for(i in 1:1000){ Y - rmvnorm(1000,mean=mu,sigma=S) X[i,] - apply(Y,2,sum) } cor(Y) [,1] [,2] [1,] 1.000 0.4909281 [2,] 0.4909281 1.000 So, unless you meant that you want the _sample_ correlation to be pre-specified, you are all set. albyn On Sun, May 09, 2010 at 09:20:25PM -0400, Sergio Andrés Estay Cabrera wrote: Hi everybody, I am trying to generate two random walks with an specific correlation, for example, two random walks of 200 time steps with a correlation 0.7. I built the random walks with: x-cumsum(rnorm(200, mean=0,sd=1)) y-cumsum(rnorm(200, mean=0,sd=1)) but I don't know how to fix the correlation between them. With white noise is easy to fix the correlation using the function rmvnorm in the package mvtnorm I surfed in the web in the searchable mail archives in the R web site but no references appears. If you have some advices to solve this problems I would be very thankful. Thanks in advance. Sergio A. Estay *CASEB * Departamento de Ecología Universidad Catolica de Chile -- “La disciplina no tiene ningún mérito en circunstancias ideales. ” – Habor Mallow __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- “La disciplina no tiene ningún mérito en circunstancias ideales. ” – Habor Mallow __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dimensions on svychisq on svydesign
I think your problem is that HL07 is not a data frame but a list. read.spss() produces a list rather than a data frame by default, and svydesign() requires a data frame. You can use as.data.frame() to turn HL07 into a data.frame. The weights also look a bit strange -- you have sampling probabilities ranging from 0.27 to 3 -- this isn't necessarily wrong but is unusual. -thomas On Sun, 9 May 2010, Stefán Jónsson wrote: Dear Forum I a running svychisq from the survey package and get errors with the number of dimensions, errors that I do not understand and do not know how to fix. I ask you kindly to help me out. The eror message follows with some information below. I hope there are enough information to help me to fix the problem if not please let me know what is needed Best Stefan Hrafn Jonsson QHISQ2 - svychisq(~S73 + S36 , design = HL7design , statistic = Chisq) Error in design$variables[, as.character(rows)] : incorrect number of dimensions HL07 - read.spss(C:/Users/Stefan/Desktop/export1.por, use.value.labels = FALSE) HL7design -svydesign(id=~ID2,strata=~STRATA, weights=~VIGT2, data=HL07 ) summary(HL7design) summary(HL7design) Stratified Independent Sampling design (with replacement) svydesign(id = ~ID2, strata = ~STRATA, weights = ~VIGT2, data = HL07) Probabilities: Min. 1st Qu. MedianMean 3rd Qu.Max. 0.3779 0.6933 1.2880 1.3270 1.6970 3.0980 Stratum Sizes: 1 2 3 4 5 6 11 12 13 14 15 16 obs414 403 447 479 501 464 364 453 514 540 534 521 design.PSU 414 403 447 479 501 464 364 453 514 540 534 521 actual.PSU 414 403 447 479 501 464 364 453 514 540 534 521 Data variables: NULL xtabs(~HL07$S73 + HL07$S36 ) HL07$S36 HL07$S73 1 2 3 4 5 6 7 8 9 1 199 248 517 707 736 156 57 10 2 2 458 294 636 992 543 55 18 3 3 QHISQ2 - svychisq(~HL07$S73 + HL07$S36 , design = HL7design , statistic = Chisq) Error in design$variables[, as.character(rows)] : incorrect number of dimensions QHISQ2 - svychisq(~S73 + S36 , design = HL7design , statistic = Chisq) Error in design$variables[, as.character(rows)] : incorrect number of dimensions [[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. Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] graphics::plot Organizing line types, line colors and generating matching legends...
Lets say I have a generated data frame with variables that follow a naming convention: title,a1,a2,b1,b2,b3,c1,c2,c3,c4... I am plotting every column (starting from a1) as a line in a plot. That works. However my diagram becomes very unorganized. Creating legends is nice, but trying out different combinations requires me to adjust my legend since it is generally disconnected from the data. Is there an elegant way where R generates legends for its variables so that the legend will fit the line and uses the column name as in the legend? I guess I am asking for the basic Excel thing. I understand that in the standard graphics package, this is not really intended. Perhaps somebody can point me into a direction where this more easily possible? Is it for example easier in gplot or lattice? Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] graphics::plot Organizing line types, line colors and generating matching legends...
Hi, Lattice and ggplot2 are both ideally suited for this task. Consider this example, library(ggplot2) d = data.frame(x=1:10, a1=rnorm(10), b1=rnorm(10)) m = melt(d, id =x) # reshape into long format qplot(x, value, data=m, geom=path, colour=variable) library(lattice) xyplot(value~x, data=m, type=l, group=variable, auto.key=TRUE) HTH, baptiste On 10 May 2010 21:29, Ralf B ralf.bie...@gmail.com wrote: Lets say I have a generated data frame with variables that follow a naming convention: title,a1,a2,b1,b2,b3,c1,c2,c3,c4... I am plotting every column (starting from a1) as a line in a plot. That works. However my diagram becomes very unorganized. Creating legends is nice, but trying out different combinations requires me to adjust my legend since it is generally disconnected from the data. Is there an elegant way where R generates legends for its variables so that the legend will fit the line and uses the column name as in the legend? I guess I am asking for the basic Excel thing. I understand that in the standard graphics package, this is not really intended. Perhaps somebody can point me into a direction where this more easily possible? Is it for example easier in gplot or lattice? Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bug in DEMA (Moving Average smoothing algoritm) ?
When running DEMA(data, 5) on a vector 'data' of length 5, my R engine stops. Is this function or the R environment facing a bug here or am I doing something wrong? DEMA should work if the smoothing window size is the same size as the the data length, right? (I am working with Eclipse 3.5. and the StatET environment.) Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Supercripting text
Sigh; that's because I forget to include it in the 'substitute' list. Here is a version that works (and has been tested...). ourtitle - function(title, footnotes=NULL) { if (length(footnotes) 0) { fn - paste(footnotes, collapse=' ') title - eval(substitute(expression(bold(paste(title, ^fn))), list(title=title, fn=fn))) } title } Shang Gao wrote: I tried writing that function before, but the expression() command is not preserved when we incorporate it into a function(). The first example you gave me, if run in R, produced a title that reads title instead of stuff. It seems that in this case the expression() can't read the character string in the argument specified in the function() command. -Original Message- From: Kevin Coombes [mailto:kevin.r.coom...@gmail.com] Sent: Monday, May 10, 2010 12:08 PM To: Shang Gao Cc: r-help@r-project.org Subject: Re: [R] Supercripting text You probably want to write your own titling function to add superscripts. The following code will serve as a reasonable starting point: # make the title expression ourtitle - function(title, footnotes=NULL) { if (length(footnotes) 0) { fn - paste(footnotes, collapse=' ') title - eval(substitute(expression(bold(paste(title, ^fn))), list(fn=fn))) } title } # example with footnotes tt - ourtitle(stuff, 1:3) plot(1, 1) title(tt) # example without footnotes plot(1, 1) title(ourtitle(stuff)) Note that the only way I could make this work was to combine the footnote list before calling the eval-substitute-expression code; I cannot get it to work by applying things ot a list. Kevin Shang Gao wrote: Dear R users, I recently developed a plotting function in R and introduced it to my coworkers. The function is designed to make plotting easier and more efficient, which will in turn be more cost-effective for the company. The reviews for the function have been positive thus far, except for one issue -- addition of superscripts to the title. We need superscipts in the titles sometimes to highlight footnotes which appear at the bottom of the plots. The syntax for supersciprts, however, is rather cumbersome, especially in titles since it needs to be bolded. So far the only way of superscripting is to use the expression() function. But to go about formatting the text such that it appears bolded as a title in my plots, I would have to type in the command text(expression(bold(paste(text for title,^1)))) In some cases, the plot would require 3 footnotes to be shown, and the code would be text(expression(bold(paste(text for title,^1, ^2, ^3))).) Most of my coworkers are still in the process of picking up R, some have never used R before. The above commands may be a little too much for them to handle. Is there an easier way of superscripting texts in R? It would be great if any of you know of alternative ways other than using the expression() function. I greatly appreciate your help. Thank you. Sincerely, Shang [[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] Using R with screenreading software
Hi, I use R with a screen reader to do statistical and financial analysis. There are a couple of things that your student can do. R was created on Linux, and then ported to Windows. So she can use R under Linux where the CLI is perfectly accessible. There are 2 main screen readers for Linux: Speakup for the text console and Orca for the Gnome Desktop. Also, ESS, an extension to Emacs can be used as well. On Windows, the accessibility of R console can vary from screen reader to screen reader. I mainly work on the R terminal found in C:\Program Files\R\R-2.10.0\bin. You could create a desktop shortcut for the Rterm.exe file. If she is not comfortable typing directly on the R console, then a text editor can be used for the R code. Any text editor can do, though I use Tinn-R, which is fairly accessible. Tinn-R can be found here. http://www.sciviews.org/Tinn-R/ The code can either be pasted in R or can be run directly by using the source function. source(C:/Test.r) See ?source R output can be sent to a text file using sink() # Open the connection sink(sink-Test.txt) # Enter something x - c(1, 2, 3, 4, 5) mean(x) # End the connection sink() More helpful would be ?sink and ?capture.output Depending on what she has to do, R can also be used through Excel which is again accessible. Regards Roopakshi from India -- Message: 29 Date: Tue, 4 May 2010 15:41:41 +0200 From: Rainer Scheuchenpflug scheuchenpf...@psychologie.uni-wuerzburg.de To: r-help@r-project.org Subject: [R] Using R with screenreading software Message-ID: 002e01caeb8f$8736b2c0$95a418...@uni-wuerzburg.de Content-Type: text/plain; charset=iso-8859-1 Dear R-Experts, a student of mine tries to use the Windows-Rconsole with screen reading software (she is blind), and cannot access the command line (Menus are ok). The company which produces her screen reader tells her that this is due to the cursor used in Rconsole, which is static, not blinking. They maintain that if the cursor could be changed to a blinking one, she should be able to access the command line and outputs. For my last exam she used R in a Dosbox as workaround, but encountered other problems, esp. with scrolling. So: Is it possible to change the cursor type/behavior in R-Console? She uses R 2.8.1, Windows 2000, and screenreader Virgo 4.6 from Baum Retec, if that is any help. Your assistance with this problem and any other tips for teaching R to blind users will be much appreciated, Rainer Scheuchenpflug Dr. Rainer Scheuchenpflug Lehrstuhl f?r Psychologie III R?ntgenring 11 97070 W?rzburg Tel: 0931-31-82185 Fax: 0931-31-82616 Mail: scheuchenpf...@psychologie.uni-wuerzburg.de Web: http://www.izvw.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dot plot with error bands
Many thanks for this suggestion. Indeed, labels turned out to be a factor, and after reordering the levels I got the plot I wanted. Alexey David Winsemius wrote: On May 10, 2010, at 10:00 AM, Alexey Bessudnov wrote: Dear all, I'm trying to create a dot plot with error bands with Dotplot(labels ~ Cbind(estimate, lower, upper), data=For.plot) where estimate, lower and upper are numerical vectors, and labels is a character vector that contains labels. The problem is that labels are automatically sorted alphabetically, and I want them to be sorted by estimate (as in my data frame). This should be straightforward, but unfortunately being new to R I can't figure out how to do this. I'll appreciate your guidance. Have you tried making labels (an unfortunate choice for a variable name, BTW) a factor variable with levels in the order of your desire? (Also being new to R, you may not recognize the difference between a factor variable and a character vector, so producing a more explicit description of the dataframe For.plot with the str function ought to be your next contribution to this thread if the above solution is not effective. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Polylogarithm
I am writing to ask if R has a build- in function to calculate this polylogarithm Li_n(z) function , also known as the Jonquière's function defined as Li_n(z)=sum_(k=1)^infty(z^k)/(k^n) Thanks Andy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Dataframe horizontal scrolling
R experts, I am working with large multivariable data frames ( 50 variables) and I would like to scroll horizontally across my output to view each data frame rather than having to scroll down vertically- wrapped data frames.I have been using R Commander as a programming interface. If I assign a long character string to a vector I can scroll across its output easily but not a dataframe of equivalent width. I just want my data frame variables to fully output horizontally rather than partially with vertical wrapping, if that is possible. Any help would be appreciated. Thank you, Mike _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Supercripting text
I tried writing that function before, but the expression() command is not preserved when we incorporate it into a function(). The first example you gave me, if run in R, produced a title that reads title instead of stuff. It seems that in this case the expression() can't read the character string in the argument specified in the function() command. -Original Message- From: Kevin Coombes [mailto:kevin.r.coom...@gmail.com] Sent: Monday, May 10, 2010 12:08 PM To: Shang Gao Cc: r-help@r-project.org Subject: Re: [R] Supercripting text You probably want to write your own titling function to add superscripts. The following code will serve as a reasonable starting point: # make the title expression ourtitle - function(title, footnotes=NULL) { if (length(footnotes) 0) { fn - paste(footnotes, collapse=' ') title - eval(substitute(expression(bold(paste(title, ^fn))), list(fn=fn))) } title } # example with footnotes tt - ourtitle(stuff, 1:3) plot(1, 1) title(tt) # example without footnotes plot(1, 1) title(ourtitle(stuff)) Note that the only way I could make this work was to combine the footnote list before calling the eval-substitute-expression code; I cannot get it to work by applying things ot a list. Kevin Shang Gao wrote: Dear R users, I recently developed a plotting function in R and introduced it to my coworkers. The function is designed to make plotting easier and more efficient, which will in turn be more cost-effective for the company. The reviews for the function have been positive thus far, except for one issue -- addition of superscripts to the title. We need superscipts in the titles sometimes to highlight footnotes which appear at the bottom of the plots. The syntax for supersciprts, however, is rather cumbersome, especially in titles since it needs to be bolded. So far the only way of superscripting is to use the expression() function. But to go about formatting the text such that it appears bolded as a title in my plots, I would have to type in the command text(expression(bold(paste(text for title,^1)))) In some cases, the plot would require 3 footnotes to be shown, and the code would be text(expression(bold(paste(text for title,^1, ^2, ^3))).) Most of my coworkers are still in the process of picking up R, some have never used R before. The above commands may be a little too much for them to handle. Is there an easier way of superscripting texts in R? It would be great if any of you know of alternative ways other than using the expression() function. I greatly appreciate your help. Thank you. Sincerely, Shang [[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] step function
Hi All I need some help with plotting a step function, currently I'm using sfun - stepfun(c(1, 2, 5,10, 20), c(0, 11, 22, 33, 44, 0), f=0) plot(sfun, pch=NA, main=, xlim=c(1,20)) which I working fine, but my data is in the following format: Min Max Value 1 2 11 2 5 22 510 33 10 20 44 1. To save time, is there a way to directly plot the above data as it is (without any reformatting). 2. Also, I need with starting the x-axis value from 1, xlim is not completely helping me with this. Any help would be highly appreciated. Thank you, Kim [[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] Dataframe horizontal scrolling
Hi Mike, You can set options(width = x), where x equals the number of columns. -Ista On Monday 10 May 2010 16:06:54 Michael H wrote: R experts, I am working with large multivariable data frames ( 50 variables) and I would like to scroll horizontally across my output to view each data frame rather than having to scroll down vertically- wrapped data frames.I have been using R Commander as a programming interface. If I assign a long character string to a vector I can scroll across its output easily but not a dataframe of equivalent width. I just want my data frame variables to fully output horizontally rather than partially with vertical wrapping, if that is possible. Any help would be appreciated. Thank you, Mike _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Corrupt R installation?
I installed the lattice package, and got an error that R was not able to remove the previous version of lattice. Now my installation seems to be currupt, even affecting other packages. I am getting this error when loading TTR: library(TTR) Loading required package: xts Loading required package: zoo Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'lattice' In addition: Warning messages: 1: package 'TTR' was built under R version 2.10.1 2: package 'xts' was built under R version 2.10.1 3: package 'zoo' was built under R version 2.10.1 Error: package 'zoo' could not be loaded My question now is, is there a way to manually remove lattice (or whats left from it) ? Or do I have to go through the process of completely re-installing? What do you guys do to prevent such a situation - is there an easy way to secure a R installation? Ralf __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 algorithm/package for creating spatial autocorrelation of uniformly distributed landscape values
Dear all: I would like to create a landscape of environmental values that follow a uniform frequency distribution and also have spatial autocorrelation in the landscape. I was wondering if there is an algorithm and/or package out there that creates autocorrelation of values that are distributed according to a non-normal frequency distribution. Any suggestions are greatly appreciated. Thank you, Laura -- Genius is the summed production of the many with the names of the few attached for easy recall, unfairly so to other scientists - E. O. Wilson (The Diversity of Life) [[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] Dataframe horizontal scrolling
Perhaps even ?View would be useful here. I've never used R Commander, so don't know it would be useful in that environment. Michael H wrote: R experts, I am working with large multivariable data frames ( 50 variables) and I would like to scroll horizontally across my output to view each data frame rather than having to scroll down vertically- wrapped data frames.I have been using R Commander as a programming interface. If I assign a long character string to a vector I can scroll across its output easily but not a dataframe of equivalent width. I just want my data frame variables to fully output horizontally rather than partially with vertical wrapping, if that is possible. Any help would be appreciated. Thank you, Mike _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cumsum output
Hi: Thanks to Dennis and Fernando for your help reordering the levels. Now I have a different issue: I am trying to get the cumulative weekly values using cumsum and it appears to output the wrong values. Here's my dataset: winter - structure(list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L), BY2009 = c(0L, 95L, 436L, 809L, 3668L, 9437L, 42700L, 141135L, 486474L, 1109095L, 1459053L, 1990285L, 2643088L, 2988446L, 3131437L, 3280320L, 4237821L, 4270316L, 4285178L, 4292388L, 4302153L, 4308999L, 4314066L, 4320267L, 4323312L, 4429542L, 4430725L, 4430920L, 4437775L, 4448036L, 4452215L, 4452865L, 4453105L, 4453270L, 4454459L, 4455322L, 4455884L, 4457234L, 4457422L, 4457901L, 4458671L, 4458671L, 4459229L, 4459543L, 4459690L, NA, NA, NA, NA, NA, NA, NA), BY2008 = c(0L, 0L, 77L, 201L, 360L, 2736L, 12216L, 29530L, 129104L, 452783L, 650994L, 744624L, 873807L, 985627L, 1056887L, 1092128L, 1106148L, 1126926L, 1148620L, 1163636L, 1177036L, 1186223L, 1189830L, 1192634L, 1195051L, 1200342L, 1216558L, 1217456L, 1218014L, 1218723L, 1219695L, 1219756L, 1220128L, 1223214L, 1233322L, 1237617L, 1238499L, 1241092L, 1241128L, 1241361L, 1241604L, 1241604L, 1241674L, 1241946L, 1242254L, 1242388L, 1242428L, 1242428L, 1242428L, 1242428L, 1242428L, 1242428L), BY2007 = c(0L, 0L, 0L, 10775L, 14941L, 19899L, 36120L, 65521L, 100472L, 133660L, 279704L, 384711L, 570008L, 729690L, 937227L, 1077921L, 1206196L, 1250470L, 1277549L, 1296477L, 1306914L, 1336898L, 1355293L, 1381139L, 1385712L, 1417707L, 1421386L, 1422429L, 1432065L, 1433589L, 1434416L, 1441425L, 1441658L, 1442091L, 1442091L, 1443194L, 1443451L, 1443579L, 1443645L, 1443715L, 1444250L, 1444679L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L), BY2006 = c(0L, 707L, 3097L, 11957L, 36387L, 77272L, 150064L, 355585L, 700078L, 1363051L, 1889460L, 2521413L, 3371904L, 4214582L, 4660569L, 5218721L, 5550753L, 5725079L, 5805680L, 5854376L, 5952947L, 6056510L, 6205979L, 6284060L, 6466538L, 6468696L, 6485262L, 6489289L, 6491944L, 6493056L, 6493623L, 6496218L, 6501194L, 6507530L, 6507824L, 6509582L, 6509873L, 6510076L, 6510526L, 6511624L, 6512412L, 6512607L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513306L, 6513306L, 6513306L ), BY2005 = c(0L, 0L, 868L, 2912L, 6976L, 13025L, 22424L, 35728L, 80900L, 323055L, 799919L, 1512453L, 2570862L, 4685880L, 6196222L, 7334435L, 7667627L, 7826447L, 7920826L, 8269708L, 8308998L, 8338699L, 8385957L, 8455794L, 8463678L, 8513016L, 8535184L, 8554581L, 8573978L, 8589962L, 8598650L, 8599850L, 8601473L, 8602764L, 8604120L, 8604827L, 8605702L, 8606577L, 8606799L, 8607682L, 8607682L, 8607682L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L)), .Names = c(week, BY2009, BY2008, BY2007, BY2006, BY2005), class = data.frame, row.names = c(NA, -52L)) apply(winter[,2:6],2,cumsum) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, 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] Corrupt R installation?
On May 10, 2010, at 4:46 PM, Ralf B wrote: I installed the lattice package, and got an error that R was not able to remove the previous version of lattice. Now my installation seems to be currupt, even affecting other packages. I am getting this error when loading TTR: library(TTR) Loading required package: xts Loading required package: zoo Error in loadNamespace(i, c(lib.loc, .libPaths())) : there is no package called 'lattice' In addition: Warning messages: 1: package 'TTR' was built under R version 2.10.1 2: package 'xts' was built under R version 2.10.1 3: package 'zoo' was built under R version 2.10.1 Error: package 'zoo' could not be loaded My question now is, is there a way to manually remove lattice (or whats left from it) ? Or do I have to go through the process of completely re-installing? What do you guys do to prevent such a situation - is there an easy way to secure a R installation? You could try simply deleting the .Rdta file that is perhaps invisible to your file manager software. on whatever OS you are using. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cumsum output
It is working correctly, You have NAs in your data, so you get NAs in the cumsum. On Mon, May 10, 2010 at 5:09 PM, Felipe Carrillo mazatlanmex...@yahoo.comwrote: Hi: Thanks to Dennis and Fernando for your help reordering the levels. Now I have a different issue: I am trying to get the cumulative weekly values using cumsum and it appears to output the wrong values. Here's my dataset: winter - structure(list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L), BY2009 = c(0L, 95L, 436L, 809L, 3668L, 9437L, 42700L, 141135L, 486474L, 1109095L, 1459053L, 1990285L, 2643088L, 2988446L, 3131437L, 3280320L, 4237821L, 4270316L, 4285178L, 4292388L, 4302153L, 4308999L, 4314066L, 4320267L, 4323312L, 4429542L, 4430725L, 4430920L, 4437775L, 4448036L, 4452215L, 4452865L, 4453105L, 4453270L, 4454459L, 4455322L, 4455884L, 4457234L, 4457422L, 4457901L, 4458671L, 4458671L, 4459229L, 4459543L, 4459690L, NA, NA, NA, NA, NA, NA, NA), BY2008 = c(0L, 0L, 77L, 201L, 360L, 2736L, 12216L, 29530L, 129104L, 452783L, 650994L, 744624L, 873807L, 985627L, 1056887L, 1092128L, 1106148L, 1126926L, 1148620L, 1163636L, 1177036L, 1186223L, 1189830L, 1192634L, 1195051L, 1200342L, 1216558L, 1217456L, 1218014L, 1218723L, 1219695L, 1219756L, 1220128L, 1223214L, 1233322L, 1237617L, 1238499L, 1241092L, 1241128L, 1241361L, 1241604L, 1241604L, 1241674L, 1241946L, 1242254L, 1242388L, 1242428L, 1242428L, 1242428L, 1242428L, 1242428L, 1242428L), BY2007 = c(0L, 0L, 0L, 10775L, 14941L, 19899L, 36120L, 65521L, 100472L, 133660L, 279704L, 384711L, 570008L, 729690L, 937227L, 1077921L, 1206196L, 1250470L, 1277549L, 1296477L, 1306914L, 1336898L, 1355293L, 1381139L, 1385712L, 1417707L, 1421386L, 1422429L, 1432065L, 1433589L, 1434416L, 1441425L, 1441658L, 1442091L, 1442091L, 1443194L, 1443451L, 1443579L, 1443645L, 1443715L, 1444250L, 1444679L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L), BY2006 = c(0L, 707L, 3097L, 11957L, 36387L, 77272L, 150064L, 355585L, 700078L, 1363051L, 1889460L, 2521413L, 3371904L, 4214582L, 4660569L, 5218721L, 5550753L, 5725079L, 5805680L, 5854376L, 5952947L, 6056510L, 6205979L, 6284060L, 6466538L, 6468696L, 6485262L, 6489289L, 6491944L, 6493056L, 6493623L, 6496218L, 6501194L, 6507530L, 6507824L, 6509582L, 6509873L, 6510076L, 6510526L, 6511624L, 6512412L, 6512607L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513306L, 6513306L, 6513306L ), BY2005 = c(0L, 0L, 868L, 2912L, 6976L, 13025L, 22424L, 35728L, 80900L, 323055L, 799919L, 1512453L, 2570862L, 4685880L, 6196222L, 7334435L, 7667627L, 7826447L, 7920826L, 8269708L, 8308998L, 8338699L, 8385957L, 8455794L, 8463678L, 8513016L, 8535184L, 8554581L, 8573978L, 8589962L, 8598650L, 8599850L, 8601473L, 8602764L, 8604120L, 8604827L, 8605702L, 8606577L, 8606799L, 8607682L, 8607682L, 8607682L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L)), .Names = c(week, BY2009, BY2008, BY2007, BY2006, BY2005), class = data.frame, row.names = c(NA, -52L)) apply(winter[,2:6],2,cumsum) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] cumsum output
I realized that after I hit the send button...I was looking at the wrong dataset,Brr Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA From: jim holtman jholt...@gmail.com To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-h...@stat.math.ethz.ch Sent: Mon, May 10, 2010 2:33:03 PM Subject: Re: [R] cumsum output It is working correctly, You have NAs in your data, so you get NAs in the cumsum. On Mon, May 10, 2010 at 5:09 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Hi: Thanks to Dennis and Fernando for your help reordering the levels. Now I have a different issue: I am trying to get the cumulative weekly values using cumsum and it appears to output the wrong values. Here's my dataset: winter - structure(list(week = c(26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L), BY2009 = c(0L, 95L, 436L, 809L, 3668L, 9437L, 42700L, 141135L, 486474L, 1109095L, 1459053L, 1990285L, 2643088L, 2988446L, 3131437L, 3280320L, 4237821L, 4270316L, 4285178L, 4292388L, 4302153L, 4308999L, 4314066L, 4320267L, 4323312L, 4429542L, 4430725L, 4430920L, 4437775L, 4448036L, 4452215L, 4452865L, 4453105L, 4453270L, 4454459L, 4455322L, 4455884L, 4457234L, 4457422L, 4457901L, 4458671L, 4458671L, 4459229L, 4459543L, 4459690L, NA, NA, NA, NA, NA, NA, NA), BY2008 = c(0L, 0L, 77L, 201L, 360L, 2736L, 12216L, 29530L, 129104L, 452783L, 650994L, 744624L, 873807L, 985627L, 1056887L, 1092128L, 1106148L, 1126926L, 1148620L, 1163636L, 1177036L, 1186223L, 1189830L, 1192634L, 1195051L, 1200342L, 1216558L, 1217456L, 1218014L, 1218723L, 1219695L, 1219756L, 1220128L, 1223214L, 1233322L, 1237617L, 1238499L, 1241092L, 1241128L, 1241361L, 1241604L, 1241604L, 1241674L, 1241946L, 1242254L, 1242388L, 1242428L, 1242428L, 1242428L, 1242428L, 1242428L, 1242428L), BY2007 = c(0L, 0L, 0L, 10775L, 14941L, 19899L, 36120L, 65521L, 100472L, 133660L, 279704L, 384711L, 570008L, 729690L, 937227L, 1077921L, 1206196L, 1250470L, 1277549L, 1296477L, 1306914L, 1336898L, 1355293L, 1381139L, 1385712L, 1417707L, 1421386L, 1422429L, 1432065L, 1433589L, 1434416L, 1441425L, 1441658L, 1442091L, 1442091L, 1443194L, 1443451L, 1443579L, 1443645L, 1443715L, 1444250L, 1444679L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L, 1444776L), BY2006 = c(0L, 707L, 3097L, 11957L, 36387L, 77272L, 150064L, 355585L, 700078L, 1363051L, 1889460L, 2521413L, 3371904L, 4214582L, 4660569L, 5218721L, 5550753L, 5725079L, 5805680L, 5854376L, 5952947L, 6056510L, 6205979L, 6284060L, 6466538L, 6468696L, 6485262L, 6489289L, 6491944L, 6493056L, 6493623L, 6496218L, 6501194L, 6507530L, 6507824L, 6509582L, 6509873L, 6510076L, 6510526L, 6511624L, 6512412L, 6512607L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513139L, 6513306L, 6513306L, 6513306L ), BY2005 = c(0L, 0L, 868L, 2912L, 6976L, 13025L, 22424L, 35728L, 80900L, 323055L, 799919L, 1512453L, 2570862L, 4685880L, 6196222L, 7334435L, 7667627L, 7826447L, 7920826L, 8269708L, 8308998L, 8338699L, 8385957L, 8455794L, 8463678L, 8513016L, 8535184L, 8554581L, 8573978L, 8589962L, 8598650L, 8599850L, 8601473L, 8602764L, 8604120L, 8604827L, 8605702L, 8606577L, 8606799L, 8607682L, 8607682L, 8607682L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L, 8607811L)), .Names = c(week, BY2009, BY2008, BY2007, BY2006, BY2005), class = data.frame, row.names = c(NA, -52L)) apply(winter[,2:6],2,cumsum) Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] [Fwd: Re: Plotting log-axis with the exponential base to
Elisabeth, question to you: How is it that you recognise that it is a logaritmic axis with the base of 10, as opposed to any other base? Ted. On 10-May-10 17:15:04, Elisabeth Bjerke Rastad wrote: Hello! Thank you for answering! What I am trying to do is to plot my raw values (biomass of different species) on a logaritmic y-axis with the base of e. When I type log=y, the axis transforms into a logaritmic axis with the base of 10. Best regards, Elisabeth Dear Elisabeth, I'm not sure if I have understood your question -- are you trying to use a different logarithmic base? Kind regards, Xianwen On Sun, May 9, 2010 at 8:05 PM, Elisabeth Bjerke Rastad ebr...@post.uit.no wrote: Hello! I have a problem which I have tried to solve for several days now.. I have plottet a lineplot.CI in the library sciplot, and I am trying to plot it with a logaritmic y-axis (with exponential base). The problem is that; when I type log y, the axis transforms into the logaritmic of base 10. I wonder if someeone could tell me how to specify that I would like to use the exponential logaritmic y-axis. I have tried a lot (but obviously not all, I guess this problem is possible to solve..) Hope you would like to help me! Thank you a lot in advance!! Greetings, Elisabeth B. RÃ¥stad (Master's student, Norway) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Xianwen Chen, M.Sc. Scientific assistant, BFE, UiT (www.uit.no) Tel.: +47 776 46 112 | Fax: +47 776 46 020 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 10-May-10 Time: 22:48:35 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Robust SE Heteroskedasticity-consistent estimation
Hi, I'm using maxlik with functions specified (L, his gradient hessian). Now I would like determine some robust standard errors of my estimators. So I 'm try to use vcovHC, or hccm or robcov for example but in use one of them with my result of maxlik, I've a the following error message : Erreur dans terms.default(object) : no terms component Is there some attributes to give to maxlik objet for fitting the call of vcovHC? 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] Dataframe horizontal scrolling
under Unix/X11 (and IIRC under Windows), edit(some.data.frame) will invoke a smallish spreadsheet-like data editor, which will allow you to move around your data with no fuss. I probably wouldn't use it for any serious data entry, but found damn useful in a lot of data-debugging situations (you know, the sort of ... thing ... that hit the fan when you've been coaxed to accept Excel spreatsheet as dats sets). HTH, Emmanuel Charpentier Le lundi 10 mai 2010 à 16:06 -0400, Michael H a écrit : R experts, I am working with large multivariable data frames ( 50 variables) and I would like to scroll horizontally across my output to view each data frame rather than having to scroll down vertically- wrapped data frames.I have been using R Commander as a programming interface. If I assign a long character string to a vector I can scroll across its output easily but not a dataframe of equivalent width. I just want my data frame variables to fully output horizontally rather than partially with vertical wrapping, if that is possible. Any help would be appreciated. Thank you, Mike _ Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox. N:WL:en-US:WM_HMP:042010_1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cex.axis on levelplot
I'm trying to use cex.axis or something like this to augment the size labels' on levelplot axis, but it doesn't work. Could someone help me? -- View this message in context: http://r.789695.n4.nabble.com/cex-axis-on-levelplot-tp2172879p2172879.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] predict() without generating the model within R
Is there a predict method/syntax which I could use to generate predictions (and other output from predict() methods) if I have the model parameter estimates from a training dataset but not the data used to generate the original model (the models were generated by a collaborator using STATA and for IRB reasons I am not allowed independent access to the original data)? I have the new/testing data upon which I wish to base my predictions. Thanks, Bimal PS-yes, I know that if my collaborator just used R, he could send me just the model as an Rdata object. That is not going to happen in this instance. Bimal P Chaudhari, MPH Boston University MD Candidate, 2011 Washington University in St. Louis MS Candidate, 2010 Doris Duke Clinical Research Fellow 314-286-2864 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plotting data when all you have is the summary data
Are there functions/packages which support plots (bar and/or line) where I provide the point estimate and some error measure rather than the raw data? I often have to summarize/present data from multiple sources where the original data is unavailable and do not yet have a good solution for this. Thanks, bimal Bimal P Chaudhari, MPH Boston University MD Candidate, 2011 Washington University in St. Louis MS Candidate, 2010 Doris Duke Clinical Research Fellow 314-286-2864 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] predict() without generating the model within R
On 10/05/2010 6:13 PM, Chaudhari, Bimal wrote: Is there a predict method/syntax which I could use to generate predictions (and other output from predict() methods) if I have the model parameter estimates from a training dataset but not the data used to generate the original model (the models were generated by a collaborator using STATA and for IRB reasons I am not allowed independent access to the original data)? I have the new/testing data upon which I wish to base my predictions. That depends on what model is being fit, but in general I'd say it would be impractical to put together enough information for predict() to work properly. However, you can do predictions for many models just from their definition, and you may have enough information to calculate errors as well. But you'll need to program the formulas yourself. Duncan Murdoch Thanks, Bimal PS-yes, I know that if my collaborator just used R, he could send me just the model as an Rdata object. That is not going to happen in this instance. Bimal P Chaudhari, MPH Boston University MD Candidate, 2011 Washington University in St. Louis MS Candidate, 2010 Doris Duke Clinical Research Fellow 314-286-2864 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cex.axis on levelplot
On May 10, 2010, at 4:29 PM, vjaneiro wrote: I'm trying to use cex.axis or something like this to augment the size labels' on levelplot axis, but it doesn't work. Could someone help me? Look at the thread Re: [R] Increasing the font size on axes in trellis from two days ago. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting data when all you have is the summary data
On May 10, 2010, at 6:17 PM, Chaudhari, Bimal wrote: Are there functions/packages which support plots (bar and/or line) where I provide the point estimate and some error measure rather than the raw data? I often have to summarize/present data from multiple sources where the original data is unavailable and do not yet have a good solution for this. There are R packages that support meta analysis. Learn to search, grasshopper. Thanks, bimal Bimal P Chaudhari, MPH Boston University MD Candidate, 2011 Washington University in St. Louis MS Candidate, 2010 David Winsemius, MD, MPH West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Robust SE Heteroskedasticity-consistent estimation
On Mon, 10 May 2010, RATIARISON Eric wrote: Hi, I'm using maxlik with functions specified (L, his gradient hessian). Now I would like determine some robust standard errors of my estimators. So I 'm try to use vcovHC, or hccm or robcov for example but in use one of them with my result of maxlik, I've a the following error message : Erreur dans terms.default(object) : no terms component Is there some attributes to give to maxlik objet for fitting the call of vcovHC? This is discussed in vignette(sandwich-OOP, package = sandwich) one of the vignettes accompanying the sandwich package that provides the vcovHC() function. At the very least, you need an estfun() method which extracts the gradient contributions per observation. Then you need a bread() function, typically based on the observed Hessian. Then you can compute the basic sandwich() estimators. Best, Z 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.
Re: [R] System neutral Daylight Savings Time response?
Perhaps you should be using the chron package. It has no time zones in the first place. On Mon, May 10, 2010 at 2:26 PM, Garrett Grolemund g...@rice.edu wrote: I'm searching for an r command that will notify me if I create a time that does not exist due to Daylight Savings Time. For example, if I run the following command on a windows machine ISOdatetime(2010,03,14,2,10,0, tz = ) # My system time is set to the United States Central Time Zone [1] NA R returns NA, which is the behavior I want. However, if I run the same command on a mac, R returns a POSIXct object and I have to examine the object manually to notice that I had tried to create an impossible time. ISOdatetime(2010,03,14,2,10,0, tz = ) [1] 2010-03-14 01:10:00 CST Is there a method of creating time objects in R that will always return NA for non-existant times, no matter the operating system? Thank you sincerely, Garrett [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R algorithm/package for creating spatial autocorrelation of uniformly distributed landscape values
On May 10, 2010, at 4:54 PM, Laura S wrote: Dear all: I would like to create a landscape of environmental values that follow a uniform frequency distribution and also have spatial autocorrelation in the landscape. Perhaps: X - distribution on one dimension Y - distribution on another dimension cY - rho*X +(1-rho)*Y I was wondering if there is an algorithm and/or package out there that creates autocorrelation of values that are distributed according to a non-normal frequency distribution. There are several packages with the letters distr as a substring. And there is also at least one package that will assist in creating copulas. Any suggestions are greatly appreciated. Thank you, Laura -- Genius is the summed production of the many with the names of the few attached for easy recall, unfairly so to other scientists - E. O. Wilson (The Diversity of Life) [[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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot: Trouble with xlim() and discrete scales
I'm learning ggplot and am a little confused. Sometimes discrete scales work like I'd expect, and sometimes they don't. For example... This works exactly like one would expect: df-data.frame(names=c(Bob,Mary,Joe,Bob,Bob)) ggplot(df,aes(names))+geom_histogram() But this yields an error: ggplot(df,aes(names))+geom_histogram()+xlim(Bob) Error in data.frame(count = as.numeric(tapply(weight, bins, sum, na.rm = TRUE))$ arguments imply differing number of rows: 0, 1 ...as does this: ggplot(df,aes(names))+geom_histogram()+xlim(Bob,Mary) ... but this works fine: ggplot(df,aes(names))+geom_histogram()+xlim(Bob,Mary,Joe) ... and curiously, so does this: ggplot(df,aes(names))+geom_histogram()+xlim(Bob,Mary,Joe,Frank) ... and even more confusingly, this works perfectly: ggplot(df,aes(names,..density..,group=1))+geom_histogram()+xlim(Bob,Mary) This feels like a bug, but perhaps I'm doing something dumb. Can anyone clarify? And while I have your attention: as a ggplot novice, I often find myself getting cryptic error messages like the one above. Nearly always this is because I'm asking it to do something unreasonable, but it often takes me quite a long time to figure out my error. Does anyone have general tips for debugging ggplot commands? Anything better than summary(p)? Thanks very much for your help, -J [[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] ggplot: Trouble with xlim() and discrete scales
On May 10, 2010, at 7:36 PM, John Rauser wrote: I'm learning ggplot and am a little confused. Sometimes discrete scales work like I'd expect, and sometimes they don't. For example... This works exactly like one would expect: df-data.frame(names=c(Bob,Mary,Joe,Bob,Bob)) ggplot(df,aes(names))+geom_histogram() But this yields an error: ggplot(df,aes(names))+geom_histogram()+xlim(Bob) Error in data.frame(count = as.numeric(tapply(weight, bins, sum, na.rm = TRUE))$ arguments imply differing number of rows: 0, 1 Well, a range with only one value seems a bit ... degenerate? ...as does this: ggplot(df,aes(names))+geom_histogram()+xlim(Bob,Mary) str(df) 'data.frame': 5 obs. of 1 variable: $ names: Factor w/ 3 levels Bob,Joe,Mary: 1 3 2 1 1 ... but this works fine: ggplot(df,aes(names))+geom_histogram()+xlim(Bob,Mary,Joe) So now that range covers the factor's possible values, and it appears Hadley's coding is willing to a accept a degree of abstraction. ... and curiously, so does this: ggplot(df,aes(names))+geom_histogram() +xlim(Bob,Mary,Joe,Frank) ... and even more confusingly, this works perfectly: ggplot(df,aes(names,..density..,group=1))+geom_histogram() +xlim(Bob,Mary) This feels like a bug, but perhaps I'm doing something dumb. Looks dumb to me. Can anyone clarify? And while I have your attention: as a ggplot novice, I often find myself getting cryptic error messages like the one above. Nearly always this is because I'm asking it to do something unreasonable, but it often takes me quite a long time to figure out my error. Does anyone have general tips for debugging ggplot commands? Anything better than summary(p)? Use str to look at your data. gives you further information about classes. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot: Trouble with xlim() and discrete scales
May I ask for further illumination of my dumbness? I had been merrily plotting ..density.. and using xlim() to constrain the x-axis like this and everything was working fine: df-data.frame(names=c(Bob,Mary,Joe,Bob,Bob)) ggplot(df,aes(names,..density..,group=1))+geom_histogram()+xlim(Bob,Mary) So I was a little surprised when this didn't work the same way: ggplot(df,aes(names))+geom_histogram()+xlim(Bob,Mary) Actually, looking at the above sparks an idea. I thought there was a difference between plotting ..count.. and ..density.., but in fact it's the group=1 that makes the first example work. Both of these behave as one would hope: ggplot(df,aes(names,group=1))+geom_histogram()+xlim(Bob,Mary) ggplot(df,aes(names,..count..,group=1))+geom_histogram()+xlim(Bob,Mary) ...though I admit that I'm not exactly sure why. Can anyone explain? Thanks, -J [[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 with Names
Hi - a newbie question, if someone can please help I want to change X1, X2,,.to X.1 X.2 etc in the names below. I am using the Principal Component Regression function (pcr) and it seems to want it this way datap3.pcr - pcr(water ~ X, 10, data = datap3, Validation =cv) Error in model.frame.default(formula = water ~ X, data = datap3) : invalid type (list) for variable 'X' -- names(X) [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 [21] X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39 X40 [41] X41 X42 X43 X44 X45 X46 X47 X48 X49 X50 X51 X52 X53 X54 X55 X56 X57 X58 X59 X60 [61] X61 X62 X63 X64 X65 X66 X67 X68 X69 X70 X71 X72 X73 X74 X75 X76 X77 X78 X79 X80 [81] X81 X82 X83 X84 X85 X86 X87 X88 X89 X90 X91 X92 X93 X94 X95 X96 X97 X98 X99 X100 names(X)[1] [1] X1 for(i in 1:100){names(X)[i] - X.i} names(X) [1] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [25] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [49] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [73] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [97] X.i X.i X.i X.i for(i in 1:100){names(X)[i] - X.i} Error: object 'X.i' not found for(i in 1:100){names(X)[i] - X.i} [[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] Help with Names
Is this what you want: x - paste(X, 1:10, sep='') x [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 sub(X, X., x) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 On Mon, May 10, 2010 at 8:53 PM, Ravi Ramaswamy raram...@gmail.com wrote: Hi - a newbie question, if someone can please help I want to change X1, X2,,.to X.1 X.2 etc in the names below. I am using the Principal Component Regression function (pcr) and it seems to want it this way datap3.pcr - pcr(water ~ X, 10, data = datap3, Validation =cv) Error in model.frame.default(formula = water ~ X, data = datap3) : invalid type (list) for variable 'X' -- names(X) [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 [21] X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39 X40 [41] X41 X42 X43 X44 X45 X46 X47 X48 X49 X50 X51 X52 X53 X54 X55 X56 X57 X58 X59 X60 [61] X61 X62 X63 X64 X65 X66 X67 X68 X69 X70 X71 X72 X73 X74 X75 X76 X77 X78 X79 X80 [81] X81 X82 X83 X84 X85 X86 X87 X88 X89 X90 X91 X92 X93 X94 X95 X96 X97 X98 X99 X100 names(X)[1] [1] X1 for(i in 1:100){names(X)[i] - X.i} names(X) [1] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [25] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [49] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [73] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [97] X.i X.i X.i X.i for(i in 1:100){names(X)[i] - X.i} Error: object 'X.i' not found for(i in 1:100){names(X)[i] - X.i} [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Help with Names
Jim - thanks. It worked, however pcr program is still not accepting it there is a sample yarn data loaded and I am comparing. My data looks like this X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 1Kalle 2.36038 2.35396 2.34772 2.34167 2.33587 2.33036 2.32517 2.32033 2.31583 2.31168 2.30791 2.30450 2.30150 2.29891 2.29680 2.29523 2.29421 and yarn data looks like this NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 NIR.10 NIR.11 NIR.12 NIR.13 NIR.14 NIR.15 NIR.16 NIR.17 NIR.18 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 2.00580 1.83790 1.69070 1.57770 1.50330 1.43810 1.33730 1.22060 1.14100 So, I thought I could convert X1 to X.1 and it would work. The names seem different. Not sure how to make the change names(yarn) [1] NIR density train but names(X) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14 X.15 X.16 X.17 X.18 On Mon, May 10, 2010 at 9:05 PM, jim holtman jholt...@gmail.com wrote: Is this what you want: x - paste(X, 1:10, sep='') x [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 sub(X, X., x) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 On Mon, May 10, 2010 at 8:53 PM, Ravi Ramaswamy raram...@gmail.comwrote: Hi - a newbie question, if someone can please help I want to change X1, X2,,.to X.1 X.2 etc in the names below. I am using the Principal Component Regression function (pcr) and it seems to want it this way datap3.pcr - pcr(water ~ X, 10, data = datap3, Validation =cv) Error in model.frame.default(formula = water ~ X, data = datap3) : invalid type (list) for variable 'X' -- names(X) [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 [21] X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39 X40 [41] X41 X42 X43 X44 X45 X46 X47 X48 X49 X50 X51 X52 X53 X54 X55 X56 X57 X58 X59 X60 [61] X61 X62 X63 X64 X65 X66 X67 X68 X69 X70 X71 X72 X73 X74 X75 X76 X77 X78 X79 X80 [81] X81 X82 X83 X84 X85 X86 X87 X88 X89 X90 X91 X92 X93 X94 X95 X96 X97 X98 X99 X100 names(X)[1] [1] X1 for(i in 1:100){names(X)[i] - X.i} names(X) [1] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [25] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [49] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [73] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [97] X.i X.i X.i X.i for(i in 1:100){names(X)[i] - X.i} Error: object 'X.i' not found for(i in 1:100){names(X)[i] - X.i} [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Help with Names
You need to provide an 'str(yarn)' so we can see what the structure is. I don't know what the 'pcr' program is expecting, but it looks like from what you have provided that 'yarn' might be a dataframe and X is a vector. Look at the documentation for pcr and see what it expects. On Mon, May 10, 2010 at 9:08 PM, Ravi Ramaswamy raram...@gmail.com wrote: Jim - thanks. It worked, however pcr program is still not accepting it there is a sample yarn data loaded and I am comparing. My data looks like this X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 1Kalle 2.36038 2.35396 2.34772 2.34167 2.33587 2.33036 2.32517 2.32033 2.31583 2.31168 2.30791 2.30450 2.30150 2.29891 2.29680 2.29523 2.29421 and yarn data looks like this NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 NIR.10 NIR.11 NIR.12 NIR.13 NIR.14 NIR.15 NIR.16 NIR.17 NIR.18 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 2.00580 1.83790 1.69070 1.57770 1.50330 1.43810 1.33730 1.22060 1.14100 So, I thought I could convert X1 to X.1 and it would work. The names seem different. Not sure how to make the change names(yarn) [1] NIR density train but names(X) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14 X.15 X.16 X.17 X.18 On Mon, May 10, 2010 at 9:05 PM, jim holtman jholt...@gmail.com wrote: Is this what you want: x - paste(X, 1:10, sep='') x [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 sub(X, X., x) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 On Mon, May 10, 2010 at 8:53 PM, Ravi Ramaswamy raram...@gmail.comwrote: Hi - a newbie question, if someone can please help I want to change X1, X2,,.to X.1 X.2 etc in the names below. I am using the Principal Component Regression function (pcr) and it seems to want it this way datap3.pcr - pcr(water ~ X, 10, data = datap3, Validation =cv) Error in model.frame.default(formula = water ~ X, data = datap3) : invalid type (list) for variable 'X' -- names(X) [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 [21] X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39 X40 [41] X41 X42 X43 X44 X45 X46 X47 X48 X49 X50 X51 X52 X53 X54 X55 X56 X57 X58 X59 X60 [61] X61 X62 X63 X64 X65 X66 X67 X68 X69 X70 X71 X72 X73 X74 X75 X76 X77 X78 X79 X80 [81] X81 X82 X83 X84 X85 X86 X87 X88 X89 X90 X91 X92 X93 X94 X95 X96 X97 X98 X99 X100 names(X)[1] [1] X1 for(i in 1:100){names(X)[i] - X.i} names(X) [1] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [25] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [49] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [73] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [97] X.i X.i X.i X.i for(i in 1:100){names(X)[i] - X.i} Error: object 'X.i' not found for(i in 1:100){names(X)[i] - X.i} [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Help with Names
There is definitely a difference. The pcr program is Principal Component Regression, but document says The formula argument should be a symbolic formula of the form response ~ terms, where response is the name of the response vector or matrix (for multi-response models) and terms is the name of one or more predictor matrices, usually separated by +, e.g., water ~ FTIR or y ~ X + Z. See lm for a detailed description. The named variables should exist in the supplied data data frame or in the global environment. Not sure what to do next ... str(yarn) 'data.frame':28 obs. of 3 variables: $ NIR: num [1:28, 1:268] 3.07 3.07 3.08 3.08 3.1 ... ..- attr(*, dimnames)=List of 2 .. ..$ : NULL .. ..$ : NULL $ density: num 100 80.2 79.5 60.8 60 ... $ train : logi TRUE TRUE TRUE TRUE TRUE TRUE ... str(X) 'data.frame':79 obs. of 100 variables: $ X.1 : num 2.36 2.36 2.15 2.22 2.3 ... $ X.2 : num 2.35 2.36 2.14 2.22 2.3 ... $ X.3 : num 2.35 2.35 2.14 2.21 2.29 ... $ X.4 : num 2.34 2.34 2.13 2.21 2.28 ... On Mon, May 10, 2010 at 9:19 PM, jim holtman jholt...@gmail.com wrote: You need to provide an 'str(yarn)' so we can see what the structure is. I don't know what the 'pcr' program is expecting, but it looks like from what you have provided that 'yarn' might be a dataframe and X is a vector. Look at the documentation for pcr and see what it expects. On Mon, May 10, 2010 at 9:08 PM, Ravi Ramaswamy raram...@gmail.comwrote: Jim - thanks. It worked, however pcr program is still not accepting it there is a sample yarn data loaded and I am comparing. My data looks like this X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 1Kalle 2.36038 2.35396 2.34772 2.34167 2.33587 2.33036 2.32517 2.32033 2.31583 2.31168 2.30791 2.30450 2.30150 2.29891 2.29680 2.29523 2.29421 and yarn data looks like this NIR.1 NIR.2 NIR.3 NIR.4 NIR.5 NIR.6 NIR.7 NIR.8 NIR.9 NIR.10 NIR.11 NIR.12 NIR.13 NIR.14 NIR.15 NIR.16 NIR.17 NIR.18 1 3.06630 3.08610 3.10790 3.09720 2.99790 2.82730 2.62330 2.40390 2.19310 2.00580 1.83790 1.69070 1.57770 1.50330 1.43810 1.33730 1.22060 1.14100 So, I thought I could convert X1 to X.1 and it would work. The names seem different. Not sure how to make the change names(yarn) [1] NIR density train but names(X) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 X.11 X.12 X.13 X.14 X.15 X.16 X.17 X.18 On Mon, May 10, 2010 at 9:05 PM, jim holtman jholt...@gmail.com wrote: Is this what you want: x - paste(X, 1:10, sep='') x [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 sub(X, X., x) [1] X.1 X.2 X.3 X.4 X.5 X.6 X.7 X.8 X.9 X.10 On Mon, May 10, 2010 at 8:53 PM, Ravi Ramaswamy raram...@gmail.comwrote: Hi - a newbie question, if someone can please help I want to change X1, X2,,.to X.1 X.2 etc in the names below. I am using the Principal Component Regression function (pcr) and it seems to want it this way datap3.pcr - pcr(water ~ X, 10, data = datap3, Validation =cv) Error in model.frame.default(formula = water ~ X, data = datap3) : invalid type (list) for variable 'X' -- names(X) [1] X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19 X20 [21] X21 X22 X23 X24 X25 X26 X27 X28 X29 X30 X31 X32 X33 X34 X35 X36 X37 X38 X39 X40 [41] X41 X42 X43 X44 X45 X46 X47 X48 X49 X50 X51 X52 X53 X54 X55 X56 X57 X58 X59 X60 [61] X61 X62 X63 X64 X65 X66 X67 X68 X69 X70 X71 X72 X73 X74 X75 X76 X77 X78 X79 X80 [81] X81 X82 X83 X84 X85 X86 X87 X88 X89 X90 X91 X92 X93 X94 X95 X96 X97 X98 X99 X100 names(X)[1] [1] X1 for(i in 1:100){names(X)[i] - X.i} names(X) [1] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [25] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [49] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [73] X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i X.i [97] X.i X.i X.i X.i for(i in 1:100){names(X)[i] - X.i} Error: object 'X.i' not found for(i in 1:100){names(X)[i] - X.i} [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? -- Jim Holtman Cincinnati, OH +1 513 646 9390 What
[R] kernel density to smooth plots
Hi r-sers, I have a data of relative frequencies for the interval of 0-20, 20-40,...380-400. I would like the two data on the same graph using the same x-axis label. My question is how to get a smooth curve using kernel density code if it possible for this data. cbind(rel_obs,rel_gen) rel_obs rel_gen [1,] 0.0 0. [2,] 0.092534175 0.0712 [3,] 0.105152471 0.1092 [4,] 0.095688749 0.1264 [5,] 0.107255521 0.1143 [6,] 0.098843323 0.1063 [7,] 0.085173502 0.0878 [8,] 0.084121977 0.0727 [9,] 0.064143007 0.0637 [10,] 0.056782334 0.0475 [11,] 0.048370137 0.0402 [12,] 0.041009464 0.0314 [13,] 0.021030494 0.0269 [14,] 0.029442692 0.0235 [15,] 0.018927445 0.0183 [16,] 0.015772871 0.0134 [17,] 0.009463722 0.0100 [18,] 0.007360673 0.0089 [19,] 0.005257624 0.0072 [20,] 0.004206099 0.0033 [21,] 0.004206099 0.0034 [22,] 0.003154574 0.0030 [23,] 0.002103049 0.0024 [24,] 0.0 0.0018 [25,] 0.0 0.0015 [26,] 0.0 0.0019 [27,] 0.0 0.0011 [28,] 0.0 0.0006 [29,] 0.0 0.0009 [30,] 0.0 0.0006 [31,] 0.0 0.0003 [32,] 0.0 0.0001 [33,] 0.0 0. [34,] 0.0 0.0001 [35,] 0.0 0. [36,] 0.0 0. [37,] 0.0 0.0001 [38,] 0.0 0. [39,] 0.0 0. [40,] 0.0 0. [41,] 0.0 0. 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] Advice needed on awkward tables
Dear r-help list members, I am quite new to R, and hope to seek advice from you about a problem I have been cracking my head over. Apologies if this seems like a simple problem. I have essentially two tables. The first (Table A) is a standard patient clinicopathological data table, where rows correspond to patient IDs and columns correspond to clinical features. Records in this table are stored as 1 or 0 (denoting presence). An example is provided below. The second (Table B) is a table that represents a 'key' to Table A. This Table B has a category field, as well as a feature field which links to the Table B. Unfortunately, this is a one-to-many relationship, and the numbers in the feature field represent the respective columns in Table A, delimited by semicolons. So in the example below, I need to collapse the data in Table B into a table with nrow equivalent to the number of categories and ncol = number of patients. The collapsing of each categoriy, will be based on a Boolean OR, or the equivalent ANY in R (so long as 1 of the features is true, the resulting outcome will be true) data.table.a - matrix(data=round(runif(100)),nrow=10,ncol=10,dimnames=list(paste(Patient,1:10),paste(Feature,1:10))) data.table.b - data.frame (ID=c(1,2,3,4,5,6,7),CATEGORY=c(1,2,3,3,4,5,5),FEATURE=c(9,3;5,7,4,6;10,1;2,8)) In the example tables above, we hope to collapse the features by category - so the final desired output will be a total of 10 patients as rows, and a total of 5 categories as columns. (after collapsing the features by a Boolean OR). (i.e. if any of the features in the category are present, it will be a TRUE). I apologize for the apparently awkward table, but this is what I had to start with. I tried expanding data.table.b$FEATURE using strsplit, which resulted in a list, and then I got stuck there for a long time. Thanks for any help. 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] dbSendQuery with R variables
Rhelpers: I'd like to modify this RSQLite statement: rs_stations-dbSendQuery(con_stations, select * from stations) so that stations is actually an R variable, e.g.: stations=c(stationA,stationB) How would I modify the above statement to query from stations[[1]] (aka stationA)? --j __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.