[R] power spectrum of eeg
Hi, I need to find the power spectrum of an eeg and display frequency in hz. I found two functions, spectrum or auspec but they give me frequency from 0.0 - 0.5. How do i get frequency in Hz or KHz? Also, is it possible to plot two overlapping spectra in order to compare their peaks etc? Thanks for any help. -- View this message in context: http://r.789695.n4.nabble.com/power-spectrum-of-eeg-tp3052195p3052195.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] calculating martingale residual on new data using predict.coxph
Hi David, Thanks, but I don't quite follow your examples below. The residuals you calculated are still based on the training data from which your cox model was generated. I'm interested in the testing data. Best, ...Tao - Original Message From: David Winsemius dwinsem...@comcast.net To: David Winsemius dwinsem...@comcast.net Cc: Shi, Tao shida...@yahoo.com; r-help@r-project.org; dieter.me...@menne-biomed.de; r_ting...@hotmail.com Sent: Fri, November 19, 2010 10:53:26 AM Subject: Re: [R] calculating martingale residual on new data using predict.coxph On Nov 19, 2010, at 12:50 PM, David Winsemius wrote: On Nov 19, 2010, at 12:32 PM, Shi, Tao wrote: Hi list, I was trying to use predict.coxph to calculate martingale residuals on a test data, however, as pointed out before What about resid(fit) ? It's my reading of Therneau Gramsch [and of help(coxph.object) ] that they consider those martingale residuals. The manner in which I _thought_ this would work was to insert some dummy cases into the original data and then to get residuals by weighting the cases appropriately. That doesn't seem to be as successful as I imagined: test1 - list(time=c(4,3,1,1,2,2,3,3), weights=c(rep(1,7), 0), +status=c(1,1,1,0,1,1,0,1), +x=c(0,2,1,1,1,0,0,1), +sex=c(0,0,0,0,1,1,1,1)) coxph(Surv(time, status) ~ x , test1, weights=weights)$weights Error in fitter(X, Y, strats, offset, init, control, weights = weights, : Invalid weights, must be 0 # OK then make it a small number test1 - list(time=c(4,3,1,1,2,2,3,3), weights=c(rep(1,7), 0.01), +status=c(1,1,1,0,1,1,0,1), +x=c(0,2,1,1,1,0,0,1), +sex=c(0,0,0,0,1,1,1,1)) print(resid( coxph(Surv(time, status) ~ x , test1,weights=weights) ) ,digits=3) 12 3 45 6 78 -0.6410 -0.5889 0.8456 -0.1544 0.4862 0.6931 -0.6410 0.0509 Now take out constructed case and weights test1 - list(time=c(4,3,1,1,2,2,3), +status=c(1,1,1,0,1,1,0), +x=c(0,2,1,1,1,0,0), +sex=c(0,0,0,0,1,1,1)) print(resid( coxph(Surv(time, status) ~ x , test1) ) ,digits=3) 1 2 3 4 5 6 7 -0.632 -0.589 0.846 -0.154 0.486 0.676 -0.632 Expecting approximately the same residuals for first 7 cases but not really getting it. There must be something about weights in coxph that I don't understand, unless a one-hundreth of a case gets up indexed inside the machinery of coxph? Still think that inserting a single constructed case into a real dataset of sufficient size ought to be able to yield some sort of estimate, and only be a minor perturbation, although I must admit I'm having trouble figuring out ... why are we attempting such a maneuver? The notion of residuals around constructed cases makes me statistically suspicious, although I suppose that is just some sort of cumulative excess/deficit death fraction. http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html predict(mycox1, newdata, type=expected) is not implemented yet. Dieter suggested to use 'cph' and 'predict.Design', but from my reading so far, I'm not sure they can do that. Do you other ways to calculate martingale residuals on a new data? Thank you very much! ...Tao --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] how to apply sample function to each row of a data frame?
it works. I really appreciate the help! :) -- View this message in context: http://r.789695.n4.nabble.com/Re-how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050933p3052098.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] use sample function to create new data frame
here is my original data frame a b c A B C [1,] 1 2 3 4 5 6 [2,] 7 8 9 10 11 12 [3,] 13 14 15 16 17 18 a, b, c are type I variables A, B, C are type II variables how can I create a new data frame in which: 1) in each row, there are one random number from type I variables, and two random numbers from type II variables 2) meanwhile, in each row, the two type II numbers have to be only those numbers that are not corresponding to the type I number. For example, if the type I number is 1, the type II numbers should not include 4. the new data frame should be like this: [,1] [,2] [,3] [1,]I IIII [2,]I IIII [3,]I IIII Many thanks!! :) -- View this message in context: http://r.789695.n4.nabble.com/use-sample-function-to-create-new-data-frame-tp3052110p3052110.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 calculate squared R of spatial autoregressive models
Dear List, I am comparing the squared R values of linear models and its spatial autoregressive counterparts. (SARerror) (1. lm (Y~X1) 2. lm (Y~ X1+X2) 3. lm(Y~X1+X2+X3)) The squared R values of linear models are generated by command summary (lm). Similarly, I tried to produce those of spatial autoregressive models based on the squared Pearsons correlation of explanatory and response variables. It failed The code is as followed. Please kindly modify the code and thank you. 1. single predictor sar.x1 -errorsarlm(Y~X1,data=datam.std,listw=nb8.w, na.action=na.omit, method=Matrix, zero.policy=TRUE) summary(sar.x1) cor(sar.x1$X1, sar.x1$Y, method = pearson) error message error in cor(sar.x1$ X1, sar.x1$Y, method = pearson) : supply both 'x' and 'y' or a matrix-like 'x' 2. multiple predictors sar.all -errorsarlm(Y~X1+X2+X3,data=datam.std,listw=nb8.w, na.action=na.omit, method=Matrix, zero.policy=TRUE) summary(sar.all) cor(sar.all$X1+ sar.all$X2+ sar.all$X3, sar.x1$Y, method = pearson) error message error in cor(sar.all$X1+ sar.all$X2+ sar.all$X3, sar.x1$Y, method = pearson) : supply both 'x' and 'y' or a matrix-like 'x' Elaine [[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 produce glm graph
In addition to David's suggestion, you might want to examine the termplot function, ?termplot HTH -Original Message- From: r-help-boun...@r-project.org on behalf of David Winsemius Sent: Sat 11/20/2010 3:54 PM To: Sonja Klein Cc: r-help@r-project.org Subject: Re: [R] How to produce glm graph On Nov 20, 2010, at 4:27 AM, Sonja Klein wrote: I'm very new to R and modeling but need some help with visualization of glms. [snip] Is there a way to produce a graph in R that has these features? Of course. Modeling would be of little value without such capability. In R, regression functions produce an object with a particular class (glm in this case) and there is generally have predict method for each class. There is also a vector of fitted values within the object that may be accessed with the fitted or fitted values functions. The predict.glm help page has a worked example. -- 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. [[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] Problem on running update
Hi Martin, Thanks for your advice. Ran following code on R-2.12.0 32bit as admin for(lib in .libPaths()) { + descs - Sys.glob(file.path(lib, *, DESCRIPTION)) + sizes - file.info(descs)$size + names(sizes) - descs + print(sizes[sizes 100]) + } named numeric(0) named numeric(0) Where are the above files? B.R. Stephen L - Original Message From: Martin Morgan mtmor...@fhcrc.org To: Stephen Liu sati...@yahoo.com Cc: r-help@r-project.org Sent: Sun, November 21, 2010 2:10:52 PM Subject: Re: [R] Problem on running update On 11/20/2010 08:56 PM, Stephen Liu wrote: Hi folks, Win 7 64bit R 2.12.) Today on running: update.packages() Error: subscript out of bounds Unable to proceed. I have been googling around and couldn't discover the cause. Pls help. TIA Hi Stephen -- maybe https://stat.ethz.ch/pipermail/r-help/2010-November/259912.html Martin B.R. Stephen L __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Counting things in a time series.
You never did show us what your data looks like. You could convert them to POSIXct, then use 'cut' to split them into the bins and then 'table' to count them. Try something like this: timeStamp - as.POSIXct('2010-11-21 00:00') + runif(50, 0, 86400) # day's worth of time # bin into 1 hour buckets starting at midnight bins - cut(timeStamp, breaks = seq(as.POSIXct('2010-11-21 00:00'), + by = '1 hour', length = 25)) table(bins) bins 2010-11-21 00:00:00 2010-11-21 01:00:00 2010-11-21 02:00:00 2010-11-21 03:00:00 2010-11-21 04:00:00 1 5 4 5 5 2010-11-21 05:00:00 2010-11-21 06:00:00 2010-11-21 07:00:00 2010-11-21 08:00:00 2010-11-21 09:00:00 2 2 4 1 3 2010-11-21 10:00:00 2010-11-21 11:00:00 2010-11-21 12:00:00 2010-11-21 13:00:00 2010-11-21 14:00:00 0 3 3 0 1 2010-11-21 15:00:00 2010-11-21 16:00:00 2010-11-21 17:00:00 2010-11-21 18:00:00 2010-11-21 19:00:00 0 3 0 3 1 2010-11-21 20:00:00 2010-11-21 21:00:00 2010-11-21 22:00:00 2010-11-21 23:00:00 0 1 1 2 On Sun, Nov 21, 2010 at 12:29 AM, Noah Silverman n...@smartmediacorp.com wrote: Hi, I have a process (not in R) that records events with a time stamp. So, I have a huge series of maybe 100,000 time stamps. I'd like to break it up into hourly (Or daily) intervals and then count how many events occurred in each interval. That way I can graph it. Ideally, converting the this into a time series in R would let me do some interesting analysis. The data is just a list of epoch timestamps. Importing into R is trivial but I'm stuck from there. 1) How can I bin the counts by an hour? One thought would be to divided each timestamp by 3600, them multiply back by 1000. This would effectively convert them to hours with multiple entries per hour. ) But, I then don't know how to count them 2) Once I figure out the counts, I'll then have a data structure with a column of epoch seconds and a second column of counts. How can I then convert that into a ts object? Thanks! -N __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [beginner] how to run *.r script from graphic interface (R Console window) ?
Is there a fuction like open(path/to/file), readfile or sth like that that would run code from R file just like I was it typing myself into R Console window ? -- View this message in context: http://r.789695.n4.nabble.com/beginner-how-to-run-r-script-from-graphic-interface-R-Console-window-tp3052326p3052326.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] [beginner] how to run *.r script from graphic interface (R Console window) ?
Have a look at function source(), i.e., type in the R console ?source I hope it helps. Best, Dimitris On 11/21/2010 1:23 PM, madr wrote: Is there a fuction like open(path/to/file), readfile or sth like that that would run code from R file just like I was it typing myself into R Console window ? -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 Web: http://www.erasmusmc.nl/biostatistiek/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] display data as 1px dots in scatterplot ?
By default scatter-plot presents data by using circles, is there a way to make it 1px dots ? -- View this message in context: http://r.789695.n4.nabble.com/display-data-as-1px-dots-in-scatterplot-tp3052343p3052343.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] Counting things in a time series.
Hi, these are pretty basic questions. You might want to pick up an introductory manual. Lets assume you have a time stamp that already indicates the hours. Assume you have 300 observations, each of which falls in one of 24 hours of observation. You easily get the number of obs in each hour with the table command. x=sample(1:24,300,replace=T) table(x) Let's now assume you don't have the observations binned yet. Then you can 'cut' the time stamp vector at intervals of your liking, and tabulate the resulting occurrences of the factors. Assume as an example that you wanted irregular intervals. You want to know how many occurrences there are between midnight and 0900, 0900 and noon, noon and 1500, 1500 and 1800, and 1800 and midnight. nx=cut(x,c(0,9,12,15,18,24)) table(nx) for the second question: ?as.ts() HTH, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Counting-things-in-a-time-series-tp3052148p3052306.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] calculating martingale residual on new data using
The tendency is to use residual-like diagnostics on the entire dataset that was available for model development. For test data we typically run predictive accuracy analyses. For example, one of the strongest validations is to show, in a high-resolution calibration plot, that absolute predictions (e.g., probability of survival at 2 years) are accurate. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/calculating-martingale-residual-on-new-data-using-predict-coxph-tp3050712p3052377.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] calculating martingale residual on new data using predict.coxph
On Nov 21, 2010, at 3:42 AM, Shi, Tao wrote: Hi David, Thanks, but I don't quite follow your examples below. I wasn't really sure they did anything useful anyway. The residuals you calculated are still based on the training data from which your cox model was generated. I'm interested in the testing data. The survest function in rms and the survfit function in survival will calculate survival probabilities given a model and newdata, and depending on your definition of residual you could take the difference between the calculation and validation data. That must be what happens (at least at a gross level of description) when Harrell runs his validate function on his cph models in the rms/Design package, although I don't know if something that you would recognize as a martingale residual is an identifiable intermediate. If you are using survfit, it would appear from my reading that you would need to set the individual parameter to TRUE. I'm assuming you planned to calculate these (1- expected) at the event times of the validation cohort (which it appears the default method fixes via the censor argument)? -- David Best, ...Tao - Original Message From: David Winsemius dwinsem...@comcast.net To: David Winsemius dwinsem...@comcast.net Cc: Shi, Tao shida...@yahoo.com; r-help@r-project.org; dieter.me...@menne-biomed.de; r_ting...@hotmail.com Sent: Fri, November 19, 2010 10:53:26 AM Subject: Re: [R] calculating martingale residual on new data using predict.coxph On Nov 19, 2010, at 12:50 PM, David Winsemius wrote: On Nov 19, 2010, at 12:32 PM, Shi, Tao wrote: Hi list, I was trying to use predict.coxph to calculate martingale residuals on a test data, however, as pointed out before What about resid(fit) ? It's my reading of Therneau Gramsch [and of help(coxph.object) ] that they consider those martingale residuals. The manner in which I _thought_ this would work was to insert some dummy cases into the original data and then to get residuals by weighting the cases appropriately. That doesn't seem to be as successful as I imagined: test1 - list(time=c(4,3,1,1,2,2,3,3), weights=c(rep(1,7), 0), +status=c(1,1,1,0,1,1,0,1), +x=c(0,2,1,1,1,0,0,1), +sex=c(0,0,0,0,1,1,1,1)) coxph(Surv(time, status) ~ x , test1, weights=weights)$weights Error in fitter(X, Y, strats, offset, init, control, weights = weights, : Invalid weights, must be 0 # OK then make it a small number test1 - list(time=c(4,3,1,1,2,2,3,3), weights=c(rep(1,7), 0.01), +status=c(1,1,1,0,1,1,0,1), +x=c(0,2,1,1,1,0,0,1), +sex=c(0,0,0,0,1,1,1,1)) print(resid( coxph(Surv(time, status) ~ x , test1,weights=weights) ) ,digits=3) 12 3 45 6 78 -0.6410 -0.5889 0.8456 -0.1544 0.4862 0.6931 -0.6410 0.0509 Now take out constructed case and weights test1 - list(time=c(4,3,1,1,2,2,3), +status=c(1,1,1,0,1,1,0), +x=c(0,2,1,1,1,0,0), +sex=c(0,0,0,0,1,1,1)) print(resid( coxph(Surv(time, status) ~ x , test1) ) ,digits=3) 1 2 3 4 5 6 7 -0.632 -0.589 0.846 -0.154 0.486 0.676 -0.632 Expecting approximately the same residuals for first 7 cases but not really getting it. There must be something about weights in coxph that I don't understand, unless a one-hundreth of a case gets up indexed inside the machinery of coxph? Still think that inserting a single constructed case into a real dataset of sufficient size ought to be able to yield some sort of estimate, and only be a minor perturbation, although I must admit I'm having trouble figuring out ... why are we attempting such a maneuver? The notion of residuals around constructed cases makes me statistically suspicious, although I suppose that is just some sort of cumulative excess/deficit death fraction. http://tolstoy.newcastle.edu.au/R/e4/help/08/06/13508.html predict(mycox1, newdata, type=expected) is not implemented yet. Dieter suggested to use 'cph' and 'predict.Design', but from my reading so far, I'm not sure they can do that. Do you other ways to calculate martingale residuals on a new data? Thank you very much! ...Tao --David Winsemius, MD West Hartford, CT 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] display data as 1px dots in scatterplot ?
On Nov 21, 2010, at 7:46 AM, madr wrote: By default scatter-plot There is no R function by that name. presents data by using circles, is there a way to make it 1px dots ? It may depend on the actual plotting function, which you have not mentioned, but as a starter read up on the cex parameter in ?par. -- 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] Alternatives to image(...) and filled.contour(...) for 2-D filled Plots
By any chance are there any alternatives to image(...) and filled.contour(...) I used Rseek to search for that very topic, but didn't turn over any leads... http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4newwindow=1q=alternative+to+image+and+filled.contoursa=Searchcof=FORID%3A11siteurl=www.rseek.org%252F#1238 I'm sure there are some out there, but curious about some of the favorites and ones folks have had success using. Thanks for any insights and feedback. I would like to use the alternative 2-D fill function with the example I have been messing with in place of image(...) or filled.contour(...): library(akima) hyp_distance-seq(1,15) angle_deg_val-seq(0,15) x_distance_val-NULL y_distance_val-NULL for(ii in 1:length(hyp_distance)) { for(jj in 1:length(angle_deg_val)) { x_distance_tmp-hyp_distance[ii]*cos(angle_deg_val[jj]*pi/180) y_distance_tmp-hyp_distance[ii]*sin(angle_deg_val[jj]*pi/180) x_distance_val-c(x_distance_val, x_distance_tmp) y_distance_val-c(y_distance_val, y_distance_tmp) } } temperature_vals-rnorm(length(x_distance_val), 75, 2) temp_samples-cbind(x_distance_val, y_distance_val, temperature_vals) temp_samples_DF-data.frame(x = x_distance_val, y = y_distance_val, z = temperature_vals) ak.fan - interp(temp_samples[,1], temp_samples[,2], temp_samples[,3] ) length_val-floor(max(temperature_vals) - min(temperature_vals))*2 color_vals_red_to_yellow_to_green-colorRampPalette(c(red, yellow, green), space=Lab)(length_val) color_vals_green_to_yellow_to_red-colorRampPalette(c(green, yellow, red), space=Lab)(length_val) plot(1,1, col = 0, xlim = c(min(x_distance_val), max(x_distance_val)), ylim = c(min(y_distance_val), max(y_distance_val)), xlab = Room X Position (FT), ylab = Room Y Position (FT), main = Room Temp vs Position) grid() # filled.contour(ak.fan, col = color_vals_red_to_yellow_to_green) # filled.contour(ak.fan, col = color_vals_green_to_yellow_to_red) # image(ak.fan, col = color_vals_red_to_yellow_to_green, add = TRUE) image(ak.fan, col = color_vals_green_to_yellow_to_red, add = TRUE) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] display data as 1px dots in scatterplot ?
At 4:46 AM -0800 11/21/10, madr wrote: By default scatter-plot presents data by using circles, is there a way to make it 1px dots ? -- View this message in context: http://r.789695.n4.nabble.com/display-data-as-1px-dots-in-scatterplot-tp3052343p3052343.html Sent from the R help mailing list archive at Nabble.com. pch = . e.g., x - rnorm(100) plot(x,pch=.) Bill __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] negative alpha or custom gradient colors of data dots in scatterplot ?
I know that by setting alpha to for example col = rgb(0, 0, 0, 0.1) it is possible to see how many overlapping is in the plot. But disadvantage of it is that single points are barely visible on the background. So I wonder if there is possible to make setting that single points would be almost black, but with more and more data on the same spot it would get more and more whiteish. Or maybe it is possible to make sole data points black but overlapped tending to some particular color of choice ? -- View this message in context: http://r.789695.n4.nabble.com/negative-alpha-or-custom-gradient-colors-of-data-dots-in-scatterplot-tp3052394p3052394.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] [beginner] simple keyword to exit script ?
I have tried quit(), and return() but first exits from whole graphical interface and second is only for functions. What I need only to exit from current script and return to the console. -- View this message in context: http://r.789695.n4.nabble.com/beginner-simple-keyword-to-exit-script-tp3052417p3052417.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] [beginner] simple keyword to exit script ?
On Nov 21, 2010, at 9:52 AM, madr wrote: I have tried quit(), and return() but first exits from whole graphical interface and second is only for functions. What I need only to exit from current script and return to the console. ?stop -- 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] [beginner] simple keyword to exit script ?
I try to use stop(), but i get: Error in eval.with.vis(expr, envir, enclos) : -- View this message in context: http://r.789695.n4.nabble.com/beginner-simple-keyword-to-exit-script-tp3052417p3052430.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] plot(x,y xlab=NULL,ylab=NULL) but labels still visible.
Labels are still present on graph render, their names are x and y that is the same as I used on the variables to supply data for chart. How to get rid of them. -- View this message in context: http://r.789695.n4.nabble.com/plot-x-y-xlab-NULL-ylab-NULL-but-labels-still-visible-tp3052439p3052439.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] [beginner] simple keyword to exit script ?
stop() throws an error but the side effect is to pop out of whatever environment you may be in and return to the top-level. I thought that was what you wanted. If not, then please produce a better problem description with code as requested in the posting guide. On Nov 21, 2010, at 10:12 AM, madr wrote: I try to use stop(), but i get: Error in eval.with.vis(expr, envir, enclos) : -- View this message in context: http://r.789695.n4.nabble.com/ And learn to include context. -- 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] plot(x,y xlab=NULL,ylab=NULL) but labels still visible.
On Nov 21, 2010, at 10:21 AM, madr wrote: Labels are still present on graph render, their names are x and y that is the same as I used on the variables to supply data for chart. How to get rid of them. The term labels as used in functions is different than the graphical objects affected by xlab and ylab. Those are really titles ?title ?plot.default # which you should have consulted while you were using the help(plot) information. Use one of axes, xaxt or yaxt To indicate both or which axis to suppress. -- 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] abline(h=whatever) not working in candleChart() (in quantmod)?
Hello, all-- I am having some fun playing with the graphing in quantmod-- very nice! I am writing a function to calculate (and hopefully plot) support and resistance lines, but the usual plot call of abline(h=value) does not seem to work. Here's my code: require(quantmod) AAPL-getYahooData(AAPL) candleChart(AAPL,subset=last 3 months,theme=white) addMACD() abline(h=290,col=red) The same sequence works fine if I'm just using a plain vanilla plot call, however. What am I missing? Do I need to call the line as a technical study using addTA? Not sure how to make a straight line constant doing that... I'm sure it should be obvious, since my searching on google hasn't turned up anything. So I'm getting ready for a face-palm moment if anyone can point me in the right direction! --- David L. Van Brunt, Ph.D. mailto:dlvanbr...@gmail.com On Sun, Nov 21, 2010 at 10:29 AM, David Winsemius dwinsem...@comcast.netwrote: stop() throws an error but the side effect is to pop out of whatever environment you may be in and return to the top-level. I thought that was what you wanted. If not, then please produce a better problem description with code as requested in the posting guide. On Nov 21, 2010, at 10:12 AM, madr wrote: I try to use stop(), but i get: Error in eval.with.vis(expr, envir, enclos) : -- View this message in context: http://r.789695.n4.nabble.com/ And learn to include context. -- 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. [[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] [beginner] simple keyword to exit script ?
On Nov 21, 2010, at 10:43 AM, madr wrote: Is there any way of suppressing that error, like in other programming languages you can specifically invoke an error or simply exit, If you are in a function, then return() like after user input, exiting then is not always identical with error , there are cases when it is intended behavior. I thought R makes that distinction. Provide some code. (You did say you had a script.) The answer probably depends on context and you are not providing any. -- 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] plot(x,y xlab=NULL,ylab=NULL) but labels still visible.
here's the code x= c(1,5,7,3,4) y= c(2,4,5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5), xaxt=NULL,yaxt=NULL, xlab=NULL,ylab=NULL) and x and y are still visible -- View this message in context: http://r.789695.n4.nabble.com/plot-x-y-xlab-NULL-ylab-NULL-but-labels-still-visible-tp3052439p3052482.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] plot(x,y xlab=NULL,ylab=NULL) but labels still visible.
Replace the xlab=NULL and ylab=NULL in your example code with xlab= and ylab= to remove the x and y labels on your axes. If you're also trying to remove the ticks and tick labels, substitute xaxt=n and yaxt=n into your code. x= c(1,5,7,3,4) y= c(2,4,5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0,0.5), xaxt=NULL,yaxt=NULL, xlab=,ylab=) On Sun, Nov 21, 2010 at 11:02 AM, madr madra...@interia.pl wrote: here's the code x= c(1,5,7,3,4) y= c(2,4,5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5), xaxt=NULL,yaxt=NULL, xlab=NULL,ylab=NULL) and x and y are still visible -- View this message in context: http://r.789695.n4.nabble.com/plot-x-y-xlab-NULL-ylab-NULL-but-labels-still-visible-tp3052439p3052482.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. -- ___ Luke Miller Postdoctoral Researcher Marine Science Center Northeastern University Nahant, MA (781) 581-7370 x318 [[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] plot(x,y xlab=NULL,ylab=NULL) but labels still visible.
On Nov 21, 2010, at 11:02 AM, madr wrote: here's the code x= c(1,5,7,3,4) y= c(2,4,5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5), xaxt=NULL,yaxt=NULL, xlab=NULL,ylab=NULL) and x and y are still visible ?par for valid xaxt and yaxt values. And unlearn the use of NULL for argument values. You generally are going to want to provide something (NA or ) and in R NULL is nothing. See if this is closer to what you wanted x= c(1,5,7,3,4) y= c(2,4,5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)), pch='X', col = rgb(0, 0, 0, 0.5), xaxt=n, yaxt=n, xlab=,ylab=) -- 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] resample from tail of exponential
Hello If i want to resample from the tail of exponential distribution,and the observations are divided to intervals ,the probability of each interval is p.what is the suitable command? Regards Sulafah [[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] plot(x,y xlab=NULL,ylab=NULL) but labels still visible.
On 2010-11-21 08:02, madr wrote: here's the code x= c(1,5,7,3,4) y= c(2,4,5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5), xaxt=NULL,yaxt=NULL, xlab=NULL,ylab=NULL) and x and y are still visible If you just want to remove both axis titles (xlab and ylab), use plot(, ann = FALSE). If you want both axes to be free of ticks, etc, use plot(, ann = FALSE, axes = FALSE). This will also remove the 'box' around the plot; you can add that back with plot() box() It's useful to study the documentation for ?plot.default to which you are directed by ?plot. Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RCurl and cookies in POST requests
Hi Christian There is a new version of the RCurl package on the Omegahat repository and that handles this case. The issue was running the finalizer to garbage collect the curl handle, and it was correctly not being released as the dynCurlReader() update function was precious and had a reference to the curl handle. The new package has finer grained control in curlSetOpt() to control whether functions are made 'precious' or not and we can use this when we know we will leave the curl handle in a correct and consistent state even when the values of the function options are to be garbage collected before the curl handle. D. On 11/15/10 7:06 AM, Christian M. wrote: Hello Duncan. Thanks for having a look at this. As soon as I get home I'll try your suggestion. BTW, the link to the omega-help mailing list seems to be broken: http://www.omegahat.org/mailman/listinfo/ Thank you. chr Duncan Temple Lang (Monday 15 November 2010, 01:02): Hi Christian Thanks for finding this. The problem seems to be that the finalizer on the curl handle seems to disappear and so is not being called when the handle is garbage collected. So there is a bug somewhere and I'll try to hunt it down quickly. In the meantime, you can achieve the same effect by calling the C routine curl_easy_cleanup. You can't do this directly with a .Call() or .C() as there is no explicit interface in the RCurl package to this routine. However, you can use the Rffi package (on the omegahat repository) library(Rffi) cif = CIF(voidType, list(pointerType)) callCIF(cif, curl_easy_cleanup, c...@ref) I'll keep looking for why the finalizer is getting discarded. Thanks again, D. On 11/14/10 6:30 AM, Christian M. wrote: Hello. I know that it's usually possible to write cookies to a cookie file by removing the curl handle and doing a gc() call. I can do this with getURL(), but I just can't obtain the same results with postForm(). If I use: curlHandle - getCurlHandle(cookiefile=FILE, cookiejar=FILE) and then do: getURL(http://example.com/script.cgi, curl=curlHandle) rm(curlHandle) gc() it's OK, the cookie is there. But, if I do (same handle; the parameter is a dummy): postForm(site, .params=list(par=cookie), curl=curlHandle, style=POST) rm(curlHandle) gc() no cookie is written. Probably I'm doing something wrong, but don't know what. Is it possible to store cookies read from the output of a postForm() call? How? Thanks. Christian PS.: I'm attaching a script that can be sourced (and its .txt version). It contains an example. The expected result is a file (cookies.txt) with two cookies. The script currently uses getURL() and two cookies are stored. If postForm() is used (currently commented), only 1 cookie is written. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] power spectrum of eeg
Date: Sun, 21 Nov 2010 00:18:24 -0800 From: master.rs...@yahoo.com To: r-help@r-project.org Subject: [R] power spectrum of eeg Hi, I need to find the power spectrum of an eeg and display frequency in hz. I found two functions, spectrum or auspec but they give me frequency from 0.0 - 0.5. How do i get frequency in Hz or KHz? Help it to help you and show it a scaling factor. ?spectrum points to something callsed frequency(x) that presumably shows it the scaling factors. Also, is it possible to plot two overlapping spectra in order to compare their peaks etc? Thanks for any help. -- View this message in context: http://r.789695.n4.nabble.com/power-spectrum-of-eeg-tp3052195p3052195.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ?summaryRprof running at 100% cpu for one hour ...
On 21.11.2010 01:30, Kjetil Halvorsen wrote: see below. 2010/11/20 Uwe Liggeslig...@statistik.tu-dortmund.de: On 19.11.2010 21:43, Kjetil Halvorsen wrote: This is very strange. (Debian squeeze, R 2.12.0 compiled from source) I did some moderately large computation (including svd of a 560x50 matrix), running a few minutes, and R memory increasing to about 900MB on this 2 GB ram laptop. I had done Rprof(memory.profiling=TRUE) first. Then doing summaryRprof(). Then doing ?summaryRprof and then the computer running with one of two cores at 100% for more than an hour! Whats happening? We do not know. What about sending a reproducible example? I will try. But how do I send this info Well, just send what you typed to get into that state ... Uwe when I have to kill the R-process from outside? kjetil Best, Uwe (running R from within emacs-ess) Kjetil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ?summaryRprof running at 100% cpu for one hour ...
OK, trying it on a 8Gb Windows machine with R-2.12.0 64-bit it runs within less than 2 minutes in 5Gb of RAM. That means your machine is probably swapping heavily and is therefore extremely slow. Nevertheless, this seems to be unrelated with summaryRprof(). The anacor() call is roughly equally fast with or without Rprof() calls around it. Best wishes, Uwe On 21.11.2010 02:38, Kjetil Halvorsen wrote: OK . I will try to give an reproducible example. the code I give refer to a 72x72 matrix Wna, which is given at the end of this message. This matrix contains NA's on the diagonal.I try an correspondence analysis on this matrix, with package anacor, which supports correspondence analysis of matrices with NA's. library(anacor) Loading required package: scatterplot3d Loading required package: fda Loading required package: splines Loading required package: zoo Loading required package: colorspace Loading required package: car Loading required package: MASS Loading required package: nnet Loading required package: survival Rprof(file=Rprof.out, append=FALSE, memory.profiling=TRUE) sessionInfo() R version 2.12.0 (2010-10-15) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C [3] LC_TIME=en_US.utf8LC_COLLATE=en_US.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_US.utf8 [7] LC_PAPER=en_US.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] anacor_1.0-1 car_2.0-6survival_2.35-8 [4] nnet_7.3-1 MASS_7.3-8 colorspace_1.0-1 [7] fda_2.2.5zoo_1.6-4scatterplot3d_0.3-31 loaded via a namespace (and not attached): [1] fortunes_1.4-0 grid_2.12.0 lattice_0.19-13 tools_2.12.0 green.ana-anacor(Wna, ndim=3) I will start this command in a moment, it runs for over an hour, and memory grows to multiple GB (If there are to many other programs running, the process gets killed!. This laptop has amd64, debian squeeze, 2Gb ram, 4Gb swap. I leave it running tonight. After finnishing this, giving some simple commands , like ls() or ?Rprof, leads to the problem described originally. Will post more info tomorrow. Kjetil On Sat, Nov 20, 2010 at 9:30 PM, Kjetil Halvorsen kjetilbrinchmannhalvor...@gmail.com wrote: see below. 2010/11/20 Uwe Liggeslig...@statistik.tu-dortmund.de: On 19.11.2010 21:43, Kjetil Halvorsen wrote: This is very strange. (Debian squeeze, R 2.12.0 compiled from source) I did some moderately large computation (including svd of a 560x50 matrix), running a few minutes, and R memory increasing to about 900MB on this 2 GB ram laptop. I had done Rprof(memory.profiling=TRUE) first. Then doing summaryRprof(). Then doing ?summaryRprof and then the computer running with one of two cores at 100% for more than an hour! Whats happening? We do not know. What about sending a reproducible example? I will try. But how do I send this info when I have to kill the R-process from outside? dput(Wna) structure(c(NA, 0, 0, 0, 0.34, 0.114285714, 0.125, 0, 0.138461538, 0, 0, 0, 0.085714286, 0.26667, 0, 0.35, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.12, 0, 0, 0.090909091, 0, 0, 0.44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4, 0.142857143, 0.525, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.225, 0.65, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0.085714286, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.454545455, 0.08, 0, 0, 0, 0, 0, 0.25, 0, 0, 0, 0.714285714, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.18, 0.054545455, 0, 0, 0, 0.1, 0, 0.542857143, 0, 0.114285714, 0, 0, 0.25, 0.16, 0, 0, 0, 0, 0, 0, 0, 0.046153846, 0.2, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0.1, 0, 0.125, 0, 0, 0, 0.085714286, 0, 0, 0.16667, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.08, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.257142857, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.114285714, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, NA, 0, 0.114285714, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.3, 0, 0.285714286, 0, 0, 0.145454545, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.12, 0.125, 0, 0, 0.1, 0, 0.145454545, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.075, 0, 0.1, 0.2, 0.7, 0, 0, 0, 0, 0, 0, 0, 0, 0.79333, 0, 0.325, 0, NA, 0, 0, 0, 0, 0, 0, 0, 0.114285714, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.090909091, 0, 0, 0.14, 0, 0, 0, 0.185714286, 0, 0, 0, 0, 0, 0, 0, 0.054545455, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.625, 0, 0, 0, 0, 0, 0, 0, 0, 0.40667, 0, 0, 0, 0.5, 0.08, NA, 0, 0, 0.123076923, 0.9, 0.085714286, 0, 0.571428571, 0, 0.7, 0, 0.5, 0.25, 0, 0.1, 0, 0.571428571, 0, 0, 0.072727273, 0.5, 0.1, 0.24, 0, 0, 0, 0, 0.125, 0, 0.32, 0.3, 0, 0, 0.057142857, 0.25, 0, 0, 0.685714286, 0.26667, 0, 0.272727273, 0, 0,
[R] how to get rid of unused space on all 4 borders in plot() render
x= c(1,5,7,-3,4) y= c(2,4,-5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5),yaxt=n, ann=FALSE) and this code produces: http://i53.tinypic.com/ffd7d3.png Where I marked in red areas that I want to get rid of and use as much real screen estate as I can. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052527.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] [beginner] simple keyword to exit script ?
Is there any way of suppressing that error, like in other programming languages you can specifically invoke an error or simply exit, like after user input, exiting then is not always identical with error , there are cases when it is intended behavior. I thought R makes that distinction. -- View this message in context: http://r.789695.n4.nabble.com/beginner-simple-keyword-to-exit-script-tp3052417p3052464.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get rid of unused space on all 4 borders in plot() render
On Nov 21, 2010, at 11:49 AM, madr wrote: x= c(1,5,7,-3,4) y= c(2,4,-5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5),yaxt=n, ann=FALSE) Rather than filling up r-help with incremental beginner questions you need to either: --- read more introductory material such as found here: http://cran.r-project.org/other-docs.html --- or read more of the help documents. In this case ?par and this code produces: http://i53.tinypic.com/ffd7d3.png Where I marked in red areas that I want to get rid of and use as much real screen estate as I can. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052527.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD 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] Merge two ggplots
Hi: On Sun, Nov 21, 2010 at 5:55 AM, Alaios ala...@yahoo.com wrote: Sorry it was a typo: my code looks like: plot_shad_CR-function(x,y,agentid,CRagent,f){ library(ggplot2) plotdata-melt(f) names(plotdata)-c('x','y','z') agent-CRagent[[agentid]] # To make following expression shorter ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+ ^^where do these come from? geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80+ geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour=CRagents[[i]]$sr)+ ^^^ ?? geom_tile(aes(fill=z)) } It's a *much* saner approach to arrange the data before submitting it to ggplot(). In other words, generate a data frame with the the variables CRX, CRY sr and/or its corresponding cuts and *then* submit it to ggplot(). The hard work is to produce a data frame that will run simply through ggplot(). HTH, Dennis and I get as an error message this: plot_shad_CR(CRX,CRY,1,CRagent,f) Error in eval(expr, envir, enclos) : object 'z' not found Calls: print ... lapply - is.vector - lapply - FUN - eval - eval -- *From:* Dennis Murphy djmu...@gmail.com *To:* Alaios ala...@yahoo.com *Cc:* Rhelp r-help@r-project.org *Sent:* Sat, November 20, 2010 4:24:15 PM *Subject:* Re: [R] Merge two ggplots Hi: Perhaps a plus sign at the end of the line before geom_tile() would help. Dennis On Sat, Nov 20, 2010 at 6:30 AM, Alaios ala...@yahoo.com wrote: Hello everyone. I am using ggplot and I need some help to merge these two plots into one. plot_CR-function(x,y,agentid,CRagent){ library(ggplot2) agent-CRagent[[agentid]] # To make following expression shorter ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+ geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80+ geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour=CRagents[[i]]$sr) } plot_shad_f-function(f){ library(ggplot2) plotdata-melt(f) names(plotdata)-c('x','y','z') v-ggplot(plotdata, aes(x, y, z = z)) v + geom_tile(aes(fill=z)) } The first plot puts points and texts below the points... in an area while the second function in the same are fills the background using geom_tiles... Is it possible somehow to merge these two plots into one? So far I have tried to merge the two functions as one but I fail as ggplot is not very clear to me what it needs. plotdata-melt(f) names(plotdata)-c('x','y','z') agent-CRagent[[agentid]] # To make following expression shorter ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+ geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80+ geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour=CRagents[[i]]$sr) geom_tile(aes(fill=z)) } Could you please help me? I would like to thank you in advance for your help Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [beginner] simple keyword to exit script ?
On Sun, Nov 21, 2010 at 9:52 AM, madr madra...@interia.pl wrote: I have tried quit(), and return() but first exits from whole graphical interface and second is only for functions. What I need only to exit from current script and return to the console. 1. use my.source() below instead of source() to source your file and 2. in your file exit by using parent.frame(3)$exit.source(returncode). Note that parent.frame(3)exit.source(returncode) must be at the top level of your script. If its buried within a function within the script then you may have to increase 3 to some larger number to go back the correct number of frames. See ?callCC for more info. Here is an example: # use this in place of source my.source - function(file, ...) { source. - function(exit.source) source(file, ...) callCC(source.) } # generate a test script called mytestfile.R cat(cat('A\n') parent.frame(3)$exit.source(7) # exit script cat('B\n') , file = mytestfile.R) # run the test script # It never gets to cat('B\n') # exitcode contains the exit code, 7 in this case exitcode - my.source(mytestfile.R) -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [beginner] simple keyword to exit script ?
Better is probably to return() from a function, i.e. define a function in your script and call that at the end of your function, e.g. - - - - main - function() { # bla # bla if (something) { return(); } # otherwise # bla } main(); - - - - Otherwise, here is a hack: stopQuietly - function(...) { blankMsg - sprintf(\r%s\r, paste(rep( , getOption(width)-1L), collapse= )); stop(simpleError(blankMsg)); } # stopQuietly() stopQuietly() The Error: message will be replaced by blanks. It will still output an empty line. May not work in all settings; depends on terminal etc. You need to define stopQuietly() in your script. My $.02 /Henrik On Sun, Nov 21, 2010 at 7:56 AM, David Winsemius dwinsem...@comcast.net wrote: On Nov 21, 2010, at 10:43 AM, madr wrote: Is there any way of suppressing that error, like in other programming languages you can specifically invoke an error or simply exit, If you are in a function, then return() like after user input, exiting then is not always identical with error , there are cases when it is intended behavior. I thought R makes that distinction. Provide some code. (You did say you had a script.) The answer probably depends on context and you are not providing any. -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem on running update
On 11/21/2010 03:12 AM, Stephen Liu wrote: Hi Martin, Thanks for your advice. Ran following code on R-2.12.0 32bit as admin for(lib in .libPaths()) { + descs - Sys.glob(file.path(lib, *, DESCRIPTION)) + sizes - file.info(descs)$size + names(sizes) - descs + print(sizes[sizes 100]) + } named numeric(0) named numeric(0) Where are the above files? If your problem was as a regular user, then run the above code as regular user not admin. Not sure what 'the above files' are that you are looking for; the 'named numeric(0)' says that no packages have DESCRIPTION files with size 100; the loop looked in all directories in .libPaths() for a subdirectory with file DESCRIPTION; you can find these by for instance Sys.glob(file.path(.libPaths()[1], *, DESCRIPTION)) Your next step is to identify where the error is occurring; you might try update.packages(repos=http://cran.r-project.org;) and when the error occurs use traceback() to understand the functions that are being called at the time of the error; the output of traceback() will be helpful to the list, even if not useful to you. The next step is likely to try to identify more precisely where the problem is, e.g., options(error=recover) update.packages(repos=http://cran.r-project.org;) and then following the instructions on ?recover and ?browser to more precisely identify the problem. Use options(error=NULL) to turn off recovery when done. Martin B.R. Stephen L - Original Message From: Martin Morgan mtmor...@fhcrc.org To: Stephen Liu sati...@yahoo.com Cc: r-help@r-project.org Sent: Sun, November 21, 2010 2:10:52 PM Subject: Re: [R] Problem on running update On 11/20/2010 08:56 PM, Stephen Liu wrote: Hi folks, Win 7 64bit R 2.12.) Today on running: update.packages() Error: subscript out of bounds Unable to proceed. I have been googling around and couldn't discover the cause. Pls help. TIA Hi Stephen -- maybe https://stat.ethz.ch/pipermail/r-help/2010-November/259912.html Martin B.R. Stephen L __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 rid of unused space on all 4 borders in plot() render
Alternatively give ggplot2 package a try: x= c(1,5,7,-3,4) y= c(2,4,-5,2,5) xx - data.frame(x,y) library(ggplot2) qplot(x,y, data=xx) --- On Sun, 11/21/10, madr madra...@interia.pl wrote: From: madr madra...@interia.pl Subject: [R] how to get rid of unused space on all 4 borders in plot() render To: r-help@r-project.org Received: Sunday, November 21, 2010, 11:49 AM x= c(1,5,7,-3,4) y= c(2,4,-5,2,5) plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='X',col = rgb(0, 0, 0, 0.5),yaxt=n, ann=FALSE) and this code produces: http://i53.tinypic.com/ffd7d3.png Where I marked in red areas that I want to get rid of and use as much real screen estate as I can. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052527.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [beginner] simple keyword to exit script ?
On Sun, Nov 21, 2010 at 10:56:14AM -0500, David Winsemius wrote: On Nov 21, 2010, at 10:43 AM, madr wrote: Is there any way of suppressing that error, like in other programming languages you can specifically invoke an error or simply exit, If you are in a function, then return() like after user input, exiting then is not always identical with error , there are cases when it is intended behavior. I thought R makes that distinction. Provide some code. (You did say you had a script.) The answer probably depends on context and you are not providing any. A script may reach a condition, when it should stop in different situations. It need not be called using source(). It may be a function called from an extension package. If there is a sequence of several embedded calls than return() cannot be used. For scripts, which i use myself, i use stop() with a parameter, which is a character string explaining the stopping condition. This string is then a part of the generated error message. For scripts, which are used also by other people, i try to avoid this and make sure that after reaching a stopping condition, all cycles and function calls are finished. PS. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Merge two ggplots
Sorry it was a typo: my code looks like: plot_shad_CR-function(x,y,agentid,CRagent,f){ library(ggplot2) plotdata-melt(f) names(plotdata)-c('x','y','z') agent-CRagent[[agentid]] # To make following expression shorter ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+ geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80+ geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour=CRagents[[i]]$sr)+ geom_tile(aes(fill=z)) } and I get as an error message this: plot_shad_CR(CRX,CRY,1,CRagent,f) Error in eval(expr, envir, enclos) : object 'z' not found Calls: print ... lapply - is.vector - lapply - FUN - eval - eval From: Dennis Murphy djmu...@gmail.com Cc: Rhelp r-help@r-project.org Sent: Sat, November 20, 2010 4:24:15 PM Subject: Re: [R] Merge two ggplots Hi: Perhaps a plus sign at the end of the line before geom_tile() would help. Dennis Hello everyone. I am using ggplot and I need some help to merge these two plots into one. plot_CR-function(x,y,agentid,CRagent){ library(ggplot2) agent-CRagent[[agentid]] # To make following expression shorter ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+ geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80+ geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour=CRagents[[i]]$sr) } plot_shad_f-function(f){ library(ggplot2) plotdata-melt(f) names(plotdata)-c('x','y','z') v-ggplot(plotdata, aes(x, y, z = z)) v + geom_tile(aes(fill=z)) } The first plot puts points and texts below the points... in an area while the second function in the same are fills the background using geom_tiles... Is it possible somehow to merge these two plots into one? So far I have tried to merge the two functions as one but I fail as ggplot is not very clear to me what it needs. plotdata-melt(f) names(plotdata)-c('x','y','z') agent-CRagent[[agentid]] # To make following expression shorter ggplot((data.frame(x=CRX,y=CRY,sr=agent$sr)))+ geom_point(aes(x,y,colour=cut(sr,c(0,-10,-20,-30,-40,-50,-60,-70,-80+ geom_text(aes(x,y,color=cut(sr, c(0,-10,-20,-30,-40,-50,-60,-70,-80)), label=round(sr,3)),vjust=1,legend=FALSE)+labs(colour=CRagents[[i]]$sr) geom_tile(aes(fill=z)) } Could you please help me? I would like to thank you in advance for your help Regards Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] a philosophy R question
Thanks to all for the great insightful answers! Sincerely, Erin On Sat, Nov 20, 2010 at 10:22 PM, bill.venab...@csiro.au wrote: The conventional view used to be that S is the language and that R and S-PLUS are implementations of it. R is usually described as 'a programming environment for data analysis and graphics' (as was S-PLUS before it). However as the language that R implements diverges inexorably from the classical definition of S it is now probably more accurate to describe the language itself as R as well, now a dialect of S, if you will. The only thing most would agree upon, though is that neither R nor S-PLUS should *ever* be described as stats packages. Such a description is definitely to be avoided. In fact calling R a 'package' at all would be both confusing and misleading (not to mention demeaning!). Bill Venables. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent: Sunday, 21 November 2010 11:56 AM To: R help Subject: [R] a philosophy R question Dear R People: Do we say that R is a programming language or a programming environment, please? Which is correct, please? Thanks in advance, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@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. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get rid of unused space on all 4 borders in plot() render
I have looked into par documentation, and only setting for size of the plot area was pin. But this setting sets the area as inflexible, that is no matter how I make the window small or big it stays the same. Default value has advantage that however it uses plot area that is always smaller than device area still this area is changing with the window and able to be bigger. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052631.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] [beginner] simple keyword to exit script ?
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Henrik Bengtsson Sent: Sunday, November 21, 2010 8:17 AM To: David Winsemius Cc: r-help; madr Subject: Re: [R] [beginner] simple keyword to exit script ? Better is probably to return() from a function, i.e. define a function in your script and call that at the end of your function, e.g. This list gets a lot of questions about how to do things with 'scripts' that are easily done with functions. The S language (implemented by R and S+) is oriented around functions, not scripts. Functions easily call other functions but scripts cannot easily call other scripts. Scripts are handy for one-off things, but if you want to use the code in them again it is best to put it into functions (and, after not too long, the functions into a package). If you don't accept that fact you have no end of frustration with the language. (I realize others may have different opinions.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com - - - - main - function() { # bla # bla if (something) { return(); } # otherwise # bla } main(); - - - - Otherwise, here is a hack: stopQuietly - function(...) { blankMsg - sprintf(\r%s\r, paste(rep( , getOption(width)-1L), collapse= )); stop(simpleError(blankMsg)); } # stopQuietly() stopQuietly() The Error: message will be replaced by blanks. It will still output an empty line. May not work in all settings; depends on terminal etc. You need to define stopQuietly() in your script. My $.02 /Henrik On Sun, Nov 21, 2010 at 7:56 AM, David Winsemius dwinsem...@comcast.net wrote: On Nov 21, 2010, at 10:43 AM, madr wrote: Is there any way of suppressing that error, like in other programming languages you can specifically invoke an error or simply exit, If you are in a function, then return() like after user input, exiting then is not always identical with error , there are cases when it is intended behavior. I thought R makes that distinction. Provide some code. (You did say you had a script.) The answer probably depends on context and you are not providing any. -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] density at particular values
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Shant Ch Sent: Saturday, November 20, 2010 6:34 PM To: David Winsemius Cc: r-help@r-project.org Subject: Re: [R] density at particular values David, I did look at ?density many times. I think I didn't explain what I have to find. Suppose I have a data. x- c(rnorm(40,5,3),rcauchy(30,0,4),rexp(30,6)) Suppose I don't have information about the mixture, I have been given only the data. density(x) will give the 6 number summary of the data, given as x and also the 6 number summary of the density of density given as y. print(density(x)) displays a 6-number summary of the x and y outputs of density, which are only tangentially related to the data. (The default x output is a evenly spaced seqence of n=512 values covering the range of the input x.) I don't know why this display was chosen. I want to find the density of the given data at x=1. I basically want the value of y(=density) for x=1 i.e. kernel density at x=1. If you really just want the density at a single point, x0 (=1 in your case), you can do d0 - density(x, from=x0, to=x0, n=1)$y (density only lets you choose the output x vector as an evenly spaced sequence parameterized by from, to, and n.) Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Shant From: David Winsemius dwinsem...@comcast.net Cc: r-help@r-project.org Sent: Sat, November 20, 2010 8:54:32 PM Subject: Re: [R] density at particular values On Nov 20, 2010, at 8:07 PM, Shant Ch wrote: Hello everyone! I want to use density function of R to compute the density at x(=0, say). But it is giving me the 5-number summary and mean of the data and densities at that point. I just want the densities at different values specified by me. Can anyone let me know how can I find that? Here's what you should have done (even before posting): ?density Read the help page to see the structure of what density() returns. Value x the n coordinates of the points where the density is estimated. y the estimated density values. These will be non-negative, but can be zero. Realize that the specified by me part is either going to be modified to pick an existing estimate near my specification or that you will need to approximate the value. So what is the actual problem (and the actual data setup) ? --David. For example Thanks in advance for your help. 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. David Winsemius, MD West Hartford, CT [[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] how to get rid of unused space on all 4 borders in plot() render
On Nov 21, 2010, at 1:31 PM, madr wrote: I have looked into par documentation, and only setting for size of the plot area was pin. But this setting sets the area as inflexible, that is no matter how I make the window small or big it stays the same. Default value has advantage that however it uses plot area that is always smaller than device area still this area is changing with the window and able to be bigger. Look in the Graphics section of Petra Kuhnert and Bill Venables document in the contributed documentation. It's really excellent. Starts out by defining the regions in the plot window. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052631.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD 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] boxplot: reverse y-axis order
Hello, Searching this forum has enabled me to get pretty far in what I'm trying to do. However, there is one more manipulation I would like to make and I haven't found a solution. Using the data and code below, I generate the plot produced by the last command. If possible I would like to reverse the order of the y-axis (bearing in mind horizontal=T) so that 0 is plotted at the upper most part of the y-axis and 3 at the axis intercepts. I've tried the experiment approach to no avail, meaning I've placed rev(...) around various arguments but with wrong results. Thanks, Eric df-read.table(textConnection(Field Date AvgWTD Region variable value hole depth depthM 204 17-Aug-00 2.897428989 US R1 NA R 1 0 205 17-Aug-00 4.017264366 US R1 1.01 R 1 0 206 10-Jun-03 NA US R1 1.19 R 1 0 207 26-May-04 NA US R1 1.6 R 1 0 207 29-May-03 NA US R1 1.23 R 1 0 207 17-Aug-00 NA US R1 1.82 R 1 0 21 03-Jun-99 1.896872044 US R1 NA R 1 0 22 10-Aug-00 1.546097994 US R1 1.3 R 1 0 22 17-Aug-99 1.639824152 US R1 1.11 R 1 0 22 02-Jun-99 1.202943921 US R1 1.44 R 1 0 23 22-May-02 1.52449 US R1 1.58 R 1 0 23 09-Aug-00 1.938527942 US R1 2.2 R 1 0 23 17-Aug-99 0.93040204 US R1 1.36 R 1 0 23 02-Jun-99 1.479804039 US R1 2.65 R 1 0 24 09-Jun-03 NA US R1 1.08 R 1 0 24 04-Jun-01 1.484376073 US R1 NA R 1 0 24 09-Aug-00 1.439671993 US R1 2.41 R 1 0 24 03-Jun-99 1.481328011 US R1 2.36 R 1 0 26A 16-Aug-00 3.128010035 US R1 2.44 R 1 0 26A 06-Apr-99 NA US R1 1.81 R 1 0 26B 10-Aug-00 2.090928078 US R1 1.62 R 1 0 27 26-May-04 NA US R1 1.6 R 1 0 27 29-May-03 NA US R1 NA R 1 0 27 04-Jun-01 NA US R1 2.24 R 1 0 27 09-Aug-00 5.324855804 US R1 9.79 R 1 0 27 10-Jun-99 NA US R1 1.25 R 1 0 28 10-Aug-04 3.565550327 US R1 1.01 R 1 0 28 10-Aug-00 2.169414043 US R1 1.79 R 1 0 28 10-Jun-99 1.633728027 US R1 2.1 R 1 0 29 09-Jun-03 1.847087979 US R1 3.01 R 1 0 29 22-May-02 1.950719953 US R1 0.981 R 1 0 29 08-Jun-01 1.647139192 US R1 1.8 R 1 0 29 15-Aug-00 1.946148038 US R1 3.01 R 1 0 29 04-Jun-99 1.824735999 US R1 0.845 R 1 0 30 28-May-03 NA US R1 1.09 R 1 0 30 10-Aug-00 3.727704048 US R1 0.76 R 1 0 30 17-Aug-99 NA US R1 NA R 1 0 30 03-Jun-99 NA US R1 1.87 R 1 0 31 15-Aug-00 1.594104052 US R1 2.32 R 1 0 31 17-Aug-99 0.961643994 US R1 0.99 R 1 0 31 03-Jun-99 0.907288015 US R1 1.48 R 1 0 33 04-Jun-01 5.030724049 US R1 1.23 R 1 0 33 15-Aug-00 4.110228062 US R1 2.24 R 1 0 33 12-Aug-99 1.383792043 US R1 NA R 1 0 33 04-Jun-99 1.542287946 US R1 1.42 R 1 0 35 14-Aug-00 1.918715954 US R1 2.1 R 1 0 35 17-Aug-99 1.495044112 US R1 1.52 R 1 0 35 06-Apr-99 NA US R1 2.02 R 1 0 37 22-May-02 4.803647995 US R1 2.12 R 1 0 37 06-Aug-01 3.499104261 US R1 1.91 R 1 0 37 16-Aug-00 3.473958015 US R1 2.41 R 1 0 37 08-Jun-99 NA US R1 0.648 R 1 0 38 26-May-04 NA US R1 1.94 R 1 0 38 04-Aug-03 NA US R1 2.02 R 1 0 38 16-Aug-01 2.645663977 US R1 4.97 R 1 0 38 08-Jun-99 1.240535975 US R1 1.06 R 1 0 39 16-Aug-00 1.674571276 US R1 3.25 R 1 0 39 08-Jun-99 0.774192035 US R1 7.41 R 1 0 40 09-Aug-04 NA US R1 18 R 1 0 40 26-May-04 NA US R1 7.03 R 1 0 40 29-May-03 NA US R1 3.61 R 1 0 40 04-Jun-01 0.669035971 US R1 3.92 R 1 0 40 16-Aug-00 0.518160045 US R1 2.81 R 1 0 40 11-Aug-99 0.232257605 US R1 NA R 1 0 41 09-Aug-05 0.704087973 US R1 1.65 R 1 0 41 26-May-04 1.865375996 US R1 1.62 R 1 0 41 04-Aug-03 1.544319987 US R1 0.968 R 1 0 41 02-Jun-03 2.767584085 US R1 1.02 R 1 0 41 11-Aug-00 1.138427973 US R1 0.98 R 1 0 41 12-Aug-99 0.924763203 US R1 1.64 R 1 0 41 09-Jun-99 0.964184046 US R1 1.24 R 1 0 42 11-Aug-00 1.082802057 US R1 1.09 R 1 0 43 09-Jun-03 1.775460005 US R1 1.14 R 1 0 43 30-May-01 1.38074398 US R1 2.38 R 1 0 43 16-Aug-00 0.61214 US R1 2.23 R 1 0 43 12-Aug-99 0.583996832 US R1 4.97 R 1 0 43 09-Jun-99 0.838199973 US R1 3.41 R 1 0 45 06-Jun-01 5.977128029 US R1 1.72 R 1 0 45 10-Aug-00 5.331714153 US R1 1.57 R 1 0 45 10-Jun-99 NA US R1 1.13 R 1 0 48 09-Aug-04 3.940454483 US R1 0.886 R 1 0 48 28-May-03 NA US R1 1.15 R 1 0 48 30-May-01 2.782824039 US R1 2.79 R 1 0 48 15-Aug-00 2.336292028 US R1 7.22 R 1 0 48 12-Aug-99 1.379220009 US R1 NA R 1 0 49 16-Aug-00 2.613964796 US R1 2.1 R 1 0 49 31-May-99 NA US R1 NA R 1 0 5 08-Aug-00 NA US R1 1.19 R 1 0 50 16-Aug-00 2.816961765 US R1 1.02 R 1 0 50 11-Aug-99 2.66755 US R1 1.45 R 1 0 50 31-May-99 NA US R1 1.54 R 1 0 51 02-Jun-03 NA US R1 4.15 R 1 0 51 16-Aug-00 NA US R1 4.68 R 1 0 51 11-Aug-99 NA US R1 NA R 1 0 51 09-Jun-99 5.42076 US R1 2.37 R 1 0 52 04-Aug-03 2.141219854 US R1 1.88 R 1 0 52 09-Jun-03 1.549908042 US R1 1.13 R 1 0 52 04-Jun-01 2.020823956 US R1 3.13 R 1 0 52 10-Aug-99 2.029206038 US R1 NA R 1 0 52 09-Jun-99 1.862328053 US R1 1.56 R 1 0 53 12-Aug-99 NA US R1 1.37 R 1 0 53 09-Jun-99 NA US R1 3.77 R 1 0 57 11-Aug-99 1.907286048 US R1 4.58 R 1 0 57 09-Jun-99 0.930655956 US R1 11.1 R 1 0 6 28-May-03 3.97459197 US R1 1.35 R 1 0 6 31-May-01 4.736591816 US R1 2.69 R 1 0 6 08-Aug-00 5.587999821 US R1 1.43 R 1 0 60A 11-Jun-99 NA US R1 1.56 R 1 0 61 22-May-02 2.862071991 US R1 1.57 R 1 0 61 06-Aug-01 2.178558111 US R1 1.69 R 1 0 61
Re: [R] use sample function to create new data frame
Gong, thanks!! but your syntax did work out as I would expect. here following are the reasons: each row from my original data frame represents data from one subject. when the one type I number and the two type II numbers are drawn from the original data frame, both type I number and type II numbers should both from the same subject. by doing so, the new data frame should only have 3 rows with each representing one subject. I am trying to revise your syntax to make it work... :) -- View this message in context: http://r.789695.n4.nabble.com/use-sample-function-to-create-new-data-frame-tp3052110p3052629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get rid of unused space on all 4 borders in plot() render
On Nov 21, 2010, at 2:43 PM, madr wrote: finally I found what I wanted, John Kane send it, and I don't know why it hasn't been posted automatically to the list so I post it by myself: solution is this: par(mai=c(.5,.5,.5,.5)) These four numbers are the margins, so setting it to 0,0,0,0 will render only plot area with 1px for box on every edge As you would have immediately found if you had gone to the Kuhnert and Venables material I suggested you read. -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052705.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD 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] model.matrix() and lm() for nested factors
To R-help list: I would like to use lm() and lmRob() to estimate the parameters of a fixed-effects model that includes nested factors with unequal numbers of levels, in some cases without also including the nesting factor in the model. When I specify options(contrasts=c(contr.sum,contr.poly)), the model matrix generated by model.matrix() can be incorrect. I realize that I can create the desired matrix myself, and use lm.fit(), or lmRob.fit.compute() but there are two problems with this: First, we are warned against using those functions directly, and, second, whereas the models I want to apply are the same for about 100 different data frames, each with about 500 observations, a different model matrix would have to be constructed for each data frame, increasing the chance of error. --- Here is a toy example: Dataframe diff.df: G D T2 1 g1 d1 -60 2 g1 d2 -50 3 g1 d3 -40 4 g2 d1 20 5 g2 d2 40 6 g2 d3 60 7 g2 d4 80 (G, D factors; T2 numeric) After options(contrasts=c(contr.sum,contr.poly)) neither of the following produces the desired model matrix: model.matrix(T2 ~ G + D%in%G, diff.df) model.matrix(T2 ~ D%in%G, diff.df) For example, omitting row numbers, the second command produces: Icpt Dd1:Gg1 Dd2:Gg1 Dd3:Gg1 Dd4:Gg1 Dd1:Gg2 Dd2:Gg2 Dd3:Gg2 Dd4:Gg2 1 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 whereas the correct matrix is: Icpt Gg1:D1 Gg1:D2 Gg2:D1 Gg2:D2 Gg2:D3 1 1 0 0 0 0 1 0 1 0 0 0 1 -1 -1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 1 0 0 0 0 1 1 0 0 -1 -1 -1 --- Other behavior of model.matrix() with nested factors in tiny examples: When the nested factors had unequal numbers of levels and the nesting factor was not included in the model, as above, the matrix generated for contr.treatment was also wrong. When the nested factors had unequal numbers of levels and the nesting factor was included in the model, the matrix for contr.sum was wrong, while the matrix for contr.treatment was wrong only in having an extra column of zeros. When the nested factors had equal numbers of levels and the nesting factor was not included in the model, the correct matrix was generated for neither contr.sum nor contr.treatment. When the nested factors had equal numbers of levels and the nesting factor was included in the model, the correct matrix was generated for both contr.sum and contr.treatment. --- My questions: (1) If there is a way to use lm() and lmRob() in such cases so that they generate the correct contrast matrices (and hence the desired parameter estimates), what is it? (2) If there is no way to do this, is the best alternative for the user to create the desired model matrices by hand and provide them as arguments to lim.fit() and lmRob.fit.compute()? (3) If one uses lm.fit() and lmRob.fit.compute() directly in this way, then, given that one is warned against doing so, what are the dangers? Many thanks. Saul Sternberg Psychology University of Pennsylvania R%%sessionInfo() R version 2.12.0 (2010-10-15) Platform: x86_64-redhat-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 draw manifold?
Hi, I'm joining in with a question -- is it possible to vary the color of the lines along z? The 'colors' argument doesn't seem to allow a vector in this situation. Thanks, baptiste On 21 November 2010 21:02, Carl Witthoft c...@witthoft.com wrote: Thanks, Dennis. Here's an enhanced version: z - seq(-10, 10, 0.1) zm-cbind(z,z,z,z,z,z,z,z,z,z) ym-matrix(nr=201,nc=10) for (i in seq(1,201)) { for (j in seq(1,10)) ym[i,j]-j/10*sin(zm[i,1])} xm-matrix(nr=201,nc=10) for (i in seq(1,201)) { for (j in seq(1,10)) xm[i,j]-j/10*cos(zm[i,1])} scatterplot3d(as.vector(t(xm)), as.vector(t(ym)), as.vector(t(zm)), main = 'Helix', pch = .,type='l') From there I can draw a few helical lines by modifying your original code (for different radii), and end up with a pretty decent mesh surface. Carl On 11/20/10 12:03 PM, Dennis Murphy wrote: Hi: Here's an example stolen out of the scatterplot3d package vignette (p. 9): library(scatterplot3d) z- seq(-10, 10, 0.01) x- cos(z) y- sin(z) scatterplot3d(x, y, z, highlight.3d = TRUE, col.axis = 'blue', col.grid = 'lightblue', main = 'Helix', pch = 20) HTH, Dennis On Sat, Nov 20, 2010 at 8:29 AM, Carl Witthoftc...@witthoft.com wrote: Hi, I need some help either in how to configure variables for wireframe(), or some suggestions as to other graphics commands to use for plotting a 2-D manifold in 3-D space. Here is an example I tried (in the hopes that it would plot a helical line) : xsp-matrix(c(cos(seq(0,80)/5)),9,9) ysp-matrix(c(sin(seq(0,80)/5)),9,9) zsp-matrix(c((seq(0,80)/20)),9,9) wireframe(zsp~xsp*ysp) The resulting plot looks vaguely like a helix, but not right. And if I change my variables' dimensions to c(3,27) it looks better, but if the dims are c(1,81), nothing gets plotted. So: is there a way to control which points are connected by lines in wireframe()? Or is there a more appropriate way to provide a plotting program with sets of coordinates in 3-space? My primary goal is to be able to plot surfaces, not just a line as in my sample code. For example, I might expand the data above to represent points on a 'ribbon' helix. Thanks for yr. help -- feel free to point me to help files for existing packages or plotting routines. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] between-group covar matrix
Hello- I am trying to calculate the between-group covariance matrix for a set of data for eventual Canonical Discrim Analysis. I can obtain the total covariance matrix and individual group covar matrix, but I am failing miserably at getting the between-group covar. The data set is composed of 9 variables, 3 groups and 26 observations. If anyone can provide some help, it would be extremely appreciated. I am an R newbie... please be gentle. -jh [[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 draw manifold?
On Nov 21, 2010, at 3:42 PM, baptiste auguie wrote: Hi, I'm joining in with a question -- is it possible to vary the color of the lines along z? The 'colors' argument doesn't seem to allow a vector in this situation. This section of the code (which appears fairly close to the beginning, makes me think that the color argument is passed as part of the x argument. if (!is.null(d - dim(x)) (length(d) == 2) (d[2] = 4)) color - x[, 4] else if (is.list(x) !is.null(x$color)) color - x$color - Either as the 4th column of a matrix or as a color-list-element. David. Thanks, baptiste On 21 November 2010 21:02, Carl Witthoft c...@witthoft.com wrote: Thanks, Dennis. Here's an enhanced version: z - seq(-10, 10, 0.1) zm-cbind(z,z,z,z,z,z,z,z,z,z) ym-matrix(nr=201,nc=10) for (i in seq(1,201)) { for (j in seq(1,10)) ym[i,j]-j/10*sin(zm[i,1])} xm-matrix(nr=201,nc=10) for (i in seq(1,201)) { for (j in seq(1,10)) xm[i,j]-j/10*cos(zm[i,1])} scatterplot3d(as.vector(t(xm)), as.vector(t(ym)), as.vector(t(zm)), main = 'Helix', pch = .,type='l') From there I can draw a few helical lines by modifying your original code (for different radii), and end up with a pretty decent mesh surface. Carl On 11/20/10 12:03 PM, Dennis Murphy wrote: Hi: Here's an example stolen out of the scatterplot3d package vignette (p. 9): library(scatterplot3d) z- seq(-10, 10, 0.01) x- cos(z) y- sin(z) scatterplot3d(x, y, z, highlight.3d = TRUE, col.axis = 'blue', col.grid = 'lightblue', main = 'Helix', pch = 20) HTH, Dennis On Sat, Nov 20, 2010 at 8:29 AM, Carl Witthoftc...@witthoft.com wrote: Hi, I need some help either in how to configure variables for wireframe(), or some suggestions as to other graphics commands to use for plotting a 2-D manifold in 3-D space. Here is an example I tried (in the hopes that it would plot a helical line) : xsp-matrix(c(cos(seq(0,80)/5)),9,9) ysp-matrix(c(sin(seq(0,80)/5)),9,9) zsp-matrix(c((seq(0,80)/20)),9,9) wireframe(zsp~xsp*ysp) The resulting plot looks vaguely like a helix, but not right. And if I change my variables' dimensions to c(3,27) it looks better, but if the dims are c(1,81), nothing gets plotted. So: is there a way to control which points are connected by lines in wireframe()? Or is there a more appropriate way to provide a plotting program with sets of coordinates in 3-space? My primary goal is to be able to plot surfaces, not just a line as in my sample code. For example, I might expand the data above to represent points on a 'ribbon' helix. Thanks for yr. help -- feel free to point me to help files for existing packages or plotting routines. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. 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] abline(h=whatever) not working in candleChart() (in quantmod)?
On Nov 21, 2010, at 10:50 AM, David L. Van Brunt, Ph.D. wrote: Hello, all-- I am having some fun playing with the graphing in quantmod-- very nice! I am writing a function to calculate (and hopefully plot) support and resistance lines, but the usual plot call of abline(h=value) does not seem to work. Here's my code: require(quantmod) AAPL-getYahooData(AAPL) candleChart(AAPL,subset=last 3 months,theme=white) addMACD() abline(h=290,col=red) Looks to me that chartSeries is an S4 function that works on objects of class chob. So try seeing if these widen your perspective : ?chob-class ?TA ?newTA The same sequence works fine if I'm just using a plain vanilla plot call, however. What am I missing? Do I need to call the line as a technical study using addTA? That's what it looks like from here. Not sure how to make a straight line constant doing that... I'm sure it should be obvious, since my searching on google hasn't turned up anything. So I'm getting ready for a face-palm moment if anyone can point me in the right direction! --- David L. Van Brunt, Ph.D. mailto:dlvanbr...@gmail.com trimmed the irrelevant material from another posting . 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] boxplot: reverse y-axis order
On 21.11.2010 20:30, emorway wrote: Hello, Searching this forum has enabled me to get pretty far in what I'm trying to do. However, there is one more manipulation I would like to make and I haven't found a solution. Using the data and code below, I generate the plot produced by the last command. If possible I would like to reverse the order of the y-axis (bearing in mind horizontal=T) so that 0 is plotted at the upper most part of the y-axis and 3 at the axis intercepts. I've tried the experiment approach to no avail, meaning I've placed rev(...) around various arguments but with wrong results. Thanks, Eric df-read.table(textConnection(Field Date AvgWTD Region variable value hole depth depthM 204 17-Aug-00 2.897428989 US R1 NA R 1 0 [SNIP] 9A 09-Aug-00 1.482089996 US C6 NA C 6 1.8 9B 01-Jun-01 1.409700036 US C6 NA C 6 1.8 9B 09-Aug-00 3.837660074 US C6 NA C 6 1.8),header=T) closeAllConnections() #The folling call doesn't preserve the correct spacing between data boxplot(value~depthM,data=df,horizontal=T,outline=F) #The following command preserves correct spacing, but need to reverse the order boxplot(value~factor(depthM,levels=c(0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3)),data=df,horizontal=T,outline=F) So if you want to reverse, either specify the levels in reverse order or use rev() as in: boxplot(value ~ factor(depthM, levels = rev(c(0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4,2.7,3))), data = df, horizontal = TRUE, outline = FALSE) 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.
Re: [R] how to draw manifold?
Thanks, Dennis. Here's an enhanced version: z - seq(-10, 10, 0.1) zm-cbind(z,z,z,z,z,z,z,z,z,z) ym-matrix(nr=201,nc=10) for (i in seq(1,201)) { for (j in seq(1,10)) ym[i,j]-j/10*sin(zm[i,1])} xm-matrix(nr=201,nc=10) for (i in seq(1,201)) { for (j in seq(1,10)) xm[i,j]-j/10*cos(zm[i,1])} scatterplot3d(as.vector(t(xm)), as.vector(t(ym)), as.vector(t(zm)), main = 'Helix', pch = .,type='l') From there I can draw a few helical lines by modifying your original code (for different radii), and end up with a pretty decent mesh surface. Carl On 11/20/10 12:03 PM, Dennis Murphy wrote: Hi: Here's an example stolen out of the scatterplot3d package vignette (p. 9): library(scatterplot3d) z- seq(-10, 10, 0.01) x- cos(z) y- sin(z) scatterplot3d(x, y, z, highlight.3d = TRUE, col.axis = 'blue', col.grid = 'lightblue', main = 'Helix', pch = 20) HTH, Dennis On Sat, Nov 20, 2010 at 8:29 AM, Carl Witthoftc...@witthoft.com wrote: Hi, I need some help either in how to configure variables for wireframe(), or some suggestions as to other graphics commands to use for plotting a 2-D manifold in 3-D space. Here is an example I tried (in the hopes that it would plot a helical line) : xsp-matrix(c(cos(seq(0,80)/5)),9,9) ysp-matrix(c(sin(seq(0,80)/5)),9,9) zsp-matrix(c((seq(0,80)/20)),9,9) wireframe(zsp~xsp*ysp) The resulting plot looks vaguely like a helix, but not right. And if I change my variables' dimensions to c(3,27) it looks better, but if the dims are c(1,81), nothing gets plotted. So: is there a way to control which points are connected by lines in wireframe()? Or is there a more appropriate way to provide a plotting program with sets of coordinates in 3-space? My primary goal is to be able to plot surfaces, not just a line as in my sample code. For example, I might expand the data above to represent points on a 'ribbon' helix. Thanks for yr. help -- feel free to point me to help files for existing packages or plotting routines. Carl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] density at particular values
On 21-Nov-10 19:11:20, William Dunlap wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Shant Ch Sent: Saturday, November 20, 2010 6:34 PM To: David Winsemius Cc: r-help@r-project.org Subject: Re: [R] density at particular values David, I did look at ?density many times. I think I didn't explain what I have to find. Suppose I have a data. x- c(rnorm(40,5,3),rcauchy(30,0,4),rexp(30,6)) Suppose I don't have information about the mixture, I have been given only the data. density(x) will give the 6 number summary of the data, given as x and also the 6 number summary of the density of density given as y. print(density(x)) displays a 6-number summary of the x and y outputs of density, which are only tangentially related to the data. (The default x output is a evenly spaced seqence of n=512 values covering the range of the input x.) I don't know why this display was chosen. I want to find the density of the given data at x=1. I basically want the value of y(=density) for x=1 i.e. kernel density at x=1. If you really just want the density at a single point, x0 (=1 in your case), you can do d0 - density(x, from=x0, to=x0, n=1)$y (density only lets you choose the output x vector as an evenly spaced sequence parameterized by from, to, and n.) Bill Dunlap Almost, but not quite! (Perhaps ... ). For example: set.seed(54321) x- c(rnorm(40,5,3),rcauchy(30,0,4),rexp(30,6)) # Shant Ch's mixture min(x) # [1] -33.32023 max(x) # [1] 716.6736 d - density(x,from=(-34),to=720,n=755) c(d$x[36],d$y[36]) ## Using density() on the full range of data # [1] 1.000 0.1125064 density(x,from=1,to=1,n=1)$y ## William's targeted density() # [1] 0.1136818 So there's about 1% difference in this example. Of course, what the answer *should* be is debatable, and 1% may be well within the debatable range, and William's 0.1136818 may be just as acceptable as my 0.1125064 (and that's without getting into issues of bandwidth and so on). I'm just putting it up to illustrate that you should not expect a unique answer to this question: what the answer is depends on how you set about finding it! Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 21-Nov-10 Time: 19:39:41 -- 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.
Re: [R] how to get rid of unused space on all 4 borders in plot() render
# 89 px / 105 px - wasted space png(d:/test.png,width=1369,height=1129,units=px) par(bg='black',fg='gray',col='gray',col.axis='gray',col.lab='gray',col.main='gray',col.sub='gray') plot(x,y,ylim=c(-20,20),xlim=c(min(x),max(x)),pch='.',col = rgb(1,1,1, 0.5),yaxt=n, ann=FALSE) dev.off() so only hack that I thought of is to save graph to a file with dimensions exceeding my need in exact amount to balance the black space and after that do auto-crop function in graphic program original: http://i55.tinypic.com/qzitqq.png cropped: http://i53.tinypic.com/29ntu75.png -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052675.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to produce glm graph
As others have noted, you can use predict() to get the fitted values and then plot them 'manually' using basic plotting functions in R. However, you will probably find it easier to use the effects package, which is designed for exactly this task. e.g., install.packages(effects) # if necessary library(effects) mod.cowles - glm(volunteer ~ sex + neuroticism*extraversion, data=Cowles, family=binomial) eff.cowles - allEffects(mod.cowles, xlevels=list(neuroticism=0:24, extraversion=seq(0, 24, 6)), given.values=c(sexmale=0.5)) eff.cowles In addition, you may find things simpler if you use poly(NEdist,2) rather than NEdist+I(NEdist^2), but effects should be able to handle either. HTH -Michael On 11/20/2010 4:27 AM, Sonja Klein wrote: I'm very new to R and modeling but need some help with visualization of glms. I'd like to make a graph of my glms to visualize the different effects of different parameters. I've got a binary response variable (bird sightings) and use binomial glms. The 'main' response variable is a measure of distance to a track and the parameters I'm testing for are vegetation parameters that effect the response in terms of distance. My glm is: glm(Response~NEdist+I(NEdist^2)+Distance+I(Distance^2) which is the basic model and where I add interactions to, like for exampls Visibility as an interaction to Distance (glm(Response~NEdist+I(NEdist^2)+Distance*Visibility+I(Distance^2))) I'd now like to make a graph which has the response variable on the y-axis (obviously). But the x-axis should have distance on it. The NEdist is a vector that is just co-influencing the curve and has to stay in the model but doesn't have any interactions with any other vectors. I'd then like to put in curves/lines for the different models to see if for example visibility effects the distance of the track to the first bird sighting. Is there a way to produce a graph in R that has these features? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] is it possible to put tick labels inside plotting area ?
here is what i mean: before: http://i51.tinypic.com/117xv6v.png after : http://i51.tinypic.com/sv2xed.png -- View this message in context: http://r.789695.n4.nabble.com/is-it-possible-to-put-tick-labels-inside-plotting-area-tp3052777p3052777.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] stupid R tricks
On 11/07/2010 08:06 PM, David Winsemius wrote: On Nov 7, 2010, at 12:25 PM, David Winsemius wrote: On Nov 7, 2010, at 11:40 AM, Carl Witthoft wrote: Hi all, Just thought I'd post this (maybe) helpful tool I wrote. For people like me who are bad at keeping a clean environment, it's a time-saver. #simple command to get only one type of object in current environment lstype-function(type='closure'){ inlist-ls(.GlobalEnv) if (type=='function') type -'closure' typelist-sapply(sapply(inlist,get),typeof) return(names(typelist[typelist==type])) } As a fellow messy-enviromnetalist that was useful. Here's a similar function that returns a vector of object names belonging to a particular (single) class: getclass - function(cls) ls(envir=.GlobalEnv)[ sapply(ls(envir=.GlobalEnv), function(x) class(eval(parse(text=x))) ) == cls ] Here is a version that substitutes get(...) for eval(parse(text= ...) making it a bit less subject to fortune hunters and removes the limitation to one-class objects: getclass - function(cls=data.frame) ls(envir=.GlobalEnv)[ sapply( sapply(ls(envir=.GlobalEnv), function(x) class(get(x)) ), function(y) cls %in% y) ] Hello, A simpler, less verbose version: getclass - function(cls=data.frame) Filter( function( b ) any( cls %in% class( get( b ) ) ), ls( envir=.GlobalEnv ) ) Best regards, Carlos J. Gil Bellosta http://www.datanalytics.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] is it possible to put tick labels inside plotting area ?
I found it. It was hard to find because no one asked about it , the proper question was about distance from the axis which can be negative. So the proper answer is : par( mgp = c(0, -1.4, 0) ) - only the center value is controlling feature in question. -- View this message in context: http://r.789695.n4.nabble.com/is-it-possible-to-put-tick-labels-inside-plotting-area-tp3052777p3052793.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get rid of unused space on all 4 borders in plot() render
finally I found what I wanted, John Kane send it, and I don't know why it hasn't been posted automatically to the list so I post it by myself: solution is this: par(mai=c(.5,.5,.5,.5)) These four numbers are the margins, so setting it to 0,0,0,0 will render only plot area with 1px for box on every edge -- View this message in context: http://r.789695.n4.nabble.com/how-to-get-rid-of-unused-space-on-all-4-borders-in-plot-render-tp3052527p3052705.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] is it possible to put tick labels inside plotting area ?
On 2010-11-21 13:18, madr wrote: I found it. It was hard to find because no one asked about it , the proper question was about distance from the axis which can be negative. So the proper answer is : par( mgp = c(0, -1.4, 0) ) - only the center value is controlling feature in question. If you want your tick marks to point inward, you might also have a look at par(tcl = ). Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: Fwd: R help
On 11/21/10 11:24, Ahmed Attia wrote: -- Forwarded message -- From: Ahmed Attia ahmedati...@gmail.com Date: Sun, Nov 21, 2010 at 11:06 AM Subject: R help To: r-help@r-project.org Dear All, I'm a beginner user in R and I would like to make a quadratic plus plateau and linear plus plateau modelsin R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron Editor: Judgment and Decision Making (http://journal.sjdm.org) -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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: Fwd: R help
Dear Ahmed, Can you give a more specific example of what you want to do? Do you mean you want to test specific contrasts for a categorical variable? If you are new to R, you will find it helpful to read the Introduction to R http://cran.r-project.org/doc/manuals/R-intro.html I also recommend going through an introductory book. There are many, my personal favorite is: Introductory Statistics with R by Peter Dalgaard Cheers, Josh On Sun, Nov 21, 2010 at 3:28 PM, Ahmed Attia ahmedati...@gmail.com wrote: On 11/21/10 11:24, Ahmed Attia wrote: -- Forwarded message -- From: Ahmed Attia ahmedati...@gmail.com Date: Sun, Nov 21, 2010 at 11:06 AM Subject: R help To: r-help@r-project.org Dear All, I'm a beginner user in R and I would like to make a quadratic plus plateau and linear plus plateau modelsin R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 [snip extra signatures] -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] Problem on running update
Hi Martin, Thanks for your advice. This is my first time hunting for cause of error on R. Steps performed as follows; Sys.glob(file.path(.libPaths()[1], *, DESCRIPTION)) [1] C:\\Users\\satimis\\Documents/R/win-library/2.12/Ecdat/DESCRIPTION [2] C:\\Users\\satimis\\Documents/R/win-library/2.12/RColorBrewer/DESCRIPTION [3] C:\\Users\\satimis\\Documents/R/win-library/2.12/Rglpk/DESCRIPTION [4] C:\\Users\\satimis\\Documents/R/win-library/2.12/akima/DESCRIPTION [5] C:\\Users\\satimis\\Documents/R/win-library/2.12/bitops/DESCRIPTION [6] C:\\Users\\satimis\\Documents/R/win-library/2.12/caTools/DESCRIPTION [7] C:\\Users\\satimis\\Documents/R/win-library/2.12/cubature/DESCRIPTION [8] C:\\Users\\satimis\\Documents/R/win-library/2.12/degreenet/DESCRIPTION [9] C:\\Users\\satimis\\Documents/R/win-library/2.12/ergm/DESCRIPTION [10] C:\\Users\\satimis\\Documents/R/win-library/2.12/fBasics/DESCRIPTION [11] C:\\Users\\satimis\\Documents/R/win-library/2.12/gam/DESCRIPTION [12] C:\\Users\\satimis\\Documents/R/win-library/2.12/gdata/DESCRIPTION [13] C:\\Users\\satimis\\Documents/R/win-library/2.12/gplots/DESCRIPTION [14] C:\\Users\\satimis\\Documents/R/win-library/2.12/gtools/DESCRIPTION [15] C:\\Users\\satimis\\Documents/R/win-library/2.12/kinship/DESCRIPTION [16] C:\\Users\\satimis\\Documents/R/win-library/2.12/latentnet/DESCRIPTION [17] C:\\Users\\satimis\\Documents/R/win-library/2.12/logspline/DESCRIPTION [18] C:\\Users\\satimis\\Documents/R/win-library/2.12/maxLik/DESCRIPTION [19] C:\\Users\\satimis\\Documents/R/win-library/2.12/miscTools/DESCRIPTION [20] C:\\Users\\satimis\\Documents/R/win-library/2.12/network/DESCRIPTION [21] C:\\Users\\satimis\\Documents/R/win-library/2.12/numDeriv/DESCRIPTION [22] C:\\Users\\satimis\\Documents/R/win-library/2.12/nws/DESCRIPTION [23] C:\\Users\\satimis\\Documents/R/win-library/2.12/rgdal/DESCRIPTION [24] C:\\Users\\satimis\\Documents/R/win-library/2.12/rgenoud/DESCRIPTION [25] C:\\Users\\satimis\\Documents/R/win-library/2.12/rlecuyer/DESCRIPTION [26] C:\\Users\\satimis\\Documents/R/win-library/2.12/rsprng/DESCRIPTION [27] C:\\Users\\satimis\\Documents/R/win-library/2.12/sem/DESCRIPTION [28] C:\\Users\\satimis\\Documents/R/win-library/2.12/shapes/DESCRIPTION [29] C:\\Users\\satimis\\Documents/R/win-library/2.12/slam/DESCRIPTION [30] C:\\Users\\satimis\\Documents/R/win-library/2.12/snow/DESCRIPTION [31] C:\\Users\\satimis\\Documents/R/win-library/2.12/snowFT/DESCRIPTION [32] C:\\Users\\satimis\\Documents/R/win-library/2.12/statmod/DESCRIPTION [33] C:\\Users\\satimis\\Documents/R/win-library/2.12/statnet/DESCRIPTION [34] C:\\Users\\satimis\\Documents/R/win-library/2.12/tripack/DESCRIPTION [35] C:\\Users\\satimis\\Documents/R/win-library/2.12/trust/DESCRIPTION [36] C:\\Users\\satimis\\Documents/R/win-library/2.12/tweedie/DESCRIPTION traceback() 5: .readPkgDesc(lib, fields) 4: installed.packages(lib.loc = lib.loc) 3: NROW(instPkgs) 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, available = available, checkBuilt = checkBuilt) 1: update.packages(repos = http://cran.r-project.org;) Enter a frame number, or 0 to exit options(error=recover) update.packages(repos=http://cran.r-project.org;) 1: update.packages(repos = http://cran.r-project.org;) 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, a 3: NROW(instPkgs) 4: installed.packages(lib.loc = lib.loc) 5: .readPkgDesc(lib, fields) Selection: 1 Called from: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, available = available, checkBuilt = checkBuilt) Browse[1] ?browser starting httpd help server ... done Browser[1] ?recover Looked at them and wondered what to do next? B.R. Stephen L - Original Message From: Martin Morgan mtmor...@fhcrc.org To: Stephen Liu sati...@yahoo.com Cc: r-help@r-project.org Sent: Mon, November 22, 2010 1:30:29 AM Subject: Re: [R] Problem on running update On 11/21/2010 03:12 AM, Stephen Liu wrote: Hi Martin, Thanks for your advice. Ran following code on R-2.12.0 32bit as admin for(lib in .libPaths()) { + descs - Sys.glob(file.path(lib, *, DESCRIPTION)) + sizes - file.info(descs)$size + names(sizes) - descs + print(sizes[sizes 100]) + } named numeric(0) named numeric(0) Where are the above files? If your problem was as a regular user, then run the above code as regular user not admin. Not sure what 'the above files' are that you are looking for; the 'named numeric(0)' says that no packages have DESCRIPTION files with size 100; the loop looked in all directories in .libPaths() for a subdirectory with file DESCRIPTION; you can find these by for instance Sys.glob(file.path(.libPaths()[1], *, DESCRIPTION)) Your next step is to identify where the
Re: [R] Fwd: Fwd: R help
Date: Sun, 21 Nov 2010 16:01:44 -0800 From: jwiley.ps...@gmail.com To: ahmedati...@gmail.com CC: r-help@r-project.org Subject: Re: [R] Fwd: Fwd: R help Dear Ahmed, Can you give a more specific example of what you want to do? Do you mean you want to test specific contrasts for a categorical variable? If you are new to R, you will find it helpful to read the Introduction to R http://cran.r-project.org/doc/manuals/R-intro.html I also recommend going through an introductory book. There are many, my personal favorite is: Introductory Statistics with R by Peter Dalgaard btw, does anyone here routinely edit stats articles for wikipedia? Many articles types have boxes or forms for properties of instance of catagories- such as atomic weights for elements. It would be nice if the wikipedia articles had standard references to notables stats packages like R but references seem inconsistent. I haven't contributed in a while and maybe this is more apropriate to bring up on wikipedia but something to consider when thinking about documentation and how to refer people on this list to intro material. In R, once you know a name you can type ?name but the hard part is often finding the name. When doc files can be downloaded locally into one place, I usually grep them for supposed keywords or just build an index of keywords. Not sure how I could do that with R but I haven't looked for a doc download enmasse that I can text process to my own liking. Cheers, Josh On Sun, Nov 21, 2010 at 3:28 PM, Ahmed Attia wrote: On 11/21/10 11:24, Ahmed Attia wrote: -- Forwarded message -- From: Ahmed Attia Date: Sun, Nov 21, 2010 at 11:06 AM Subject: R help To: r-help@r-project.org Dear All, I'm a beginner user in R and I would like to make a quadratic plus plateau and linear plus plateau modelsin R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 [snip extra signatures] -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] Making a line in a legend shorter
Hello, I am putting a legend with lines in a line plot and I would like to make the lines in the legend shorter. Does anybody knows how to do this? Thank you Felipe Parra [[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 linear plus plateau fit model
Dear R users, If you could please provide an example with the data set for the linear plus plateau model in R. I've 5 N rates and I need to make this model between N rates and grain Yield. Thanks so much Ahmed -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 [[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] Problem on running update
On 11/21/2010 05:21 PM, Stephen Liu wrote: Hi Martin, Thanks for your advice. This is my first time hunting for cause of error on R. Hi Stephen -- read the help pages ?browser, ?recover *before* trying to use the commands ... ?browser ?recover Steps performed as follows; Sys.glob(file.path(.libPaths()[1], *, DESCRIPTION)) [1] C:\\Users\\satimis\\Documents/R/win-library/2.12/Ecdat/DESCRIPTION [2] C:\\Users\\satimis\\Documents/R/win-library/2.12/RColorBrewer/DESCRIPTION [snip] [36] C:\\Users\\satimis\\Documents/R/win-library/2.12/tweedie/DESCRIPTION traceback() 5: .readPkgDesc(lib, fields) 4: installed.packages(lib.loc = lib.loc) 3: NROW(instPkgs) 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, available = available, checkBuilt = checkBuilt) 1: update.packages(repos = http://cran.r-project.org;) Enter a frame number, or 0 to exit This says that the error occurred in the .readPkgDesc function; likely one of your package 'DESCRIPTION' files is corrupt. Take a look at the source of .readPkgDesc: utils:::.readPkgDesc function (lib, fields, pkgs = list.files(lib)) { ret - matrix(NA_character_, length(pkgs), 2L + length(fields)) for (i in seq_along(pkgs)) { pkgpath - file.path(lib, pkgs[i]) if (file.access(pkgpath, 5L)) next pkgpath - file.path(pkgpath, DESCRIPTION) if (file.access(pkgpath, 4L)) next desc - tryCatch(read.dcf(pkgpath, fields = fields), error = identity) if (inherits(desc, error) || NROW(desc) 1L) { warning(gettextf(read.dcf() error on file '%s', pkgpath), domain = NA, call. = FALSE) next } desc - desc[1L, ] Rver - strsplit(strsplit(desc[Built], ;)[[1L]][1L], [ \t]+)[[1L]][2L] desc[Built] - Rver ret[i, ] - c(sub(_.*, , pkgs[i]), lib, desc) } ret[!is.na(ret[, 1L]), ] } environment: namespace:utils you'll end up somewhere in the middle of this code. The variable 'pkgs' will contain a vector of packages, and you'll likely be processing the i'th package. So provoke the error options(error=recover) update.packages(repos=http://cran.r-project.org;) and when the bug occurs 1: update.packages(repos = http://cran.r-project.org;) 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, a 3: NROW(instPkgs) 4: installed.packages(lib.loc = lib.loc) 5: .readPkgDesc(lib, fields) Selection: indicate that you'd like to enter the 5th 'Selection' Selection: 5 You should see something like Browse[1] you are 'inside' .readPkgDesc, so you can look around a little, e.g., Browse[1] pkgs Browse[1] length(pkgs) Browse[1] i Browse[1] pkgs[i] and with a little luck pkgs[i] will be the problem. It'll be located in the directory Browse[1] lib it would be helpful to look at the content of the DESCRIPTION file, to understand what is wrong Browse[1] readLines(pkgpath) If 'i' is 1 or length(pkgs) then it might pay to look around some more -- these occur at the start and end of the loop in .readPkgDesc, so you might be having problems in one of the surrounding lines. To fix this, one might quit the browser Browser[1] Q and quit recover Selection: 0 and reset how errors are handled options(error=NULL) and use remove.packages() (see ?remove.packages) to remove the problem package. Alternatively, you might find it necessary to use your operating system to manually remove the directory in which the DESCRIPTION file was found. Include the output of sessionInfo() to make sure you're using a recent version of R. Here's mine: sessionInfo() R version 2.12.0 Patched (2010-11-21 r53647) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.12.0 Martin starting httpd help server ... done Browser[1] ?recover Looked at them and wondered what to do next? B.R. Stephen L - Original Message From: Martin Morgan mtmor...@fhcrc.org To: Stephen Liu sati...@yahoo.com Cc: r-help@r-project.org Sent: Mon, November 22, 2010 1:30:29 AM Subject: Re: [R] Problem on running update On 11/21/2010 03:12 AM, Stephen Liu wrote: Hi Martin, Thanks for your advice. Ran following code on R-2.12.0 32bit as admin for(lib in .libPaths()) { + descs - Sys.glob(file.path(lib, *, DESCRIPTION)) + sizes - file.info(descs)$size + names(sizes) - descs + print(sizes[sizes 100]) + } named numeric(0) named numeric(0) Where are the above
[R] R help
Dear All, I'm a beginner user in R and I would like to make a quadratic and plateau model in R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 apply sample function to each row of a data frame?
Hey, PS, I revised your syntax and used it to another one of my data frames (df). here is the data frame: a b c A B C [1,] 1 2 3 4 5 6 [2,] 7 8 9 10 11 12 [3,] 13 14 15 16 17 18 a, b, c are type I variables A, B, C are type II variables each row represent the data from one subject my purpose is to create a new data frame in which: 1) in each row, there are one random number from type I variables, and two random numbers from type II variables 2) meanwhile, in each row, the two type II numbers have to be only those numbers that are not corresponding to the type I number. For example, if the type I number is 1, the type II numbers should not include 4. 3) type I number and type II numbers in each row should be all from the same subject. the new data frame should be like this: [,1] [,2] [,3] [1,]I IIII [2,]I IIII [3,]I IIII Here below are the revised syntax based on yours: s4-t(t(apply(df[,1:3],1,sample,1))) s5-t(apply(df[,4:6],1,sample,2)) s6-cbind(s4,s5) revised syntax works perfect except that it does not satisfy the following rule I mentioned above: 2) meanwhile, in each row, the two type II numbers have to be only those numbers that are not corresponding to the type I number. For example, if the type I number is 1, the type II numbers should not include 4. Do you know how to revise it to make it work? I tried different methods, but failed. Could you please help? Again, thanks a million -- View this message in context: http://r.789695.n4.nabble.com/Re-how-to-apply-sample-function-to-each-row-of-a-data-frame-tp3050933p3052752.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] Lost in POSIX
Can someone please fix this snippet? (i.e. append to the dataframe a column containing truncated time value)? df = structure(list(t = structure(c(1033963406.044, 1033974144.847, 1033988418.836), class = c(POSIXt, POSIXct))), .Names = t, row.names = c(NA, 3L), class = data.frame) # Try 1 df$day = trunc.POSIXt(as.POSIXlt(df$t, origin = 1970-01-01), units = day) Error in `$-.data.frame`(`*tmp*`, day, value = list(0, 0L, 0L, 7L, : replacement has 9 rows, data has 3 # Try 2 f = function(t) trunc.POSIXt(as.POSIXlt(t, origin = 1970-01-01), units = day) df$day = sapply(df$t, f) Error in `$-.data.frame`(`*tmp*`, day, value = list(sec = 0, min = 0L, : replacement has 9 rows, data has 3 -- View this message in context: http://r.789695.n4.nabble.com/Lost-in-POSIX-tp3052768p3052768.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] power spectrum of eeg
On 21/11/10 21:18, Az Ha wrote: Hi, I need to find the power spectrum of an eeg and display frequency in hz. I found two functions, spectrum or auspec but they give me frequency from 0.0 - 0.5. How do i get frequency in Hz or KHz? Also, is it possible to plot two overlapping spectra in order to compare their peaks etc? Thanks for any help. Well you you have the spectrum already, you just need to change the scale on the x-axis. The change that needs to be made is not really an R question, though how to do it is an R question. The scale used by R is cycles per unit time, where the time unit is the sampling interval of your time series. Thus the value at 0.25 say is the spectral density at 0.25 cycles per time interval, or for a period of 4 time units. To convert to Hertz, you need to know the size of your time unit in seconds. If your time unit (sampling interval) is say 1/1000 seconds (0.001 of a second), then 0.25 cycles per time interval corresponds to 1000*0.25 cycles per second, or 250 Hertz. Since kHz denotes the number of thousands of cycles per second, 250 Hz is 205/1000=0.25 Khz. Here is an example: par(mfrow = c(1,2)) w0 - 0.2 n - 100 x - cos(2*pi*w0*(0:(n-1))) specx - spec.pgram(x, plot = FALSE) spec.pgram(x) spec.pgram(x, xaxt = n, xlab = frequency (Hz), sub = paste(bandwidth = , round(1000*specx$bandwidth,2))) axis(side = 1, at = (0:5)/10, labels = 1000*(0:5)/10) David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Lost in POSIX
On Nov 21, 2010, at 3:52 PM, Dimitri Shvorob wrote: Can someone please fix this snippet? (i.e. append to the dataframe a column containing truncated time value)? df = structure(list(t = structure(c(1033963406.044, 1033974144.847, 1033988418.836), class = c(POSIXt, POSIXct))), .Names = t, row.names = c(NA, 3L), class = data.frame) df t 1 2002-10-07 00:03:26 2 2002-10-07 03:02:24 3 2002-10-07 07:00:18 df$dt - as.Date(df$t) df t dt 1 2002-10-07 00:03:26 2002-10-07 2 2002-10-07 03:02:24 2002-10-07 3 2002-10-07 07:00:18 2002-10-07 # Try 1 df$day = trunc.POSIXt(as.POSIXlt(df$t, origin = 1970-01-01), units = day) Error in `$-.data.frame`(`*tmp*`, day, value = list(0, 0L, 0L, 7L, : replacement has 9 rows, data has 3 # Try 2 f = function(t) trunc.POSIXt(as.POSIXlt(t, origin = 1970-01-01), units = day) df$day = sapply(df$t, f) Error in `$-.data.frame`(`*tmp*`, day, value = list(sec = 0, min = 0L, : replacement has 9 rows, data has 3 -- View this message in context: http://r.789695.n4.nabble.com/Lost-in-POSIX-tp3052768p3052768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD 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] need smooth cdf lines
Hi, I would like to overlap the cdf curve for observed and generated data Here is my code: plot(cdf,main =CDF of the sum for winter season-Hume,cex.axis=1.2,xlab=Rainfall (mm), xaxs=i,yaxs=i,col=c(black,red), lty=c(1,1),ylab=Cumulative probability, xlim=c(0,800),lwd=1) lines(ecdf(datobs)) legend(topright, legend = c(observed,fitted), col = c(black,red), pch=c(NA,NA), lty = c(1, 1), lwd=c(3,3),bty=n, pt.cex=2) It gives me the plots but it is not smooth. How do I adjust so that I will get two smooth cumulative density curves. Thank you for any help given. [[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] need smooth cdf lines
Ah, this looks like Australian data :) One simple way would be to use the lowess function and fiddle with the f parameter (like bandwidth). Michael On 22 November 2010 14:18, Roslina Zakaria zrosl...@yahoo.com wrote: Hi, I would like to overlap the cdf curve for observed and generated data Here is my code: plot(cdf,main =CDF of the sum for winter season-Hume,cex.axis=1.2,xlab=Rainfall (mm), xaxs=i,yaxs=i,col=c(black,red), lty=c(1,1),ylab=Cumulative probability, xlim=c(0,800),lwd=1) lines(ecdf(datobs)) legend(topright, legend = c(observed,fitted), col = c(black,red), pch=c(NA,NA), lty = c(1, 1), lwd=c(3,3),bty=n, pt.cex=2) It gives me the plots but it is not smooth. How do I adjust so that I will get two smooth cumulative density curves. Thank you for any help given. [[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 help
Hi Ahmed, Does 'quadratic plateau' model refer to a chage-point or bent-cable regression with quadratic on one side and an asymptote on the other ? If so, you might like to look at the bentcableAR package. There is a background article here: http://faculty.washington.edu/gchiu/Articles/bentcable-jasa.pdf Michael On 22 November 2010 06:06, Ahmed Attia ahmedati...@gmail.com wrote: Dear All, I'm a beginner user in R and I would like to make a quadratic and plateau model in R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 help
Sorry, chage-point should be change-point On 22 November 2010 14:44, Michael Bedward michael.bedw...@gmail.com wrote: Hi Ahmed, Does 'quadratic plateau' model refer to a chage-point or bent-cable regression with quadratic on one side and an asymptote on the other ? If so, you might like to look at the bentcableAR package. There is a background article here: http://faculty.washington.edu/gchiu/Articles/bentcable-jasa.pdf Michael On 22 November 2010 06:06, Ahmed Attia ahmedati...@gmail.com wrote: Dear All, I'm a beginner user in R and I would like to make a quadratic and plateau model in R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem on running update
Hi Martin, Sorry I can't fix the update problem. Reading ?browser and ?recover didn't help me out. Finally I uninstalled R, 32/64 bit and RExcel and made a fresh installation of them. Remark: I need to remove all folders with connection to them. Otherwise after installing R, RExcel, rcom, statconnDCOM, R-commander, etc. I still encountered the same problem. After reinstalling above packages ran R as admin, update.packages() --- Please select a CRAN mirror for use in this session --- cluster : Version 1.13.1 installed in C:/PROGRA~1/R/R-212~1.0/library Version 1.13.2 available at http://cran.ms.unimelb.edu.au Update (y/N/c)? y codetools : Version 0.2-2 installed in C:/PROGRA~1/R/R-212~1.0/library Version 0.2-5 available at http://cran.ms.unimelb.edu.au Update (y/N/c)? y Matrix : Version 0.999375-44 installed in C:/PROGRA~1/R/R-212~1.0/library Version 0.999375-45 available at http://cran.ms.unimelb.edu.au Update (y/N/c)? y mgcv : Version 1.6-2 installed in C:/PROGRA~1/R/R-212~1.0/library Version 1.7-2 available at http://cran.ms.unimelb.edu.au Update (y/N/c)? y rpart : Version 3.1-46 installed in C:/PROGRA~1/R/R-212~1.0/library Version 3.1-47 available at http://cran.ms.unimelb.edu.au Update (y/N/c)? y survival : Version 2.35-8 installed in C:/PROGRA~1/R/R-212~1.0/library Version 2.36-1 available at http://cran.ms.unimelb.edu.au Update (y/N/c)? y trying URL 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/cluster_1.13.2.zip' Content type 'application/zip' length 370152 bytes (361 Kb) opened URL downloaded 361 Kb trying URL 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/codetools_0.2-5.zip' Content type 'application/zip' length 42584 bytes (41 Kb) opened URL downloaded 41 Kb trying URL 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/Matrix_0.999375-45.zip' Content type 'application/zip' length 3224889 bytes (3.1 Mb) opened URL downloaded 3.1 Mb trying URL 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/mgcv_1.7-2.zip' Content type 'application/zip' length 894436 bytes (873 Kb) opened URL downloaded 873 Kb trying URL 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/rpart_3.1-47.zip' Content type 'application/zip' length 191611 bytes (187 Kb) opened URL downloaded 187 Kb trying URL 'http://cran.ms.unimelb.edu.au/bin/windows/contrib/2.12/survival_2.36-1.zip' Content type 'application/zip' length 2619051 bytes (2.5 Mb) opened URL downloaded 2.5 Mb package 'cluster' successfully unpacked and MD5 sums checked package 'codetools' successfully unpacked and MD5 sums checked package 'Matrix' successfully unpacked and MD5 sums checked package 'mgcv' successfully unpacked and MD5 sums checked package 'rpart' successfully unpacked and MD5 sums checked package 'survival' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Users\satimiswin764\AppData\Local\Temp\RtmpM8LYDq\downloaded_packages Update is now working. Lot of thanks for your detail advice and time spent. B.R. Stephen L - Original Message From: Martin Morgan mtmor...@fhcrc.org To: Stephen Liu sati...@yahoo.com Cc: r-help@r-project.org Sent: Mon, November 22, 2010 10:55:20 AM Subject: Re: [R] Problem on running update On 11/21/2010 05:21 PM, Stephen Liu wrote: Hi Martin, Thanks for your advice. This is my first time hunting for cause of error on R. Hi Stephen -- read the help pages ?browser, ?recover *before* trying to use the commands ... ?browser ?recover Steps performed as follows; Sys.glob(file.path(.libPaths()[1], *, DESCRIPTION)) [1] C:\\Users\\satimis\\Documents/R/win-library/2.12/Ecdat/DESCRIPTION [2] C:\\Users\\satimis\\Documents/R/win-library/2.12/RColorBrewer/DESCRIPTION [snip] [36] C:\\Users\\satimis\\Documents/R/win-library/2.12/tweedie/DESCRIPTION traceback() 5: .readPkgDesc(lib, fields) 4: installed.packages(lib.loc = lib.loc) 3: NROW(instPkgs) 2: old.packages(lib.loc = lib.loc, contriburl = contriburl, method = method, available = available, checkBuilt = checkBuilt) 1: update.packages(repos = http://cran.r-project.org;) Enter a frame number, or 0 to exit This says that the error occurred in the .readPkgDesc function; likely one of your package 'DESCRIPTION' files is corrupt. Take a look at the source of .readPkgDesc: utils:::.readPkgDesc function (lib, fields, pkgs = list.files(lib)) { ret - matrix(NA_character_, length(pkgs), 2L + length(fields)) for (i in seq_along(pkgs)) { pkgpath - file.path(lib, pkgs[i]) if (file.access(pkgpath, 5L)) next pkgpath - file.path(pkgpath, DESCRIPTION) if (file.access(pkgpath, 4L)) next desc - tryCatch(read.dcf(pkgpath, fields = fields), error = identity) if (inherits(desc, error) || NROW(desc) 1L) { warning(gettextf(read.dcf() error on file '%s', pkgpath), domain = NA,
[R] Problems using Internal filledcontour: dimension mismatch
In order to gain a bit more control over the fill contour functionality I'm trying to use the Internal filledcontour function. I wasn't able any documentation on this function and only one reference to it. I believe the code shown below is close because all the dimensions seem to be correct, but I'm still getting a dimension mismatch error and the filled contour doesn't occur. Here is a listing of the actual dimensions: length(ak.fan$y) [1] 40 dim(ak.fan$y) NULL length(ak.fan$y) [1] 40 length(ak.fan$x) [1] 40 dim(ak.fan$z) [1] 40 40 length(lev.sd.vol) [1] 5 length(color_vals_green_to_yellow_to_red) [1] 20 Note that I did try to use terrain.colors, but that also seemed to produce the same error. I also replaced all the NA values hoping that would help work around this error. I'm kind of coming to the end of my guesses about how to work around this error, so any feedback and advice is greatly appreciated. library(akima) hyp_distance-seq(1,15) angle_deg_val-seq(0,15) x_distance_val-NULL y_distance_val-NULL for(ii in 1:length(hyp_distance)) { for(jj in 1:length(angle_deg_val)) { x_distance_tmp-hyp_distance[ii]*cos(angle_deg_val[jj]*pi/180) y_distance_tmp-hyp_distance[ii]*sin(angle_deg_val[jj]*pi/180) x_distance_val-c(x_distance_val, x_distance_tmp) y_distance_val-c(y_distance_val, y_distance_tmp) } } temperature_vals-rnorm(length(x_distance_val), 75, 2) temp_samples-cbind(x_distance_val, y_distance_val, temperature_vals) temp_samples_DF-data.frame(x = x_distance_val, y = y_distance_val, z = temperature_vals) ak.fan - interp(temp_samples[,1], temp_samples[,2], temp_samples[,3] ) ak.fan.original-ak.fan # Get rid of all the NA values and replace with zero values... ak.fan$z[which(is.na(ak.fan$z))]-0.0 length_val-floor(max(temperature_vals) - min(temperature_vals))*2 color_vals_red_to_yellow_to_green-colorRampPalette(c(red, yellow, green), space=Lab)(length_val) color_vals_green_to_yellow_to_red-colorRampPalette(c(green, yellow, red), space=Lab)(length_val) plot(1,1, col = 0, xlim = c(min(x_distance_val), max(x_distance_val)), ylim = c(min(y_distance_val), max(y_distance_val)), xlab = Room X Position (FT), ylab = Room Y Position (FT), main = Room Temp vs Position) grid() # filled.contour(ak.fan, col = color_vals_red_to_yellow_to_green) # filled.contour(ak.fan, col = color_vals_green_to_yellow_to_red) lev.sd.vol - pretty(range(na.omit(unique(as.numeric(ak.fan$z, 4) .Internal(filledcontour(as.double(ak.fan$y), as.double(ak.fan$x), as.double(ak.fan$z), as.double(lev.sd.vol), col = color_vals_green_to_yellow_to_red)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot vs print ??
2010/11/20 Uwe Ligges lig...@statistik.tu-dortmund.de: On 18.11.2010 11:30, skan wrote: Hello everybody. My question arised from the output of lattice's histogram. But might be extended to any other object that could be printed. I think I've understood your answers, print calls the plot function when the object to be printed is a trellis plot object. I guess I can always use plot instead. ?? No, you really need to print() lattice objects. Actually no; plot() would do as well. My view is that plot() is the more obvious method for plotting a trellis object, and print() is an alias that is useful (only) because of the auto-printing rule. (Note that this applies only to lattice, not Trellis in S-PLUS) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R help
Hi Ahmed, Please reply via the list - you'll get better answers because most people there know more than me :) Here is a toy example that is similar to the example graph you sent me... # generate data: linear up to a change point, then plateau with constant std dev x - 20:70 y - rnorm(length(x), c(20:50 * 2, rep(100, 20)), 10) plot(x, y) library(segmented) # naive linear regression y.lm - lm(y ~ x) # convert to segmented (chage-point) regression with # initial change-point (psi) deliberately away from # known cp in artificial data y.seg - segmented(y.lm, seg.Z=~x, psi=40) Results are: Call: segmented.lm(obj = y.lm, seg.Z = ~x, psi = 40) Meaningful coefficients of the linear terms: (Intercept)x U1.x 11.0061.684 -1.688 Estimated Break-Point(s) psi1.x : 51.4 There is an article about the segmented package in Rnews vol 8/1: http://cran.r-project.org/doc/Rnews/Rnews_2008-1.pdf Hope this helps. Michael On 22 November 2010 15:03, Ahmed Attia ahmedati...@gmail.com wrote: Hi Dr Michael, Attached is an example for the linear plus plateua model but in SAS, this exactly what I need to do in R. Ahmed On Sun, Nov 21, 2010 at 7:44 PM, Michael Bedward michael.bedw...@gmail.com wrote: Hi Ahmed, Does 'quadratic plateau' model refer to a chage-point or bent-cable regression with quadratic on one side and an asymptote on the other ? If so, you might like to look at the bentcableAR package. There is a background article here: http://faculty.washington.edu/gchiu/Articles/bentcable-jasa.pdf Michael On 22 November 2010 06:06, Ahmed Attia ahmedati...@gmail.com wrote: Dear All, I'm a beginner user in R and I would like to make a quadratic and plateau model in R. Can you help please with an example? Thanks so much -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ahmed M. Attia Assistant Lecturer El-Khattara farm Station Agronomy Dept., Zgazig Univ., Egypt Visiting Scientist Haskell Agricultural laboratory Agronomy and Horticultural Dept., Univ. of Nebraska-Lincoln ahmeda...@zu.edu.eg aattiamoham...@unlnotes.unl.edu Cell phone: 4023604178 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Splitting 3D matrix from for loop to generate/save 2D matrices
Hi! I have a matrix called M with dimension (586,100,100). I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l-dim(M)[1] for (i in (1:l)){ save(M[i,,],file = M_[i].img) } Can somebody help me with this? Thanks! Hana Lee [[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] Splitting 3D matrix from for loop to generate/save 2D matrices
Hi, On Sun, Nov 21, 2010 at 9:27 PM, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). First of all, In R it is only an object with *two* dimensions that is called matrix. Anything with two or more dimensions is called an array. Example: x - 1:(2*3*4) y - matrix(x, ncol=2) z - array(x, dim=c(2,3,4)) # VECTORS is.vector(x) [1] TRUE is.vector(y) [1] FALSE is.vector(z) [1] FALSE # MATRICES is.matrix(x) [1] FALSE is.matrix(y) [1] TRUE is.matrix(z) [1] FALSE # ARRAYS is.array(x) [1] FALSE is.array(y) [1] TRUE is.array(z) [1] TRUE So, you've got an *array* (not a matrix). I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l-dim(M)[1] for (i in (1:l)){ save(M[i,,],file = M_[i].img) } ...but couldn't get it work [as I wanted]. The problem you have is generate a unique filename for matrix. The following two lines generate the same filename: filename - sprintf(M_%d.img, i); filename - paste(M_, i, .img, sep=); I prefer to use the sprintf() version. So, l - dim(M)[1] for (i in (1:l)) { filename - sprintf(M_%d.img, i); save(M[i,,], file=filename); } My $.02 /Henrik Can somebody help me with this? Thanks! Hana Lee [[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] Splitting 3D matrix from for loop to generate/save 2D matrices
Hi Hana, Use the paste function to create your file names. for ( i in 1:dim(M)[1] ) save( M[i,,], file=paste(M_, i, .img, sep=) ) Alternatively, use the sprintf function to get names with leading zeroes for easier sorting of files: for (i in 1:dim(M)[1] ) save( M[i,,], file=sprintf(M_%03d.img, i) ) Michael On 22 November 2010 16:27, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l-dim(M)[1] for (i in (1:l)){ save(M[i,,],file = M_[i].img) } Can somebody help me with this? Thanks! Hana Lee [[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] Splitting 3D matrix from for loop to generate/save 2D matrices
Sorry, I did a mistake corrected below. On Sun, Nov 21, 2010 at 9:50 PM, hb h...@biostat.ucsf.edu wrote: Hi, On Sun, Nov 21, 2010 at 9:27 PM, Hana Lee hana...@email.unc.edu wrote: Hi! I have a matrix called M with dimension (586,100,100). First of all, In R it is only an object with *two* dimensions that is called matrix. Anything with two or more dimensions is called an array. Example: x - 1:(2*3*4) y - matrix(x, ncol=2) z - array(x, dim=c(2,3,4)) # VECTORS is.vector(x) [1] TRUE is.vector(y) [1] FALSE is.vector(z) [1] FALSE # MATRICES is.matrix(x) [1] FALSE is.matrix(y) [1] TRUE is.matrix(z) [1] FALSE # ARRAYS is.array(x) [1] FALSE is.array(y) [1] TRUE is.array(z) [1] TRUE So, you've got an *array* (not a matrix). I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l-dim(M)[1] for (i in (1:l)){ save(M[i,,],file = M_[i].img) } ...but couldn't get it work [as I wanted]. Indeed save(M[i,,], ...) will throw an error. You also need to subset to a temporary variable, e.g. X - M[i,,], and save that. See below. The problem you have is generate a unique filename for matrix. The following two lines generate the same filename: filename - sprintf(M_%d.img, i); filename - paste(M_, i, .img, sep=); I prefer to use the sprintf() version. So, l - dim(M)[1] for (i in (1:l)) { filename - sprintf(M_%d.img, i); save(M[i,,], file=filename); } l - dim(M)[1] for (i in (1:l)) { filename - sprintf(M_%d.img, i); X - M[i,,]; save(X, file=filename); } Note that this will load the data into a variable called 'X' when you load() one of the files. If you do not want to have to worry about the name you can use: library(R.utils); l - dim(M)[1]; for (i in (1:l)) { filename - sprintf(M_%d.img, i); saveObject(M[i,,], file=filename); } and later load the object into any variable you with: filename - M_32.img; Z - loadObject(filename); /H My $.02 /Henrik Can somebody help me with this? Thanks! Hana Lee [[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] power spectrum of eeg
David Scott-6 wrote: On 21/11/10 21:18, Az Ha wrote: Hi, I need to find the power spectrum of an eeg and display frequency in hz. I found two functions, spectrum or auspec but they give me frequency from 0.0 - 0.5. How do i get frequency in Hz or KHz? Also, is it possible to plot two overlapping spectra in order to compare their peaks etc? Thanks for any help. Well you you have the spectrum already, you just need to change the scale on the x-axis. The change that needs to be made is not really an R question, though how to do it is an R question. The scale used by R is cycles per unit time, where the time unit is the sampling interval of your time series. Thus the value at 0.25 say is the spectral density at 0.25 cycles per time interval, or for a period of 4 time units. To convert to Hertz, you need to know the size of your time unit in seconds. If your time unit (sampling interval) is say 1/1000 seconds (0.001 of a second), then 0.25 cycles per time interval corresponds to 1000*0.25 cycles per second, or 250 Hertz. Since kHz denotes the number of thousands of cycles per second, 250 Hz is 205/1000=0.25 Khz. Here is an example: par(mfrow = c(1,2)) w0 - 0.2 n - 100 x - cos(2*pi*w0*(0:(n-1))) specx - spec.pgram(x, plot = FALSE) spec.pgram(x) spec.pgram(x, xaxt = n, xlab = frequency (Hz), sub = paste(bandwidth = , round(1000*specx$bandwidth,2))) axis(side = 1, at = (0:5)/10, labels = 1000*(0:5)/10) David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email:d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thanks David for explaining this, I got it to work the way i wanted. Meantime i found another function meanspec (package seewave), in which I can directly input the sampling frequency (in my case 4800Hz), which is lot easier to work with. But it gives me Y-axis in amplitude. Can someone explain me how amplitude in meanspec compares to spectrum in spectrum? My aim in doing all this is to compare two different eeg signal peaks to see which has greater power. Thanks again. -- View this message in context: http://r.789695.n4.nabble.com/power-spectrum-of-eeg-tp3052195p3053104.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] Splitting 3D matrix from for loop to generate/save 2D matrices
On Nov 22, 2010, at 12:27 AM, Hana Lee wrote: Hi! I have a matrix called M with dimension (586,100,100). In R you have an array (not a matrix) wehn the number of dimensions is 3. I would like to split and save this into 586 matrices with dimension 100 by 100. I have tried the following for loops but couldn't get it work.. l-dim(M)[1] for (i in (1:l)){ save(M[i,,], I think the save function needs a name rather than an object for evaluation. Also it's not a representation that will be particularly useful outside the context of R. file = M_[i].img) # the R interpreter is not going to evaluate those i's inside quotes, no matter how smart you think it is. } Maybe (with some hesitation about the advisability of this): l-dim(M)[1] for (i in (1:l)){ temp - M[i,,] save(temp, file = paste(M_,i,.img, sep=) } When these get load()-ed back in, they will each have the have temp, so if you read in more than one, only the last one will remain. It might make more sense to write them out as a group and read them back in the same way. Can somebody help me with this? Thanks! Hana Lee [[alternative HTML version deleted]] -- 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] plot start at origin
Hi r-users, I would like my axes to intersect at (0,0). I tried xaxs=i,yaxs=i but it does not change anything. I hope anybody can help me with this problem. Here is my code. hist(datobs, prob=TRUE, main =PDF of the sum of two stations,col=yellowgreen, cex.axis=1.2, xlab=Rainfall (mm), ylab=Relative frequency, ylim= c(0,.008), xlim=c(0,600),xaxs=i,yaxs=i) lines(density(dd), lwd=3,col=red) legend(topright, legend = c(observed,fitted), col = c(yellowgreen, red), pch=c(15,NA), lty = c(0, 1), lwd=c(0,3),bty=n, pt.cex=2) box() 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] How to combine Date and time in one column
Hello everyone, I am trying to built an xts object and i have run into some problems on the data handling. I would really appreciate if someone could help me with the following: 1) I have a OHLC dataset with Time and date in different columns. How could i combine date and time in one column in order to pass on the new column to xts? I have use cbind and data.frame before but i did not manage to yield any good results as the formating of the file changes. DateTime OH L C 1/2/200517:05 1.3546 1.3553 1.3546 1.35495 1/2/200517:10 1.3553 1.3556 1.3549 1.35525 1/2/200517:15 1.3556 1.35565 1.35515 1.3553 1/2/200517:25 1.3551.3556 1.355 1.3555 1/2/200517:30 1.3556 1.3564 1.35535 1.3563 2) It is not clear to me what is the best way to construct the .xts object? Should i use only the Datetime to index or should i also combine it with the rest of the variables? Thanks in advance, N -- View this message in context: http://r.789695.n4.nabble.com/How-to-combine-Date-and-time-in-one-column-tp3053155p3053155.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.
Re: [R] Rlanguage plr and loadiing climatol package
Thank to everybody that helped. I have a working bit of code :-) On Nov 20, 2010, at 3:25 PM, David Potts wrote: Hi List I am trying to call the R library function rosavent from the climatol package via the plr interface package to the postgres database. My code is a follows create or replace function w_graph() returns text as ' str - pg.spi.exec(select n,nne,ne,ene,e,ese,se,sse,s,ssw,sw,wsw,w,wnw,nw,nnw from wdata); pdf(/tmp/foobar.pdf); rosavent(str,4,4,ang=-3*pi/16,main=Annual windrose) dev.off(); print(Done); ' LANGUAGE plr; When invoked it gives the error # select w_graph(); ERROR: R interpreter expression evaluation error DETAIL: Error in PLR7843132 - function() { : could not find function rosavent CONTEXT: In PL/R function w_graph I assume this means it can not find the rosavent function from the climatol package. I have loaded the climatol package using the following syntax install.packages(climatol,lib=/home/dfuncs/r-lang/my-rlib) I'm not sure if not having loaded climatol is the source of your problem, but if it is, you have forgotten to load the package after installing it. Perhaps: require(climatol) # before the pdf(...) call I assume that the an R process created by the plr interface will load a library, does any body know how I tell it to load it? This page: http://www.varlena.com/GeneralBits/Tidbits/bernier/art13mar04/graphingWithR.html makes me thing that PL/R passes r code pg.spi.exec (... calls. Does it matter that the illustration on that page uses str- pg.spi.exec ( rahter than str- ? (This would seem to be the wrong place to be asking these questions. There are websites set up to mediate conversations between PL/R users.) -- David Winsemius, MD West Hartford, CT Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Pinan Software __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.