Re: [R] replace double backslash with singel backslash
Thanks, that helped! Yours, Kay Zitat von Gene Leynes gleyne...@gmail.com: I think that people are afraid to say You can't do that in R... But I think the real answer is: you can't do that in R. Although, it is helpful to understand Jeff's reply. I hadn't fully realized why this particular problem occurs before reading that. It's odd to me that // and / are both stored as /, but that makes sense given my experience in R. Also, the other replies are good advice, working with R's path functions or sticking with forward slashes is the way to go (don't fight the assimilation, the borg needs you). Personally, I think some of these seemingly small problems actually encumber R's mainstream adoption quite a bit, but then I'm not the one writing R. Plus, it's is still pretty dang awesome even with its minor annoyances. On Fri, Nov 4, 2011 at 8:45 AM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote: Your str does not have any double backslashes to replace. You need to revisit the concept of escape characters in the documentation. In brief, every \\ in a quoted string is actually a single character as stored in memory. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Kay Cichini kay.cich...@uibk.ac.at wrote: I want to replace \\ with \ in: str - C:\\DOKUME~1\\u0327336\\LOKALE~1\\Temp\\RtmpQ5NJ8X\\TIRIS_PICS\\1_Img.jpg and tried: gsub(, \\, str) but this removes the \\ without replacing them by \ Any help much appreciated, Kay - Kay Cichini Postgraduate student Institute of Botany Univ. of Innsbruck -- View this message in context: http://r.789695.n4.nabble.com/replace-double-backslash-with-singel-backslash-tp3989434p3989434.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. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Min Frequency in findFreqTerms
I am using 'tm' package for text mining. I use the function findFreqTerms to obtain the frequent words based on their frequency in the term document matrix. The following is the example given in the help page of this function: library(tm) data(crude) tdm - TermDocumentMatrix(crude) findFreqTerms(tdm, 2, 3) The first three columns of the document term matrix are shown below: (bpd) (bpd). (gcc) 0 0 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 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 The first term (bpd) has a frequency of 3 whereas the second and third terms have a frequency of 1 which is below the lowfreq = 2 specified. Can someone help me whether this is the right way of interpreting this function??? If so, is there a bug in the package?? Thank you. Ravi -- View this message in context: http://r.789695.n4.nabble.com/Min-Frequency-in-findFreqTerms-tp4019143p4019143.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] Opening excel CSV file in R
On 09.11.2011 04:42, Dan Zhou wrote: Hi, So I have everything written out. I used R-studio (same as R console but with an IDE) and I had no trouble calling upon and opening the csv file for computation. However, when I try to run my code in plain old R, it says that the file could not be located. Heres my code: func- function(filename, int) { Data- read.csv(sample.csv, header = TRUE) attach(Data, warn.conflicts = FALSE) ... .. } I made sure that sample file was in the same directory. Which same directory? Have you checked getwd() before running func()? I even tried inputting the entire file location C:\Users... But hopefully not that way. You need to escape backslahes as in c:\\Users or, much easiest, use forwward slahes. See the R for Windows FAQs. Uwe Ligges Please help. Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Are there equivalents to xblocks or rect that can be used with plot.xts?
I would like to add vertical shaded blocks in plot.xts graphs (like recession periods in FRED graphs) The reason I use plot.xts instead of plot.zoo is that I like the fact that the grid is automatically aligned with major ticks in plot.xts. xblocks() and rect() do not seem to work with plot.xts (only with plot.zoo). Are there any alternative methods that work with plot.xts? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Are-there-equivalents-to-xblocks-or-rect-that-can-be-used-with-plot-xts-tp4019191p4019191.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] VAR and VECM in multivariate time series
Hi, Please read Time series Econometrics books and you will find out that acf and pacf are not to be used to determine whether or not a series is stationary. The question of nonstationarity or stationarity of a series is answered using the formal tests comprising ADF, PP, KPSS, etc. I will let someone else (and I know that there is at least one such expert) deal with your question on VAR and tsDyn. Lexi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of cloris Sent: Sunday, November 06, 2011 5:25 PM To: r-help@r-project.org Subject: [R] VAR and VECM in multivariate time series Hello to everyone! I am working on my final year project about multivariate time series. There are three variables in the multivariate time series model. I have a few questions: 1. I used acf and pacf plot and find my variables are nonstationary. But in adf.test() and pp.test(), the data are stationary. why? 2.I use VAR to get a model. y is the matrix of data set and I have made a once difference of it to make it stationary. library(tsDyn) VARselect(y,lag.max=20,type=const,season = NULL, exogen = NULL) y1=VAR(y, p = 16, type = c(const), season = NULL, exogen = NULL, lag.max = NULL,ic = c(AIC)) summary(y1) plot(y1) How can I get estimation of AIC in this model? 3. I also get a VECM model v1=VECM(y, lag=16,beta=NULL, estim=ML) what does ETC mean in the output? and what is a number of cointegrating relationships? I want to make forecast by VECM. j=ca.jo(y,K=16,type='trace',season = NULL) j.var=vec2var(j) predict(j.var,n.ahead=80) Is this a correct way to predict VECM in R? Could anyone help me? Thank you very much -- View this message in context: http://r.789695.n4.nabble.com/VAR-and-VECM-in-multivariate-time-series-t p3995951p3995951.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. DISCLAIMER:\ Sample Disclaimer added in a VBScript.\ ...{{dropped:3}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Installing binaries from R-Forge
Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R... It later says To install this package directly within R type: install.packages(splm, repos=http://R-Forge.R-project.org;). I just installed R-2.14 and I still get the following error message. Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available (for R version 2.14.0) Can someone please help? I understand that there is relevant information in the posting guide, but I'm not a programmer and it's difficult for me to understand. I thought I've followed the advice from previous posts (notably, upgrade). Thank you, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Are there equivalents to xblocks or rect that can be used with plot.xts?
On Wed, Nov 9, 2011 at 4:33 AM, thierrydb thierr...@gmail.com wrote: I would like to add vertical shaded blocks in plot.xts graphs (like recession periods in FRED graphs) The reason I use plot.xts instead of plot.zoo is that I like the fact that the grid is automatically aligned with major ticks in plot.xts. xblocks() and rect() do not seem to work with plot.xts (only with plot.zoo). Are there any alternative methods that work with plot.xts? Just suppress one or both axes and then draw them with their grid in exactly the same way that you would in R classic graphics. Its only one or two extra statements depending on whether you want one or both: library(zoo) z - zooreg(1:25, Sys.Date()) plot(z, type = o, xaxt = n, yaxt = n) abline(v = Axis(time(z), side = 1), lty = 2, col = grey(.5)) # X abline(h = Axis(coredata(z), side = 2), lty = 2, col = grey(.5)) # Y -- 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.
[R] Problem with simple random slope in gam and bam (mgcv package)
Dear useRs, This is the first time I post to this list and I would appreciate any help available. I've used the excellent mgcv package for a while now to investigate geographical patterns of language variation, and it has has always worked without any problems for me. The problem below occurs using R 2.14.0 (both 32 and 64 bit versions in Windows and the 64 bit version in Unix) and mgcv (both version 1.7-10 and 1.7-6). In my (simplified) model predicting pronunciation distance I'd like to include a random slope per Participant for a binary value (IsDem) which stores a word-specific characteristic. I load the data (available at http://www.martijnwieling.nl/dat.csv) and run the model as follows: library(mgcv) # version 1.7-10, but problem also occurs with earlier versions (e.g., 1.7-6) dat = read.csv('dat.csv',header=T) # data available at: http://www.martijnwieling.nl/dat.csv dim(dat) # the original dataset is larger, but the problem also occurs in this subset [1] 2 4 model = bam(PronDist ~ s(Participant,IsDem,bs=re), data=dat) print(model) # works fine summary(model, freq=T) # works fine summary(model) # the Bayesian p-value estimation does not work: Error in eigen(B, symmetric = TRUE) : infinite or missing values in 'x' I obviously am interested in more complex models, but whenever I include any binary value as a by-word or by-participant random slope I get the same error. I've tried to locate the error and it appears to occur in the function pinvXVX in the block which 'deals with the fractional part of the pinv'. Any help would be appreciated! With kind regards, Martijn Wieling University of Groningen http://www.martijnwieling.nl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] GAM
Kilometres has only 5 unique values, while Bonus has only 7, but the default smoothing basis dimension for the s terms is 10, so there is a problem. Solution is to reduce the basis dimension. e.g. amgam - gam(log(Payment) ~ offset(log(Insured))+ + s(as.numeric(Kilometres),k=5) + s(Bonus,k=7) + Make + s(Claims),family = gaussian, + data = motori) On 08/11/11 16:57, Gyanendra Pokharel wrote: Hi R community! I am analyzing the data set motorins in the package faraway by using the generalized additive model. it shows the following error. Can some one suggest me the right way? library(faraway) data(motorins) motori- motorins[motorins$Zone==1,] library(mgcv) amgam- gam(log(Payment) ~ offset(log(Insured))+ s(as.numeric(Kilometres)) + s(Bonus) + Make + s(Claims),family = gaussian, data = motori) Error in smooth.construct.tp.smooth. spec(object, dk$data, dk$knots) : A term has fewer unique covariate combinations than specified maximum degrees of freedom summary(amgam) Error in summary(amgam) : object 'amgam' not found Gyan [[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. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] GAM
On 11/08/2011 11:57 AM, Gyanendra Pokharel wrote: Hi R community! I am analyzing the data set motorins in the package faraway by using the generalized additive model. it shows the following error. Can some one suggest me the right way? library(faraway) data(motorins) motori- motorins[motorins$Zone==1,] library(mgcv) amgam- gam(log(Payment) ~ offset(log(Insured))+ s(as.numeric(Kilometres)) + s(Bonus) + Make + s(Claims),family = gaussian, data = motori) Error in smooth.construct.tp.smooth. spec(object, dk$data, dk$knots) : A term has fewer unique covariate combinations than specified maximum degrees of freedom Just to provide further information, table(motori$Kilometres) 1 2 3 4 5 61 63 60 57 54 Kilometres only has 5 unique values; this complicates the issue of estimating a curve, as you only have 5 points to work with. Likewise, Bonus only has 7 unique values. Claims does not pose any problem, as it has 98 unique values. As Jean suggested, you can get around this issue with: amgam- gam(log(Payment) ~ offset(log(Insured)) + s(as.numeric(Kilometres),k=5) + s(Bonus,k=7) + Make + s(Claims),family = gaussian, data = motori) -- Patrick Breheny Assistant Professor Department of Biostatistics Department of Statistics University of Kentucky __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with simple random slope in gam and bam (mgcv package)
Martijn, Thanks for this. It's a bug. The p-value computation involves model matrices for each `smooth' term (in your case actually a random effect). When the data set is large, then random sub-sampling of the data is used to keep the computational cost of these model matrices down. This is ok for continuous predictors, but in the case of factor predictors, used in re terms, it can fail to pick up some levels of the factor and consequently fail due to rank deficiency This possibility had not previously occurred to me. I'll work out a fix... best, Simon On 09/11/11 12:41, Martijn Wieling wrote: Dear useRs, This is the first time I post to this list and I would appreciate any help available. I've used the excellent mgcv package for a while now to investigate geographical patterns of language variation, and it has has always worked without any problems for me. The problem below occurs using R 2.14.0 (both 32 and 64 bit versions in Windows and the 64 bit version in Unix) and mgcv (both version 1.7-10 and 1.7-6). In my (simplified) model predicting pronunciation distance I'd like to include a random slope per Participant for a binary value (IsDem) which stores a word-specific characteristic. I load the data (available at http://www.martijnwieling.nl/dat.csv) and run the model as follows: library(mgcv) # version 1.7-10, but problem also occurs with earlier versions (e.g., 1.7-6) dat = read.csv('dat.csv',header=T) # data available at: http://www.martijnwieling.nl/dat.csv dim(dat) # the original dataset is larger, but the problem also occurs in this subset [1] 2 4 model = bam(PronDist ~ s(Participant,IsDem,bs=re), data=dat) print(model) # works fine summary(model, freq=T) # works fine summary(model) # the Bayesian p-value estimation does not work: Error in eigen(B, symmetric = TRUE) : infinite or missing values in 'x' I obviously am interested in more complex models, but whenever I include any binary value as a by-word or by-participant random slope I get the same error. I've tried to locate the error and it appears to occur in the function pinvXVX in the block which 'deals with the fractional part of the pinv'. Any help would be appreciated! With kind regards, Martijn Wieling University of Groningen http://www.martijnwieling.nl __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simon Wood, Mathematical Science, University of Bath BA2 7AY UK +44 (0)1225 386603 http://people.bath.ac.uk/sw283 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing binaries from R-Forge
The Windows binary seems not to be there. Since this is a development platform and there may be various reasons a binary does currently not exist, you could install the package from source, just add the argument type=source in your call to install.packages(). How to prepare your environment to allow to install source packages is described in the R Installation and Administration manual. Uwe Ligges On 09.11.2011 13:39, Downey, Patrick wrote: Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R... It later says To install this package directly within R type: install.packages(splm, repos=http://R-Forge.R-project.org;). I just installed R-2.14 and I still get the following error message. Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available (for R version 2.14.0) Can someone please help? I understand that there is relevant information in the posting guide, but I'm not a programmer and it's difficult for me to understand. I thought I've followed the advice from previous posts (notably, upgrade). Thank you, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] window?
Thank you. I am glad I asked. It wasn't giving answers that I expected and now I know why. Rather than pull in another package just for this functionality, I will just reassign the frequency by generating a new time series like: dswin - window(ds, start=..., end=...) dswin - ts(dswin, frequency=1) That should work shouldn't it? Thanks again. Kevin On Tue, Nov 8, 2011 at 9:40 PM, R. Michael Weylandt wrote: Like Denis said, you are asking ts to do things that don't make sense; in particular, some of your statements suggest you don't fully understand what window does or what its frequency argument does. Specifically, when you set frequency = 1 in window, that doesn't mean take a window and treat it as if it has frequency 1; rather take the subseries corresponding to yearly observations. Since 53 is prime, there is no regular subseries you can extract with window() other than the original series and the yearly series. ts objects are required to have a frequency so statements like now that I am taking a subset there is no frequency don't really make sense. Take a look at these examples: ## Create some working data ds.53 - ts(rnorm(53*2), frequency=53, start=c(2000,10)) ds.48 - ts(rnorm(48*2), frequency = 48, start = c(2000,10)) ## These all work window(ds.53, frequency = 1) # Returns elements 1 54 of ds.53 window(ds.53, frequency = 53) # Returns every element of ds.53 window(ds.48, frequency = 1) # Returns elements 1 54 of ds.53 window(ds.48, frequency = 12) # Returns elements seq(1, 48, by = 4) of ds.48 window(ds.48, frequency = 48) # Returns every element of ds.48 ## These don't window(ds.53, frequency = 7) window(ds.48, frequency = 9) Here's how you could do the same with xts. library(xts) library(forecast) x = xts(rnorm(53*2), Sys.Date() + 365*seq(0, 2, by = 1/53)) ets(x) # Auto-conversion to ts Michael On Tue, Nov 8, 2011 at 8:19 PM, Kevin Burton rkevinbur...@charter.net wrote: The problem is when I use the window function an try to extract a subset of the time series an specify the frequency as 1 (not only will ets not take a time series with a frequency greater than 24, now that I am taking a subset there is no frequency so I would like to set it to 1 (which is one of the arguments to the window function) but it does not produce what I expect. That is the problem. I fail to see the relationship of the discussion of what frequency is and how to use the forecast package with this problem. -Original Message- From: Dennis Murphy [mailto:djmu...@gmail.com] Sent: Tuesday, November 08, 2011 6:20 PM To: Kevin Burton Cc: R. Michael Weylandt; r-help@r-project.org Subject: Re: [R] window? The ets() function in the forecast package requires either a numeric vector or a Time-Series object (produced from ts()). The frequency argument in ts() refers to the time duration between observations; e.g., frequency = 7 means that the data are weekly; frequency = 12 means that the data are monthly; frequency = 4 means that the data are quarterly. You can see this from the examples on the help page of ts: ?ts at the R prompt. The example associated with the forecast::ets() function uses the USAccDeaths data: data(USAccDeaths) USAccDeaths ## monthly data for six years # Simulate the same structure with ts: u - ts(rnorm(72), start = c(1973, 1), frequency = 12) u # Evidently you want to produce a multivariate series; # here's one way with monthly frequency: v - ts(matrix(rnorm(106), ncol = 2), start = c(2001, 1), frequency = 12) v Is that more or less what you were after? Dennis On Tue, Nov 8, 2011 at 2:04 PM, Kevin Burton rkevinbur...@charter.net wrote: I expect the frequency to be set to what I set it at and the window to return all of the data in the window from the original time series. The error is not because it is prime. I can generate a time series with just 52 values (or 10) and it still occurs. I am building these objects for use with the 'forecast' packages and one of the methods 'ets' cannot handle a frequency above 24 so I set it (or try to) to 1. Will 'window' take z zoo or xts object? Can I convert from zoo or xts to ts? -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Tuesday, November 08, 2011 2:28 PM To: Kevin Burton Cc: r-help@r-project.org Subject: Re: [R] window? I'm not entirely sure that your request makes sense: what do you expect the frequency to be? It makes sense to me as is...Might your troubles be because 53 is prime? More generally, most people don't like working with the raw ts class and prefer the zoo or xts packages because they are much more pleasant for most time series work. You might want to take a look into those. Michael On Tue, Nov 8, 2011 at 3:18 PM, Kevin Burton rkevinbur...@charter.net wrote: This doesn't seem to work: d - rnorm(2*53) ds - ts(d, frequency=53, start=c(2000,10)) dswin - window(ds, start=c(2001,1), end=c(2001,10), frequency=1) dswin
Re: [R] Installing binaries from R-Forge
Hi Uwe, Thanks for your response. I tried your suggestion and got the following error message: install.packages(splm, repos=http://R-Forge.R-project.org,type=source;) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available I have downloaded the Package source (.tar.gz) at the link below, and it is not an empty file. Not sure what this problem means or what I can do about it. Thanks, Mitch -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, November 09, 2011 9:10 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Installing binaries from R-Forge The Windows binary seems not to be there. Since this is a development platform and there may be various reasons a binary does currently not exist, you could install the package from source, just add the argument type=source in your call to install.packages(). How to prepare your environment to allow to install source packages is described in the R Installation and Administration manual. Uwe Ligges On 09.11.2011 13:39, Downey, Patrick wrote: Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R... It later says To install this package directly within R type: install.packages(splm, repos=http://R-Forge.R-project.org;). I just installed R-2.14 and I still get the following error message. Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available (for R version 2.14.0) Can someone please help? I understand that there is relevant information in the posting guide, but I'm not a programmer and it's difficult for me to understand. I thought I've followed the advice from previous posts (notably, upgrade). Thank you, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Installing binaries from R-Forge
On 09.11.2011 15:15, Downey, Patrick wrote: Hi Uwe, Thanks for your response. I tried your suggestion and got the following error message: install.packages(splm, repos=http://R-Forge.R-project.org,type=source;) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available I have downloaded the Package source (.tar.gz) at the link below, and it is not an empty file. Not sure what this problem means or what I can do about it. I got trying URL 'http://R-Forge.R-project.org/src/contrib/splm_0.9-05.tar.gz' Content type 'application/x-gzip' length 52479 bytes (51 Kb) opened URL downloaded 51 Kb * installing *source* package 'splm' ... . Can you install packages from CRAN? Uwe Ligges Thanks, Mitch -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, November 09, 2011 9:10 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Installing binaries from R-Forge The Windows binary seems not to be there. Since this is a development platform and there may be various reasons a binary does currently not exist, you could install the package from source, just add the argument type=source in your call to install.packages(). How to prepare your environment to allow to install source packages is described in the R Installation and Administration manual. Uwe Ligges On 09.11.2011 13:39, Downey, Patrick wrote: Hello, I'm attempting to install the splm package from R-Forge. https://r-forge.r-project.org/R/?group_id=352 The page says, In order to successfully install the packages provided on R-Forge, you have to switch to the most recent version of R... It later says To install this package directly within R type: install.packages(splm, repos=http://R-Forge.R-project.org;). I just installed R-2.14 and I still get the following error message. Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available (for R version 2.14.0) Can someone please help? I understand that there is relevant information in the posting guide, but I'm not a programmer and it's difficult for me to understand. I thought I've followed the advice from previous posts (notably, upgrade). Thank you, Mitch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Installing binaries from R-Forge
I'm sorry. I made a mistake. I accidentally had 2 versions of R open and got that error message from R-2.10. When I correctly enter the commands you suggest into R-2.14 I get the same as you. However, my installation is filled with errors. I assume the following means that I should install each of these packages prior to trying to install splm from source. Is that correct? Warning: dependencies 'spam', 'ibdreg', 'lmtest', 'deldir', 'coda', 'sandwich' are not available also installing the dependencies 'maptools', 'spdep', 'plm', 'bdsmatrix' trying URL 'http://R-Forge.R-project.org/src/contrib/maptools_0.8-10.tar.gz' Content type 'application/x-gzip' length 813096 bytes (794 Kb) opened URL downloaded 794 Kb trying URL 'http://R-Forge.R-project.org/src/contrib/spdep_0.5-41.tar.gz' Content type 'application/x-gzip' length 1993974 bytes (1.9 Mb) opened URL downloaded 1.9 Mb trying URL 'http://R-Forge.R-project.org/src/contrib/plm_1.2-7.tar.gz' Content type 'application/x-gzip' length 1084173 bytes (1.0 Mb) opened URL downloaded 1.0 Mb trying URL 'http://R-Forge.R-project.org/src/contrib/bdsmatrix_1.1.tar.gz' Content type 'application/x-gzip' length 49623 bytes (48 Kb) opened URL downloaded 48 Kb trying URL 'http://R-Forge.R-project.org/src/contrib/splm_0.9-05.tar.gz' Content type 'application/x-gzip' length 52479 bytes (51 Kb) opened URL downloaded 51 Kb * installing *source* package 'maptools' ... ** libs ERROR: compilation failed for package 'maptools' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/maptools' * installing *source* package 'bdsmatrix' ... ** libs ERROR: compilation failed for package 'bdsmatrix' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/bdsmatrix' ERROR: dependencies 'maptools', 'deldir', 'coda' are not available for package 'spdep' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/spdep' ERROR: dependencies 'bdsmatrix', 'sandwich' are not available for package 'plm' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/plm' ERROR: dependencies 'spdep', 'plm', 'bdsmatrix', 'spam', 'ibdreg', 'lmtest' are not available for package 'splm' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/splm' The downloaded packages are in 'D:\Documents and Settings\pdowney\Local Settings\Temp\RtmpioblL6\downloaded_packages' Warning messages: 1: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/maptools_0 .8-10.tar.gz' had status 1 2: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'maptools' had non-zero exit status 3: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/bdsmatrix_ 1.1.tar.gz' had status 1 4: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'bdsmatrix' had non-zero exit status 5: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/spdep_0.5- 41.tar.gz' had status 1 6: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'spdep' had non-zero exit status 7: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/plm_1.2-7. tar.gz' had status 1 8: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'plm' had non-zero exit status 9: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/splm_0.9-0 5.tar.gz' had status 1 10: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'splm' had non-zero exit status -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, November 09, 2011 9:24 AM To: Downey, Patrick Cc: r-help@r-project.org Subject: Re: [R] Installing binaries from R-Forge On 09.11.2011 15:15, Downey, Patrick wrote: Hi Uwe, Thanks for your response. I tried your suggestion and got the following error message: install.packages(splm, repos=http://R-Forge.R-project.org,type=source;) Warning message: In getDependencies(pkgs, dependencies, available, lib) : package 'splm' is not available I have downloaded the Package source (.tar.gz) at the link below,
[R] reorder data.frame
Hello, I very general question but probably usefull to others as well: Is there any prebuild function that reorders a dataframe from: x1x2 1 100 200 2 101 201 3 102 202 4 103 203 5 104 204 6 105 205 to 1 100 x1 2 101 x1 3 102 x1 4 103 x1 5 104 x1 6 105 x1 7 200 x2 8 201 x2 9 202 x2 10 203 x2 11 204 x2 12 205 x2 I found a way with: names - rep(c(x1,x2),c(length(x1),length(x2))) x -c(x1,x2) data.frame(x,names) but probably there is already another function for doing such things more easily. Thank you Johannes -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] window?
Yes, that will definitely create a time series with the desired frequency, though the actual time index won't correspond to the original so you may need to exercise a little bit of caution in interpreting the outputs of ets(). Glad this could help, Michael On Wed, Nov 9, 2011 at 9:15 AM, rkevinbur...@charter.net wrote: Thank you. I am glad I asked. It wasn't giving answers that I expected and now I know why. Rather than pull in another package just for this functionality, I will just reassign the frequency by generating a new time series like: dswin - window(ds, start=..., end=...) dswin - ts(dswin, frequency=1) That should work shouldn't it? Thanks again. Kevin On Tue, Nov 8, 2011 at 9:40 PM, R. Michael Weylandt wrote: Like Denis said, you are asking ts to do things that don't make sense; in particular, some of your statements suggest you don't fully understand what window does or what its frequency argument does. Specifically, when you set frequency = 1 in window, that doesn't mean take a window and treat it as if it has frequency 1; rather take the subseries corresponding to yearly observations. Since 53 is prime, there is no regular subseries you can extract with window() other than the original series and the yearly series. ts objects are required to have a frequency so statements like now that I am taking a subset there is no frequency don't really make sense. Take a look at these examples: ## Create some working data ds.53 - ts(rnorm(53*2), frequency=53, start=c(2000,10)) ds.48 - ts(rnorm(48*2), frequency = 48, start = c(2000,10)) ## These all work window(ds.53, frequency = 1) # Returns elements 1 54 of ds.53 window(ds.53, frequency = 53) # Returns every element of ds.53 window(ds.48, frequency = 1) # Returns elements 1 54 of ds.53 window(ds.48, frequency = 12) # Returns elements seq(1, 48, by = 4) of ds.48 window(ds.48, frequency = 48) # Returns every element of ds.48 ## These don't window(ds.53, frequency = 7) window(ds.48, frequency = 9) Here's how you could do the same with xts. library(xts) library(forecast) x = xts(rnorm(53*2), Sys.Date() + 365*seq(0, 2, by = 1/53)) ets(x) # Auto-conversion to ts Michael On Tue, Nov 8, 2011 at 8:19 PM, Kevin Burton rkevinbur...@charter.net wrote: The problem is when I use the window function an try to extract a subset of the time series an specify the frequency as 1 (not only will ets not take a time series with a frequency greater than 24, now that I am taking a subset there is no frequency so I would like to set it to 1 (which is one of the arguments to the window function) but it does not produce what I expect. That is the problem. I fail to see the relationship of the discussion of what frequency is and how to use the forecast package with this problem. -Original Message- From: Dennis Murphy [mailto:djmu...@gmail.com] Sent: Tuesday, November 08, 2011 6:20 PM To: Kevin Burton Cc: R. Michael Weylandt; r-help@r-project.org Subject: Re: [R] window? The ets() function in the forecast package requires either a numeric vector or a Time-Series object (produced from ts()). The frequency argument in ts() refers to the time duration between observations; e.g., frequency = 7 means that the data are weekly; frequency = 12 means that the data are monthly; frequency = 4 means that the data are quarterly. You can see this from the examples on the help page of ts: ?ts at the R prompt. The example associated with the forecast::ets() function uses the USAccDeaths data: data(USAccDeaths) USAccDeaths ## monthly data for six years # Simulate the same structure with ts: u - ts(rnorm(72), start = c(1973, 1), frequency = 12) u # Evidently you want to produce a multivariate series; # here's one way with monthly frequency: v - ts(matrix(rnorm(106), ncol = 2), start = c(2001, 1), frequency = 12) v Is that more or less what you were after? Dennis On Tue, Nov 8, 2011 at 2:04 PM, Kevin Burton rkevinbur...@charter.net wrote: I expect the frequency to be set to what I set it at and the window to return all of the data in the window from the original time series. The error is not because it is prime. I can generate a time series with just 52 values (or 10) and it still occurs. I am building these objects for use with the 'forecast' packages and one of the methods 'ets' cannot handle a frequency above 24 so I set it (or try to) to 1. Will 'window' take z zoo or xts object? Can I convert from zoo or xts to ts? -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Tuesday, November 08, 2011 2:28 PM To: Kevin Burton Cc: r-help@r-project.org Subject: Re: [R] window? I'm not entirely sure that your request makes sense: what do you expect the frequency to be? It makes sense to me as is...Might your troubles be because 53 is prime? More generally, most people don't like working with the raw ts class and
Re: [R] reorder data.frame
df = data.frame(x1 = 100:105, x2 = 200:205) library(reshape2) melt(df) Michael On Wed, Nov 9, 2011 at 10:14 AM, Johannes Radinger jradin...@gmx.at wrote: Hello, I very general question but probably usefull to others as well: Is there any prebuild function that reorders a dataframe from: x1 x2 1 100 200 2 101 201 3 102 202 4 103 203 5 104 204 6 105 205 to 1 100 x1 2 101 x1 3 102 x1 4 103 x1 5 104 x1 6 105 x1 7 200 x2 8 201 x2 9 202 x2 10 203 x2 11 204 x2 12 205 x2 I found a way with: names - rep(c(x1,x2),c(length(x1),length(x2))) x -c(x1,x2) data.frame(x,names) but probably there is already another function for doing such things more easily. Thank you Johannes -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] reorder data.frame
On Nov 9, 2011, at 10:14 AM, Johannes Radinger wrote: Hello, I very general question but probably usefull to others as well: Is there any prebuild function that reorders a dataframe from: x1x2 1 100 200 2 101 201 3 102 202 4 103 203 5 104 204 6 105 205 to 1 100 x1 2 101 x1 3 102 x1 4 103 x1 5 104 x1 6 105 x1 7 200 x2 8 201 x2 9 202 x2 10 203 x2 11 204 x2 12 205 x2 ?stack I found a way with: names - rep(c(x1,x2),c(length(x1),length(x2))) x -c(x1,x2) data.frame(x,names) That is basically what stack does. but probably there is already another function for doing such things more easily. Thank you Johannes -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Intervals in function cut
jim holtman jholtman at gmail.com writes: ... Thanks Jim, very useful your information, Sergio. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] algorithm that iteratively drops columns of a data-frame
Dear R-Users, I have a problem with an algorithm that iteratively goes over a data.frame and exclude n-columns each step based on a statistical criterion. So that the 'column-space' gets smaller and smaller with each iteration (like when you do stepwise regression). The problem is that in every round I use a new subset of my data.frame. However, as soon as I generate this subset by indexing the data.frame I get of course different column-numbers (compared to my original data-frame). How can I solve this? I prepared a small example to make my problem easier to understand: Here I generate a data.frame containing 6 vectors with different means. The loop now should exclude the vector with the smallest mean in each round. At the end I want to have a vector ('drop') which contains the column numbers that I can apply on the original data.frame to get a subset with the highest means. But the problem is that this is not working, since every time I generate a subset ('data[,-drop]') I of course get now different column-numbers that differ from the column-numbers of the original data-frame. So, in the end I can't use my drop-vector on my original data-frame – since the dimension of the testing data-frame changes in every loop-round. How can I deal with this kind of problem? Any suggestions are highly appreciated! (of course for the example code, there are much easier method to achieve the goal of finding the columns with the smallest means – It is a pretty generic example) here is the sample code: x1 - rnorm(200, 5, 2) x2 - rnorm(200, 6, 2) x3 - rnorm(200, 1, 2) x4 - rnorm(200, 12, 2) x5 - rnorm(200, 8, 2) x6 - rnorm(200, 9, 2) data - data.frame(x1, x2, x3, x4, x5,x6) col_means - colMeans(data) drop - match(min(col_means), col_means) for(i in 1:4) { col_means - colMeans(data[,-drop]) drop - c(drop, match(min(col_means), col_means)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Invalid 'yscale' in viewport
I tried Googling for help on this problem, but what I saw only increased my puzzlement. I found a lovely bit of code called esplot() that makes scatterplots with associated histograms and rug plots. I have been trying to use it on my own data, but the viewport routine on which it depends (I think) is choking on the data I'm trying to plot. $ Error in valid.viewport(...) : Invalid 'yscale' in viewport When I Google this error, I see that others get this message when trying to plot dates. However, my data are two numeric vectors. The strange part is that these vectors are in fact date differences -- they started life as dates -- but I've already converted them to numeric, like so: $ cogdiff - as.numeric(cogdate - scandate)/365.24 $ labdiff - as.numeric(labdate - scandate)/365.24 When I check is(cogdiff) and is(labdiff) it tells me that both are numeric vectors. And if I put these variables into other plotting routines (e.g. plot(), qplot()), I get the expected output. So on some level the conversion to numeric has worked. However: as a sanity check I also tried the esplot() routine on two random vectors I generated, and it DID work on those -- no error message. So I don't think I'm missing any other key dependencies. Something else must be funny about my cogdiff and labdiff variables, but I'm at a loss about what it could be and am looking for suggestions. Thanks in advance... Erin Jonaitis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] algorithm that iteratively drops columns of a data-frame
Perhaps attach placeholder names to your columns and use those rather than indices? Michael On Wed, Nov 9, 2011 at 10:36 AM, Martin Batholdy batho...@googlemail.com wrote: Dear R-Users, I have a problem with an algorithm that iteratively goes over a data.frame and exclude n-columns each step based on a statistical criterion. So that the 'column-space' gets smaller and smaller with each iteration (like when you do stepwise regression). The problem is that in every round I use a new subset of my data.frame. However, as soon as I generate this subset by indexing the data.frame I get of course different column-numbers (compared to my original data-frame). How can I solve this? I prepared a small example to make my problem easier to understand: Here I generate a data.frame containing 6 vectors with different means. The loop now should exclude the vector with the smallest mean in each round. At the end I want to have a vector ('drop') which contains the column numbers that I can apply on the original data.frame to get a subset with the highest means. But the problem is that this is not working, since every time I generate a subset ('data[,-drop]') I of course get now different column-numbers that differ from the column-numbers of the original data-frame. So, in the end I can't use my drop-vector on my original data-frame – since the dimension of the testing data-frame changes in every loop-round. How can I deal with this kind of problem? Any suggestions are highly appreciated! (of course for the example code, there are much easier method to achieve the goal of finding the columns with the smallest means – It is a pretty generic example) here is the sample code: x1 - rnorm(200, 5, 2) x2 - rnorm(200, 6, 2) x3 - rnorm(200, 1, 2) x4 - rnorm(200, 12, 2) x5 - rnorm(200, 8, 2) x6 - rnorm(200, 9, 2) data - data.frame(x1, x2, x3, x4, x5,x6) col_means - colMeans(data) drop - match(min(col_means), col_means) for(i in 1:4) { col_means - colMeans(data[,-drop]) drop - c(drop, match(min(col_means), col_means)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Installing binaries from R-Forge
As Uwe said, you need to read the fine manual and set up your system to be able to compile source packages. On Windows that essentially means installing Rtools and Miktek, and configuring some environment variables. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Downey, Patrick pdow...@urban.org wrote: I'm sorry. I made a mistake. I accidentally had 2 versions of R open and got that error message from R-2.10. When I correctly enter the commands you suggest into R-2.14 I get the same as you. However, my installation is filled with errors. I assume the following means that I should install each of these packages prior to trying to install splm from source. Is that correct? Warning: dependencies 'spam', 'ibdreg', 'lmtest', 'deldir', 'coda', 'sandwich' are not available also installing the dependencies 'maptools', 'spdep', 'plm', 'bdsmatrix' trying URL 'http://R-Forge.R-project.org/src/contrib/maptools_0.8-10.tar.gz' Content type 'application/x-gzip' length 813096 bytes (794 Kb) opened URL downloaded 794 Kb trying URL 'http://R-Forge.R-project.org/src/contrib/spdep_0.5-41.tar.gz' Content type 'application/x-gzip' length 1993974 bytes (1.9 Mb) opened URL downloaded 1.9 Mb trying URL 'http://R-Forge.R-project.org/src/contrib/plm_1.2-7.tar.gz' Content type 'application/x-gzip' length 1084173 bytes (1.0 Mb) opened URL downloaded 1.0 Mb trying URL 'http://R-Forge.R-project.org/src/contrib/bdsmatrix_1.1.tar.gz' Content type 'application/x-gzip' length 49623 bytes (48 Kb) opened URL downloaded 48 Kb trying URL 'http://R-Forge.R-project.org/src/contrib/splm_0.9-05.tar.gz' Content type 'application/x-gzip' length 52479 bytes (51 Kb) opened URL downloaded 51 Kb * installing *source* package 'maptools' ... ** libs ERROR: compilation failed for package 'maptools' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/maptools' * installing *source* package 'bdsmatrix' ... ** libs ERROR: compilation failed for package 'bdsmatrix' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/bdsmatrix' ERROR: dependencies 'maptools', 'deldir', 'coda' are not available for package 'spdep' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/spdep' ERROR: dependencies 'bdsmatrix', 'sandwich' are not available for package 'plm' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/plm' ERROR: dependencies 'spdep', 'plm', 'bdsmatrix', 'spam', 'ibdreg', 'lmtest' are not available for package 'splm' * removing 'D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library/splm' The downloaded packages are in 'D:\Documents and Settings\pdowney\Local Settings\Temp\RtmpioblL6\downloaded_packages' Warning messages: 1: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/maptools_0 .8-10.tar.gz' had status 1 2: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'maptools' had non-zero exit status 3: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/bdsmatrix_ 1.1.tar.gz' had status 1 4: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'bdsmatrix' had non-zero exit status 5: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/spdep_0.5- 41.tar.gz' had status 1 6: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'spdep' had non-zero exit status 7: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library D:\DOCUME~1\pdowney\LOCALS~1\Temp\RtmpioblL6/downloaded_packages/plm_1.2-7. tar.gz' had status 1 8: In install.packages(splm, repos = http://R-Forge.R-project.org;, : installation of package 'plm' had non-zero exit status 9: running command 'D:/DOCUME~1/pdowney/MYDOCU~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l D:/Documents and Settings/pdowney/My Documents/R/R-2.14.0/library
Re: [R] Installing binaries from R-Forge
On Wed, Nov 9, 2011 at 11:08 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: As Uwe said, you need to read the fine manual and set up your system to be able to compile source packages. On Windows that essentially means installing Rtools and Miktek, and configuring some environment variables. --- On Windows if you use Rcmd.bat from http://batchfiles.googlecode.com to do your builds and installs then you don't have to set any environment variables for R. Its a self contained batch file that automatically finds what it needs using the registry where possible and assuming standard locations otherwise. Just use Rcmd.bat in place of Rcmd.exe . -- 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] algorithm that iteratively drops columns of a data-frame
Try data[,!names(data) %in% names(col_means)] On Wed, 9 Nov 2011, Martin Batholdy wrote: Dear R-Users, I have a problem with an algorithm that iteratively goes over a data.frame and exclude n-columns each step based on a statistical criterion. So that the 'column-space' gets smaller and smaller with each iteration (like when you do stepwise regression). The problem is that in every round I use a new subset of my data.frame. However, as soon as I generate this subset by indexing the data.frame I get of course different column-numbers (compared to my original data-frame). How can I solve this? I prepared a small example to make my problem easier to understand: Here I generate a data.frame containing 6 vectors with different means. The loop now should exclude the vector with the smallest mean in each round. At the end I want to have a vector ('drop') which contains the column numbers that I can apply on the original data.frame to get a subset with the highest means. But the problem is that this is not working, since every time I generate a subset ('data[,-drop]') I of course get now different column-numbers that differ from the column-numbers of the original data-frame. So, in the end I can't use my drop-vector on my original data-frame ? since the dimension of the testing data-frame changes in every loop-round. How can I deal with this kind of problem? Any suggestions are highly appreciated! (of course for the example code, there are much easier method to achieve the goal of finding the columns with the smallest means ? It is a pretty generic example) here is the sample code: x1 - rnorm(200, 5, 2) x2 - rnorm(200, 6, 2) x3 - rnorm(200, 1, 2) x4 - rnorm(200, 12, 2) x5 - rnorm(200, 8, 2) x6 - rnorm(200, 9, 2) data - data.frame(x1, x2, x3, x4, x5,x6) col_means - colMeans(data) drop - match(min(col_means), col_means) for(i in 1:4) { col_means - colMeans(data[,-drop]) drop - c(drop, match(min(col_means), col_means)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Interpreting Multiple Linear Regression Summary
I would appreciate pointers on what I should read to understand this output: summary(lm(TDS ~ Cond + Ca + Cl + Mg + Na + SO4)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) When I look at the summary for the data frame used for this model I do not see an excessive number of missing values or indications why there are no residual degrees of freedom. The same model applied to 8 other data frames did not produce similar results. Puzzled, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting Multiple Linear Regression Summary
Please see ?dput use dput(your data) and paste the output into a reply, thanks. This way we know what you are working with. Rich Shepard wrote: I would appreciate pointers on what I should read to understand this output: summary(lm(TDS ~ Cond + Ca + Cl + Mg + Na + SO4)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) When I look at the summary for the data frame used for this model I do not see an excessive number of missing values or indications why there are no residual degrees of freedom. The same model applied to 8 other data frames did not produce similar results. Puzzled, Rich __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-Multiple-Linear-Regression-Summary-tp4020516p4020567.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] Interpreting Multiple Linear Regression Summary
On Nov 9, 2011, at 12:04 PM, Rich Shepard wrote: I would appreciate pointers on what I should read to understand this output: summary(lm(TDS ~ Cond + Ca + Cl + Mg + Na + SO4)) I don't see a data= argument specified, so you are telling lm() that your workspace has individual vectors by those names in the formula. That is not what is implied by hte rest of your message. Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) When I look at the summary for the data frame used for this model I do not see an excessive number of missing values or indications why there are no residual degrees of freedom. The same model applied to 8 other data frames did not produce similar results. Puzzled, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] path.diagram in SEM--display covariances without variances
Forgive me if I'm posting to the wrong placeIt's my first time posting. Here's the situation: I'm using the sem package and making path diagrams using path.diagrams. Suppose I have the following code: #install.packages(ggm) require(ggm) cor = rcorr(7) nm = c(SOF, IWF, PWF, FSC, FSF, EF, GPA) ram = specify.model() PWF - FSF, a, NA PWF - FSC, b, NA SOF - FSF, c, NA SOF - FSC, d, NA IWF - FSF, e, NA IWF - FSC, f, NA FSC - EF, g, NA FSF - EF, h, NA EF - GPA, i, NA PWF - IWF, j, NA PWF - SOF, k, NA SOF - IWF, l, NA PWF - PWF, d1, NA SOF - SOF, d2, NA IWF - IWF, d3, NA FSC - FSC, d4, NA FSF - FSF, d5, NA EF - EF, d6, NA GPA - GPA, d7, NA sem.mod = sem(ram, cor, N=1656, obs.variables=nm) path.diagram(sem.mod, 'path/to/file/plot', ignore.double=FALSE, edge.labels=values, standardize=TRUE, min.rank=c(IWF, SOF, PWF)) The diagram is produces is hard to read because of the many variances that are shown. The covariance estimates are important for my diagram, but the variances are not. Is there a way to suppress the variance arrows without suppressing the covariance arrows? -- Dustin Fife Graduate Student, Quantitative Psychology University of Oklahoma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting Multiple Linear Regression Summary
On Wed, 9 Nov 2011, David Winsemius wrote: I don't see a data= argument specified, so you are telling lm() that your workspace has individual vectors by those names in the formula. That is not what is implied by hte rest of your message. David, That's because I attached the data frame before running the model. However, looking again at the scatter plots of the individual predictor variables with the response variable answered my question after I posted it. There are no patterns to the relationships in these scatter plots so there's nothing to model. I became caught up in the repetitive processing for all these data and stopped really seeing what was in front of me. My apologies to the list, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating 3D plot
Hi to all, i have a data set of international airports with latitude, longitude and altitude. I was thinking of creating a 3D plot out of them, but haven't succeeded yet. With plot3d(x=seq(min(traffic$lon),max(traffic$lon)),y=seq(min(traffic$lat),max(traffic$lat)),z=traffic$alt) all i get is http://imageshack.us/photo/my-images/225/70758244.png/. What i wanna get is a 3Dlike map of airports in the world. Am i using good function to achieve that? Why are the points lined up and don't copy their 2D shape (http://imageshack.us/photo/my-images/36/91660845.png/)?. Thanks for replies or hints, i'm new to R and as a geography student i'm especially interested in handling and visualizing geodata. -- Michal Zimmermann (zimmi) WWW: http://www.zimmi.cz [[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 tryCatch with a for loop
Hello all, I'm a beginner in R working on a script that will produce a set of models (linear, polynomial and logistic) for each location in a dataset. However, the self-starting logistic model often fails - if this happens I would like to just skip to the next iteration of the loop using tryCatch. I've looked at a few examples and read the help file, but didn't understand tryCatch in the context of my script. Any help or suggestions (even telling me where to insert the tryCatch command) would be much appreciated!! Below is the script I am currently working on: data-read.csv(file.choose(),sep=,,header=T) #File name is cbc.subset data$location.code = as.character(data$location.code) locs = unique(location.code) pdf(mygraphs.pdf,height=8, width=10) par(mfrow=c(3,4)) for(s in 1:length(locs)){ #To plot data from a particular stateroute: sub.ECDO-data[data$location.code == locs[s],] plot(abund~year, data=sub.ECDO, main=locs[s]) #To plot the linear model for the specified location: lmodel-lm(abund~year, data=sub.ECDO) abline(lmodel$coefficients[1],lmodel$coefficients[2],lty=2) #To plot the polynomial model for the specified location: polymodel-lm(abund~year+I(year^2), data=sub.ECDO) xv-seq(min(sub.ECDO$year),max(sub.ECDO$year),0.1) yv-predict(polymodel,list(year=xv)) lines(xv,yv) #To plot the logistic model #tryCatch logis-nls(abund~SSlogis(year,a,b,c),data=sub.ECDO) yv-predict(logis,list(year=xv)) lines(xv,yv) #To find which model is the best fit: if (logis %in% ls()) { AIC.results = AIC(lmodel,polymodel,logis) } else { AIC.results = AIC(lmodel,polymodel) } #Add text to plot text(min(sub.ECDO$year)+2,0.9*max(sub.ECDO$abund),paste(linear = ,AIC.results[1,2],\npolynomial = ,AIC.results[2,2],\nlogistic = ,AIC.results[3,2],sep=)) rm(logis) rm(polymodel) rm(lmodel) } dev.off() Thank you! -- View this message in context: http://r.789695.n4.nabble.com/Help-with-tryCatch-with-a-for-loop-tp4020475p4020475.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] Interpreting Multiple Linear Regression Summary
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rich Shepard Sent: Wednesday, November 09, 2011 9:05 AM To: r-help@r-project.org Subject: [R] Interpreting Multiple Linear Regression Summary I would appreciate pointers on what I should read to understand this output: summary(lm(TDS ~ Cond + Ca + Cl + Mg + Na + SO4)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) When I look at the summary for the data frame used for this model I do not see an excessive number of missing values or indications why there are no residual degrees of freedom. The same model applied to 8 other data frames did not produce similar results. Puzzled, Rich Rich, I don't see a 'data=' parameter in your call to lm(). How does lm() know where to find the variables referenced in the model parameter? If that is not the problem, then we need to see str() output for the data frame that you are analyzing. Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating 3D plot
Hi, On Wed, Nov 9, 2011 at 11:56 AM, Michal Zimmermann zimm...@gmail.com wrote: Hi to all, i have a data set of international airports with latitude, longitude and altitude. I was thinking of creating a 3D plot out of them, but haven't succeeded yet. With plot3d(x=seq(min(traffic$lon),max(traffic$lon)),y=seq(min(traffic$lat),max(traffic$lat)),z=traffic$alt) all i get is http://imageshack.us/photo/my-images/225/70758244.png/. What i wanna get is a 3Dlike map of airports in the world. Am i using good function to achieve that? Why are the points lined up and don't copy their 2D shape (http://imageshack.us/photo/my-images/36/91660845.png/)?. Your points are lined up because you're plotting seq(min(traffic$lon),max(traffic$lon)) instead of your actual x coordinates, and ditto for y. I would think that you want plot3d(x=traffic$lon, y=traffic$lat, z=traffic$alt) but since you don't provide data (or even which package provided the plot3d() function you're using, since there's more than one), it's hard to say for certain. Sarah Thanks for replies or hints, i'm new to R and as a geography student i'm especially interested in handling and visualizing geodata. -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting Multiple Linear Regression Summary
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Rich Shepard Sent: Wednesday, November 09, 2011 9:42 AM To: r-help@r-project.org Subject: Re: [R] Interpreting Multiple Linear Regression Summary On Wed, 9 Nov 2011, David Winsemius wrote: I don't see a data= argument specified, so you are telling lm() that your workspace has individual vectors by those names in the formula. That is not what is implied by hte rest of your message. David, That's because I attached the data frame before running the model. However, looking again at the scatter plots of the individual predictor variables with the response variable answered my question after I posted it. There are no patterns to the relationships in these scatter plots so there's nothing to model. I became caught up in the repetitive processing for all these data and stopped really seeing what was in front of me. My apologies to the list, Rich Rich, the problem is not just that there was 'nothing to model.' If that were the case, you would have gotten non-significant parameter estimates, not NA's. I would guess that there is something problematic with the how the data frame is structured relative to what lm() is expecting. So, I would not give up looking for a solution just yet. Can you show us the result of str() on the data frame that you attached? Dan Daniel Nordlund Bothell, WA USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Invalid 'yscale' in viewport
Two things: 1) It sounds like you are right in thinking there's something funny about your particular data: could you provide it to us? The easiest way to do so is to use dput() to get a plain text representation ready for copy and paste. 2) What is esplot()? It's not in base R, but I imagine you are referring to Deepayn's script here: http://www.stat.wisc.edu/~deepayan/771/esplot.R ? Just to confirm in case there is something that needs looking at in the code. Thanks, Michael On Wed, Nov 9, 2011 at 10:20 AM, Erin Jonaitis jonai...@wisc.edu wrote: I tried Googling for help on this problem, but what I saw only increased my puzzlement. I found a lovely bit of code called esplot() that makes scatterplots with associated histograms and rug plots. I have been trying to use it on my own data, but the viewport routine on which it depends (I think) is choking on the data I'm trying to plot. $ Error in valid.viewport(...) : Invalid 'yscale' in viewport When I Google this error, I see that others get this message when trying to plot dates. However, my data are two numeric vectors. The strange part is that these vectors are in fact date differences -- they started life as dates -- but I've already converted them to numeric, like so: $ cogdiff - as.numeric(cogdate - scandate)/365.24 $ labdiff - as.numeric(labdate - scandate)/365.24 When I check is(cogdiff) and is(labdiff) it tells me that both are numeric vectors. And if I put these variables into other plotting routines (e.g. plot(), qplot()), I get the expected output. So on some level the conversion to numeric has worked. However: as a sanity check I also tried the esplot() routine on two random vectors I generated, and it DID work on those -- no error message. So I don't think I'm missing any other key dependencies. Something else must be funny about my cogdiff and labdiff variables, but I'm at a loss about what it could be and am looking for suggestions. Thanks in advance... Erin Jonaitis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] path.diagram in SEM--display covariances without variances
Dear Dustin, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Dustin Fife Sent: November-09-11 10:57 AM To: r-help@r-project.org Subject: [R] path.diagram in SEM--display covariances without variances Forgive me if I'm posting to the wrong placeIt's my first time posting. Here's the situation: I'm using the sem package and making path diagrams using path.diagrams. Suppose I have the following code: . . . The diagram is produces is hard to read because of the many variances that are shown. The covariance estimates are important for my diagram, but the variances are not. Is there a way to suppress the variance arrows without suppressing the covariance arrows? No, but (1) pathDiagram() (the name of the function in the current version of the sem package) produces an editable text file, from which you could remove the arrows that you don't want to see; and (2) you could modify pathDiagram() -- the code for the function is, after all, available to you -- so that it does what you want. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -- Dustin Fife Graduate Student, Quantitative Psychology University of Oklahoma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] path.diagram in SEM--display covariances without variances
Thanks for the quick response...I've never edited someone else's package before. How do I go about doing that? On Wed, Nov 9, 2011 at 12:47 PM, John Fox j...@mcmaster.ca wrote: Dear Dustin, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Dustin Fife Sent: November-09-11 10:57 AM To: r-help@r-project.org Subject: [R] path.diagram in SEM--display covariances without variances Forgive me if I'm posting to the wrong placeIt's my first time posting. Here's the situation: I'm using the sem package and making path diagrams using path.diagrams. Suppose I have the following code: . . . The diagram is produces is hard to read because of the many variances that are shown. The covariance estimates are important for my diagram, but the variances are not. Is there a way to suppress the variance arrows without suppressing the covariance arrows? No, but (1) pathDiagram() (the name of the function in the current version of the sem package) produces an editable text file, from which you could remove the arrows that you don't want to see; and (2) you could modify pathDiagram() -- the code for the function is, after all, available to you -- so that it does what you want. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -- Dustin Fife Graduate Student, Quantitative Psychology University of Oklahoma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Dustin Fife Fife Photography www.fifephotography.com i...@fifephotography.com fife.dus...@gmail.com 405.414.5599 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting Multiple Linear Regression Summary
On Wed, 9 Nov 2011, Daniel Nordlund wrote: I would guess that there is something problematic with the how the data frame is structured relative to what lm() is expecting. Dan, I was not comfortable with my explanation, but the formula (and data frame) was equivalent to those of the other 8 streams. So, I would not give up looking for a solution just yet. OK. I'm always up for learning more about R and its processes. Can you show us the result of str() on the data frame that you attached? Sure. I subset the original data frame to select only the 6 predictor variables and the response variable. Same lm() results. I'll provide the data frame, too. summary(lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) str(mod.stump.cast) 'data.frame': 64 obs. of 7 variables: $ Ca : num NA NA 24.4 NA 21.4 NA NA NA NA NA ... $ Cl : num 1.58 5.6 3 NA 1 5 1.2 4 4 8.4 ... $ Cond: num NA NA 190 187 184 NA NA NA NA NA ... $ Mg : num NA NA 10 NA 9.1 NA NA NA NA NA ... $ Na : num NA NA NA NA NA NA NA NA NA NA ... $ SO4 : num 9.4 6.5 9 NA 7 55 6.8 105 15.6 8.4 ... $ TDS : num 105 181 112 144 114 308 96 430 108 108 ... summary(mod.stump.cast) Ca Cl Cond Mg Na Min. : 0.60 Min. : 1.000 Min. : 2.2 Min. : 9.10 Min. : 4 1st Qu.:23.35 1st Qu.: 2.000 1st Qu.:214.8 1st Qu.:11.00 1st Qu.: 4 Median :28.35 Median : 4.000 Median :282.5 Median :17.40 Median : 4 Mean :32.77 Mean : 4.076 Mean :294.6 Mean :17.85 Mean : 4 3rd Qu.:40.55 3rd Qu.: 5.600 3rd Qu.:372.0 3rd Qu.:22.10 3rd Qu.: 4 Max. :64.30 Max. :13.000 Max. :636.0 Max. :32.40 Max. : 4 NA's :50.00 NA's :11.000 NA's : 42.0 NA's :51.00 NA's :62 SO4 TDS Min. : 4.00 Min. : 14.0 1st Qu.: 7.00 1st Qu.:131.2 Median : 9.40 Median :174.0 Mean : 16.31 Mean :176.9 3rd Qu.: 17.00 3rd Qu.:195.5 Max. :105.00 Max. :430.0 NA's : 3.00 NA's : 2.0 mod.stump.cast CaCl Cond Mg Na SO4 TDS 1NA 1.58NA NA NA 9.4 105 2NA 5.60NA NA NA 6.5 181 3 24.4 3.00 190.0 10.0 NA 9.0 112 4NANA 187.0 NA NANA 144 5 21.4 1.00 184.0 9.1 NA 7.0 114 6NA 5.00NA NA NA 55.0 308 7NA 1.20NA NA NA 6.8 96 8NA 4.00NA NA NA 105.0 430 9NA 4.00NA NA NA 15.6 108 10 NA 8.40NA NA NA 8.4 108 11 NA 1.00NA NA NA 8.8 125 12 NA 1.40NA NA NA 19.4 129 13 NA 4.90NA NA NA 37.0 360 14 NA 1.70NA NA NA 12.0 140 15 NA 2.00NA NA NA 10.0 95 16 NA 1.60NA NA NA 9.1 120 17 NA 3.30NA NA NA 34.0 280 18 NA 2.20NA NA NA 11.0 130 19 NA 9.00NA NA NA 69.0 352 20 NA 1.00NA NA NA 18.0 148 21 NA 2.00NA NA NA 9.0 107 22 28.0 1.00 248.0 11.0 4 13.0 125 23 32.0 1.00NA 12.0 4 9.0 139 24 NA 5.00NA NA NA 7.0 188 25 NA 4.00NA NA NA 6.0 201 26 NA 3.00NA NA NA 5.0 178 27 NA 2.27NA NA NA 7.8 197 28 NA 1.76NA NA NA 7.8 187 29 NA 5.81NA NA NA 7.5 182 30 NA 4.23NA NA NA 6.0 165 31 NA 4.23NA NA NA 7.3 186 32 NA 6.25NA NA NA 7.0 191 33 NA 6.72NA NA NA 7.5 190 34 34.7 4.00 304.0 17.4 NA 6.0 176 35 NANA 354.0 NA NA 7.0 175 36 42.5 5.00 379.0 21.1 NA 7.0 220 37 NA 5.80NA NA NA 5.6 163 38 26.0 5.80 300.0 24.0 NA 5.6 163 39 NA 2.20NA NA NA 5.4 152 40 NA 5.40NA NA NA 11.0 221 41 NA 5.40NA NA NA 10.5 171 42 NA 4.80NA NA NA 9.9 204 43 NA 8.00NA NA NA 11.7 174 44 NA 1.00NA NA NA 8.4 190 45 NA 4.80NA NA NA 12.1 174 46 NA 5.90NA NA NA 16.0 210 47 NA 5.90NA NA NA 20.0 190 48 NA 13.00NA NA NA 7.6 180 49 NA 5.60NA NA NA 17.0 200 50 NA 1.20NA NA NA 6.5 180 51 0.6NA 2.2 NA NANA NA 52 21.4NA 187.0 9.5 NA 8.0 120 53 NANA 285.0 NA NA 22.0 135 54 48.3 3.00 378.0 22.1 NA 24.0 228 55 63.5 7.00 533.0 29.9 NA 44.0 14 56 NANA 207.0 NA NANA NA 57 NANA 262.0 NA NA 13.0 156 58 28.7 2.00
Re: [R] Interpreting Multiple Linear Regression Summary
On Nov 9, 2011, at 1:17 PM, Rich Shepard wrote: On Wed, 9 Nov 2011, Daniel Nordlund wrote: I would guess that there is something problematic with the how the data frame is structured relative to what lm() is expecting. Dan, I was not comfortable with my explanation, but the formula (and data frame) was equivalent to those of the other 8 streams. So, I would not give up looking for a solution just yet. OK. I'm always up for learning more about R and its processes. Can you show us the result of str() on the data frame that you attached? Sure. I subset the original data frame to select only the 6 predictor variables and the response variable. Same lm() results. I'll provide the data frame, too. summary(lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) str(mod.stump.cast) 'data.frame': 64 obs. of 7 variables: $ Ca : num NA NA 24.4 NA 21.4 NA NA NA NA NA ... $ Cl : num 1.58 5.6 3 NA 1 5 1.2 4 4 8.4 ... $ Cond: num NA NA 190 187 184 NA NA NA NA NA ... $ Mg : num NA NA 10 NA 9.1 NA NA NA NA NA ... $ Na : num NA NA NA NA NA NA NA NA NA NA ... $ SO4 : num 9.4 6.5 9 NA 7 55 6.8 105 15.6 8.4 ... $ TDS : num 105 181 112 144 114 308 96 430 108 108 ... summary(mod.stump.cast) Ca Cl Cond Mg Na Min. : 0.60 Min. : 1.000 Min. : 2.2 Min. : 9.10 Min. : 4 1st Qu.:23.35 1st Qu.: 2.000 1st Qu.:214.8 1st Qu.:11.00 1st Qu.: 4 Median :28.35 Median : 4.000 Median :282.5 Median :17.40 Median : 4 Mean :32.77 Mean : 4.076 Mean :294.6 Mean :17.85 Mean : 4 3rd Qu.:40.55 3rd Qu.: 5.600 3rd Qu.:372.0 3rd Qu.:22.10 3rd Qu.: 4 Max. :64.30 Max. :13.000 Max. :636.0 Max. :32.40 Max. : 4 NA's :50.00 NA's :11.000 NA's : 42.0 NA's :51.00 NA's :62 SO4 TDS Min. : 4.00 Min. : 14.0 1st Qu.: 7.00 1st Qu.:131.2 Median : 9.40 Median :174.0 Mean : 16.31 Mean :176.9 3rd Qu.: 17.00 3rd Qu.:195.5 Max. :105.00 Max. :430.0 NA's : 3.00 NA's : 2.0 mod.stump.cast CaCl Cond Mg Na SO4 TDS 1NA 1.58NA NA NA 9.4 105 2NA 5.60NA NA NA 6.5 181 3 24.4 3.00 190.0 10.0 NA 9.0 112 4NANA 187.0 NA NANA 144 5 21.4 1.00 184.0 9.1 NA 7.0 114 6NA 5.00NA NA NA 55.0 308 7NA 1.20NA NA NA 6.8 96 8NA 4.00NA NA NA 105.0 430 9NA 4.00NA NA NA 15.6 108 10 NA 8.40NA NA NA 8.4 108 11 NA 1.00NA NA NA 8.8 125 12 NA 1.40NA NA NA 19.4 129 13 NA 4.90NA NA NA 37.0 360 14 NA 1.70NA NA NA 12.0 140 15 NA 2.00NA NA NA 10.0 95 16 NA 1.60NA NA NA 9.1 120 17 NA 3.30NA NA NA 34.0 280 18 NA 2.20NA NA NA 11.0 130 19 NA 9.00NA NA NA 69.0 352 20 NA 1.00NA NA NA 18.0 148 21 NA 2.00NA NA NA 9.0 107 22 28.0 1.00 248.0 11.0 4 13.0 125 23 32.0 1.00NA 12.0 4 9.0 139 24 NA 5.00NA NA NA 7.0 188 25 NA 4.00NA NA NA 6.0 201 26 NA 3.00NA NA NA 5.0 178 27 NA 2.27NA NA NA 7.8 197 28 NA 1.76NA NA NA 7.8 187 29 NA 5.81NA NA NA 7.5 182 30 NA 4.23NA NA NA 6.0 165 31 NA 4.23NA NA NA 7.3 186 32 NA 6.25NA NA NA 7.0 191 33 NA 6.72NA NA NA 7.5 190 34 34.7 4.00 304.0 17.4 NA 6.0 176 35 NANA 354.0 NA NA 7.0 175 36 42.5 5.00 379.0 21.1 NA 7.0 220 37 NA 5.80NA NA NA 5.6 163 38 26.0 5.80 300.0 24.0 NA 5.6 163 39 NA 2.20NA NA NA 5.4 152 40 NA 5.40NA NA NA 11.0 221 41 NA 5.40NA NA NA 10.5 171 42 NA 4.80NA NA NA 9.9 204 43 NA 8.00NA NA NA 11.7 174 44 NA 1.00NA NA NA 8.4 190 45 NA 4.80NA NA NA 12.1 174 46 NA 5.90NA NA NA 16.0 210 47 NA 5.90NA NA NA 20.0 190 48 NA 13.00NA NA NA 7.6 180 49 NA 5.60NA NA NA 17.0 200 50 NA 1.20NA NA NA 6.5 180 51 0.6NA 2.2 NA NANA NA 52 21.4NA 187.0 9.5 NA 8.0 120 53 NANA 285.0 NA NA 22.0 135 54 48.3 3.00 378.0 22.1 NA
[R] raking weighting
Hi everyone, Does anyone know if there is a package to compute raking weights using R? What I need is to create a variable with weights base in some demographic variables (e.g. sexo, age group, area) using the raking procedure. Thank you in advance! -- Sebastián Daza __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in drawing
I have got following error in drawing wavelet fitting. can some one help? library(faraway) data(lidar) newlidar-lidar[c(1:128),] library(wavethresh) wds - wd(newlidar$logratio) draw(wds) Error in plot.default(x = x, y = zwr, main = main, sub = sub, xlab = xlab, : formal argument type matched by multiple actual arguments [[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] Interpreting Multiple Linear Regression Summary
On Nov 9, 2011, at 2:17 PM, Rich Shepard wrote: On Wed, 9 Nov 2011, Daniel Nordlund wrote: I would guess that there is something problematic with the how the data frame is structured relative to what lm() is expecting. Dan, I was not comfortable with my explanation, but the formula (and data frame) was equivalent to those of the other 8 streams. So, I would not give up looking for a solution just yet. OK. I'm always up for learning more about R and its processes. I count exactly 1 line in the data.frame below that have all columns with non-NA values. It should be no surprise that its 'TDS' value (=125) is the same as the estimated Intercept. I cannot understand why you mislead us to such an extent about the degree of missing-ness in that data. (Failing to indicate that you have attached a dataframe is also very discourteous.) -- David. Can you show us the result of str() on the data frame that you attached? Sure. I subset the original data frame to select only the 6 predictor variables and the response variable. Same lm() results. I'll provide the data frame, too. summary(lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) str(mod.stump.cast) 'data.frame': 64 obs. of 7 variables: $ Ca : num NA NA 24.4 NA 21.4 NA NA NA NA NA ... $ Cl : num 1.58 5.6 3 NA 1 5 1.2 4 4 8.4 ... $ Cond: num NA NA 190 187 184 NA NA NA NA NA ... $ Mg : num NA NA 10 NA 9.1 NA NA NA NA NA ... $ Na : num NA NA NA NA NA NA NA NA NA NA ... $ SO4 : num 9.4 6.5 9 NA 7 55 6.8 105 15.6 8.4 ... $ TDS : num 105 181 112 144 114 308 96 430 108 108 ... summary(mod.stump.cast) Ca Cl Cond Mg Na Min. : 0.60 Min. : 1.000 Min. : 2.2 Min. : 9.10 Min. : 4 1st Qu.:23.35 1st Qu.: 2.000 1st Qu.:214.8 1st Qu.:11.00 1st Qu.: 4 Median :28.35 Median : 4.000 Median :282.5 Median :17.40 Median : 4 Mean :32.77 Mean : 4.076 Mean :294.6 Mean :17.85 Mean : 4 3rd Qu.:40.55 3rd Qu.: 5.600 3rd Qu.:372.0 3rd Qu.:22.10 3rd Qu.: 4 Max. :64.30 Max. :13.000 Max. :636.0 Max. :32.40 Max. : 4 NA's :50.00 NA's :11.000 NA's : 42.0 NA's :51.00 NA's :62 SO4 TDS Min. : 4.00 Min. : 14.0 1st Qu.: 7.00 1st Qu.:131.2 Median : 9.40 Median :174.0 Mean : 16.31 Mean :176.9 3rd Qu.: 17.00 3rd Qu.:195.5 Max. :105.00 Max. :430.0 NA's : 3.00 NA's : 2.0 mod.stump.cast CaCl Cond Mg Na SO4 TDS 1NA 1.58NA NA NA 9.4 105 2NA 5.60NA NA NA 6.5 181 3 24.4 3.00 190.0 10.0 NA 9.0 112 4NANA 187.0 NA NANA 144 5 21.4 1.00 184.0 9.1 NA 7.0 114 6NA 5.00NA NA NA 55.0 308 7NA 1.20NA NA NA 6.8 96 8NA 4.00NA NA NA 105.0 430 9NA 4.00NA NA NA 15.6 108 10 NA 8.40NA NA NA 8.4 108 11 NA 1.00NA NA NA 8.8 125 12 NA 1.40NA NA NA 19.4 129 13 NA 4.90NA NA NA 37.0 360 14 NA 1.70NA NA NA 12.0 140 15 NA 2.00NA NA NA 10.0 95 16 NA 1.60NA NA NA 9.1 120 17 NA 3.30NA NA NA 34.0 280 18 NA 2.20NA NA NA 11.0 130 19 NA 9.00NA NA NA 69.0 352 20 NA 1.00NA NA NA 18.0 148 21 NA 2.00NA NA NA 9.0 107 22 28.0 1.00 248.0 11.0 4 13.0 125 23 32.0 1.00NA 12.0 4 9.0 139 24 NA 5.00NA NA NA 7.0 188 25 NA 4.00NA NA NA 6.0 201 26 NA 3.00NA NA NA 5.0 178 27 NA 2.27NA NA NA 7.8 197 28 NA 1.76NA NA NA 7.8 187 29 NA 5.81NA NA NA 7.5 182 30 NA 4.23NA NA NA 6.0 165 31 NA 4.23NA NA NA 7.3 186 32 NA 6.25NA NA NA 7.0 191 33 NA 6.72NA NA NA 7.5 190 34 34.7 4.00 304.0 17.4 NA 6.0 176 35 NANA 354.0 NA NA 7.0 175 36 42.5 5.00 379.0 21.1 NA 7.0 220 37 NA 5.80NA NA NA 5.6 163 38 26.0 5.80 300.0 24.0 NA 5.6 163 39 NA 2.20NA NA NA 5.4 152 40 NA 5.40NA NA NA 11.0 221 41 NA 5.40NA NA NA 10.5 171 42 NA 4.80NA NA NA 9.9 204 43 NA 8.00NA NA NA 11.7 174 44 NA 1.00NA NA NA 8.4 190 45 NA 4.80NA NA NA 12.1 174 46 NA 5.90NA NA NA
Re: [R] Interpreting Multiple Linear Regression Summary
As far as I know if there is an NA in any variable in an observation the default is to drop the entire observation. Thus there are no observations in your calculation Best Regards John On 9 November 2011 19:17, Rich Shepard rshep...@appl-ecosys.com wrote: On Wed, 9 Nov 2011, Daniel Nordlund wrote: I would guess that there is something problematic with the how the data frame is structured relative to what lm() is expecting. Dan, I was not comfortable with my explanation, but the formula (and data frame) was equivalent to those of the other 8 streams. So, I would not give up looking for a solution just yet. OK. I'm always up for learning more about R and its processes. Can you show us the result of str() on the data frame that you attached? Sure. I subset the original data frame to select only the 6 predictor variables and the response variable. Same lm() results. I'll provide the data frame, too. summary(lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4, data = mod.stump.cast) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA Ca NA NA NA NA Cl NA NA NA NA Mg NA NA NA NA Na NA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) str(mod.stump.cast) 'data.frame': 64 obs. of 7 variables: $ Ca : num NA NA 24.4 NA 21.4 NA NA NA NA NA ... $ Cl : num 1.58 5.6 3 NA 1 5 1.2 4 4 8.4 ... $ Cond: num NA NA 190 187 184 NA NA NA NA NA ... $ Mg : num NA NA 10 NA 9.1 NA NA NA NA NA ... $ Na : num NA NA NA NA NA NA NA NA NA NA ... $ SO4 : num 9.4 6.5 9 NA 7 55 6.8 105 15.6 8.4 ... $ TDS : num 105 181 112 144 114 308 96 430 108 108 ... summary(mod.stump.cast) Ca Cl Cond Mg Na Min. : 0.60 Min. : 1.000 Min. : 2.2 Min. : 9.10 Min. : 4 1st Qu.:23.35 1st Qu.: 2.000 1st Qu.:214.8 1st Qu.:11.00 1st Qu.: 4 Median :28.35 Median : 4.000 Median :282.5 Median :17.40 Median : 4 Mean :32.77 Mean : 4.076 Mean :294.6 Mean :17.85 Mean : 4 3rd Qu.:40.55 3rd Qu.: 5.600 3rd Qu.:372.0 3rd Qu.:22.10 3rd Qu.: 4 Max. :64.30 Max. :13.000 Max. :636.0 Max. :32.40 Max. : 4 NA's :50.00 NA's :11.000 NA's : 42.0 NA's :51.00 NA's :62 SO4 TDS Min. : 4.00 Min. : 14.0 1st Qu.: 7.00 1st Qu.:131.2 Median : 9.40 Median :174.0 Mean : 16.31 Mean :176.9 3rd Qu.: 17.00 3rd Qu.:195.5 Max. :105.00 Max. :430.0 NA's : 3.00 NA's : 2.0 mod.stump.cast Ca Cl Cond Mg Na SO4 TDS 1 NA 1.58 NA NA NA 9.4 105 2 NA 5.60 NA NA NA 6.5 181 3 24.4 3.00 190.0 10.0 NA 9.0 112 4 NA NA 187.0 NA NA NA 144 5 21.4 1.00 184.0 9.1 NA 7.0 114 6 NA 5.00 NA NA NA 55.0 308 7 NA 1.20 NA NA NA 6.8 96 8 NA 4.00 NA NA NA 105.0 430 9 NA 4.00 NA NA NA 15.6 108 10 NA 8.40 NA NA NA 8.4 108 11 NA 1.00 NA NA NA 8.8 125 12 NA 1.40 NA NA NA 19.4 129 13 NA 4.90 NA NA NA 37.0 360 14 NA 1.70 NA NA NA 12.0 140 15 NA 2.00 NA NA NA 10.0 95 16 NA 1.60 NA NA NA 9.1 120 17 NA 3.30 NA NA NA 34.0 280 18 NA 2.20 NA NA NA 11.0 130 19 NA 9.00 NA NA NA 69.0 352 20 NA 1.00 NA NA NA 18.0 148 21 NA 2.00 NA NA NA 9.0 107 22 28.0 1.00 248.0 11.0 4 13.0 125 23 32.0 1.00 NA 12.0 4 9.0 139 24 NA 5.00 NA NA NA 7.0 188 25 NA 4.00 NA NA NA 6.0 201 26 NA 3.00 NA NA NA 5.0 178 27 NA 2.27 NA NA NA 7.8 197 28 NA 1.76 NA NA NA 7.8 187 29 NA 5.81 NA NA NA 7.5 182 30 NA 4.23 NA NA NA 6.0 165 31 NA 4.23 NA NA NA 7.3 186 32 NA 6.25 NA NA NA 7.0 191 33 NA 6.72 NA NA NA 7.5 190 34 34.7 4.00 304.0 17.4 NA 6.0 176 35 NA NA 354.0 NA NA 7.0 175 36 42.5 5.00 379.0 21.1 NA 7.0 220 37 NA 5.80 NA NA NA 5.6 163 38 26.0 5.80 300.0 24.0 NA 5.6 163 39 NA 2.20 NA NA NA 5.4 152 40 NA 5.40 NA NA NA 11.0 221 41 NA 5.40 NA NA NA 10.5 171 42 NA 4.80 NA NA NA 9.9 204 43 NA 8.00 NA NA NA 11.7 174 44 NA 1.00 NA NA NA 8.4 190 45 NA 4.80 NA NA NA 12.1 174 46 NA 5.90 NA NA NA 16.0 210 47 NA 5.90 NA NA NA 20.0 190 48 NA 13.00 NA NA NA 7.6 180 49 NA
[R] Compare clustering solutions to a correct one
Hello everyone, I have a set of data, J healthy subjects, K diseased subjects, N features for each person. I would like to clusterize my data. Since I know that subjects are from two populations ideally I would prefer an algorithm that first is able to discriminate them, in order to see how it performs inside each group. I know that R offers several clustering functions and a very interesting clustering compare tool: cluster.stats in fpc package. I would like to ask you if you know of any existing approach where one cluster is considered correct and against it several clustering functions (with several parameters) are run, benchmarking them and selecting the best one. Since I am new of R a skeleton procedure with useful functions would help me a lot in setting up this test. Thank you very much, Massimo. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting Multiple Linear Regression Summary
On Wed, 9 Nov 2011, Marc Schwartz wrote: # 'DF' is the result of copying your data above from the # clipboard on OSX DF - read.table(pipe(pbpaste), header = TRUE) Marc, Oh? I don't do Apple so there's no OSX here. After removing incomplete records (any records with NA values) which is the default behavior for R model functions, you only have one record left to fit the model to. That's what I saw from the scatter plots. Thanks, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting Multiple Linear Regression Summary
On Wed, 9 Nov 2011, John C Frain wrote: As far as I know if there is an NA in any variable in an observation the default is to drop the entire observation. Thus there are no observations in your calculation John, Hadn't realized that. I know there are NA's in other data frames that yield model results. Perhaps it is the excessive numbers in this set that are the problem. Thanks, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] raking weighting
On Nov 9, 2011, at 2:27 PM, Sebastián Daza wrote: Hi everyone, Does anyone know if there is a package to compute raking weights using R? What I need is to create a variable with weights base in some demographic variables (e.g. sexo, age group, area) using the raking procedure. There is a `rake` function in package survey. In the future you ought to do this at the R console _before_ sending a question to R-help: RSiteSearch(raking) Thank you in advance! -- Sebastián Daza __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Interpreting Multiple Linear Regression Summary
On 09-Nov-11 19:39:54, Rich Shepard wrote: On Wed, 9 Nov 2011, John C Frain wrote: As far as I know if there is an NA in any variable in an observation the default is to drop the entire observation. Thus there are no observations in your calculation John, Hadn't realized that. I know there are NA's in other data frames that yield model results. Perhaps it is the excessive numbers in this set that are the problem. Thanks, Rich It is not so much the number of NAs, as the number of observations that get dropped through having at least 1 NA. Provided enough observations remain to get a meaningful fit, you will be OK (though interpretation may be dubious). Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 09-Nov-11 Time: 20:06:24 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot stat_summary (mean_cl_boot)
Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. Many thanks for clearing this up for me, Nate [[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] raking weighting
I did. However, I am not sure that I can create a weight variable in my database with the rake function you mention. That is why I am asking. El día 9 de noviembre de 2011 13:44, David Winsemius dwinsem...@comcast.net escribió: On Nov 9, 2011, at 2:27 PM, Sebastián Daza wrote: Hi everyone, Does anyone know if there is a package to compute raking weights using R? What I need is to create a variable with weights base in some demographic variables (e.g. sexo, age group, area) using the raking procedure. There is a `rake` function in package survey. In the future you ought to do this at the R console _before_ sending a question to R-help: RSiteSearch(raking) Thank you in advance! -- Sebastián Daza __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 -- Sebastián Daza __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Compare clustering solutions to a correct one
It sounds like you want to do supervised classification, so maybe a supervised classification algorithm would be more appropriate? Consider logistic regression, rpart, ctree, earth, etc. Andrew -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Massimo Lole Sent: Wednesday, November 09, 2011 12:39 PM To: r-help@r-project.org Subject: [R] Compare clustering solutions to a correct one Hello everyone, I have a set of data, J healthy subjects, K diseased subjects, N features for each person. I would like to clusterize my data. Since I know that subjects are from two populations ideally I would prefer an algorithm that first is able to discriminate them, in order to see how it performs inside each group. I know that R offers several clustering functions and a very interesting clustering compare tool: cluster.stats in fpc package. I would like to ask you if you know of any existing approach where one cluster is considered correct and against it several clustering functions (with several parameters) are run, benchmarking them and selecting the best one. Since I am new of R a skeleton procedure with useful functions would help me a lot in setting up this test. Thank you very much, Massimo. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] raking weighting
On Nov 9, 2011, at 3:07 PM, Sebastián Daza wrote: I did. However, I am not sure that I can create a weight variable in my database with the rake function you mention. That is why I am asking. Since you have provided absolutely no information about the data you have or the problem you are trying to solve, you cannot expect anyone here to tell you what the one right function will be. You need to _do_the_search_yourself_ and determine which (if any) of the 36 hits it brings up are relevant to your (as yet incredibly vague) problem. Further hits are possible if you click the r-help buttons which will them bring up all the questions for the years indicated -- David. El día 9 de noviembre de 2011 13:44, David Winsemius dwinsem...@comcast.net escribió: On Nov 9, 2011, at 2:27 PM, Sebastián Daza wrote: Hi everyone, Does anyone know if there is a package to compute raking weights using R? What I need is to create a variable with weights base in some demographic variables (e.g. sexo, age group, area) using the raking procedure. There is a `rake` function in package survey. In the future you ought to do this at the R console _before_ sending a question to R-help: RSiteSearch(raking) Thank you in advance! -- Sebastián Daza David Winsemius, MD West Hartford, CT -- Sebastián Daza 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] Invalid 'yscale' in viewport
Never mind, I found it -- I had some NA values I didn't know about! I will infer that viewport doesn't handle NA values gracefully! (If I'm wrong about that and I've just missed something key, please correct me.) Erin -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Wednesday, November 09, 2011 12:45 PM To: Erin Jonaitis Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Invalid 'yscale' in viewport Two things: 1) It sounds like you are right in thinking there's something funny about your particular data: could you provide it to us? The easiest way to do so is to use dput() to get a plain text representation ready for copy and paste. 2) What is esplot()? It's not in base R, but I imagine you are referring to Deepayn's script here: http://www.stat.wisc.edu/~deepayan/771/esplot.R ? Just to confirm in case there is something that needs looking at in the code. Thanks, Michael On Wed, Nov 9, 2011 at 10:20 AM, Erin Jonaitis jonai...@wisc.edu wrote: I tried Googling for help on this problem, but what I saw only increased my puzzlement. I found a lovely bit of code called esplot() that makes scatterplots with associated histograms and rug plots. I have been trying to use it on my own data, but the viewport routine on which it depends (I think) is choking on the data I'm trying to plot. $ Error in valid.viewport(...) : Invalid 'yscale' in viewport When I Google this error, I see that others get this message when trying to plot dates. However, my data are two numeric vectors. The strange part is that these vectors are in fact date differences -- they started life as dates -- but I've already converted them to numeric, like so: $ cogdiff - as.numeric(cogdate - scandate)/365.24 $ labdiff - as.numeric(labdate - scandate)/365.24 When I check is(cogdiff) and is(labdiff) it tells me that both are numeric vectors. And if I put these variables into other plotting routines (e.g. plot(), qplot()), I get the expected output. So on some level the conversion to numeric has worked. However: as a sanity check I also tried the esplot() routine on two random vectors I generated, and it DID work on those -- no error message. So I don't think I'm missing any other key dependencies. Something else must be funny about my cogdiff and labdiff variables, but I'm at a loss about what it could be and am looking for suggestions. Thanks in advance... Erin Jonaitis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Invalid 'yscale' in viewport
Thanks for your quick response, Michael. That is indeed the script I was talking about -- I didn't see it in a standard package, so I just copied it and ran it as a standalone thing. I'm afraid the data are proprietary (human subjects, health data) and so I can't share them. I was able to confirm, though, that it must be something funny about my data -- I tried the esplot() code again with some data I generated by creating random dates, subtracting them, and converting them back to numeric, and that worked just fine. I will take a look at my data more closely and see if anything strikes me. I haven't worked with dates that much in the past, so I'm a bit naïve about what could be wrong; if you can think of any common pitfalls, I would be happy to know. Many thanks, Erin -Original Message- From: R. Michael Weylandt [mailto:michael.weyla...@gmail.com] Sent: Wednesday, November 09, 2011 12:45 PM To: Erin Jonaitis Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Invalid 'yscale' in viewport Two things: 1) It sounds like you are right in thinking there's something funny about your particular data: could you provide it to us? The easiest way to do so is to use dput() to get a plain text representation ready for copy and paste. 2) What is esplot()? It's not in base R, but I imagine you are referring to Deepayn's script here: http://www.stat.wisc.edu/~deepayan/771/esplot.R ? Just to confirm in case there is something that needs looking at in the code. Thanks, Michael On Wed, Nov 9, 2011 at 10:20 AM, Erin Jonaitis jonai...@wisc.edu wrote: I tried Googling for help on this problem, but what I saw only increased my puzzlement. I found a lovely bit of code called esplot() that makes scatterplots with associated histograms and rug plots. I have been trying to use it on my own data, but the viewport routine on which it depends (I think) is choking on the data I'm trying to plot. $ Error in valid.viewport(...) : Invalid 'yscale' in viewport When I Google this error, I see that others get this message when trying to plot dates. However, my data are two numeric vectors. The strange part is that these vectors are in fact date differences -- they started life as dates -- but I've already converted them to numeric, like so: $ cogdiff - as.numeric(cogdate - scandate)/365.24 $ labdiff - as.numeric(labdate - scandate)/365.24 When I check is(cogdiff) and is(labdiff) it tells me that both are numeric vectors. And if I put these variables into other plotting routines (e.g. plot(), qplot()), I get the expected output. So on some level the conversion to numeric has worked. However: as a sanity check I also tried the esplot() routine on two random vectors I generated, and it DID work on those -- no error message. So I don't think I'm missing any other key dependencies. Something else must be funny about my cogdiff and labdiff variables, but I'm at a loss about what it could be and am looking for suggestions. Thanks in advance... Erin Jonaitis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Interpreting Multiple Linear Regression Summary
There is only one row with a complete set of observations; I think lm() is throwing out the rest. Rich Shepard wrote: On Wed, 9 Nov 2011, John C Frain wrote: As far as I know if there is an NA in any variable in an observation the default is to drop the entire observation. Thus there are no observations in your calculation John, Hadn't realized that. I know there are NA's in other data frames that yield model results. Perhaps it is the excessive numbers in this set that are the problem. Thanks, Rich __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-Multiple-Linear-Regression-Summary-tp4020516p4021352.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] Interpreting Multiple Linear Regression Summary
This is the output of dput(your data) structure(list(Ca = c(NA, NA, 24.4, NA, 21.4, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 28, 32, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 34.7, NA, 42.5, NA, 26, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 0.6, 21.4, NA, 48.3, 63.5, NA, NA, 28.7, NA, NA, NA, NA, 64.3, 23), Cl = c(1.58, 5.6, 3, NA, 1, 5, 1.2, 4, 4, 8.4, 1, 1.4, 4.9, 1.7, 2, 1.6, 3.3, 2.2, 9, 1, 2, 1, 1, 5, 4, 3, 2.27, 1.76, 5.81, 4.23, 4.23, 6.25, 6.72, 4, NA, 5, 5.8, 5.8, 2.2, 5.4, 5.4, 4.8, 8, 1, 4.8, 5.9, 5.9, 13, 5.6, 1.2, NA, NA, NA, 3, 7, NA, NA, 2, NA, NA, NA, NA, 7, 4.1), Cond = c(NA, NA, 190, 187, 184, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 248, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 304, 354, 379, NA, 300, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 2.2, 187, 285, 378, 533, 207, 262, 244, 238, 280, 380, 402, 636, 300), Mg = c(NA, NA, 10, NA, 9.1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 11, 12, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 17.4, NA, 21.1, NA, 24, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 9.5, NA, 22.1, 29.9, NA, NA, 12.6, NA, NA, NA, NA, 32.4, 21), Na = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 4L, 4L, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), SO4 = c(9.4, 6.5, 9, NA, 7, 55, 6.8, 105, 15.6, 8.4, 8.8, 19.4, 37, 12, 10, 9.1, 34, 11, 69, 18, 9, 13, 9, 7, 6, 5, 7.8, 7.8, 7.5, 6, 7.3, 7, 7.5, 6, 7, 7, 5.6, 5.6, 5.4, 11, 10.5, 9.9, 11.7, 8.4, 12.1, 16, 20, 7.6, 17, 6.5, NA, 8, 22, 24, 44, NA, 13, 13, 12, 18, 23, 23, 73, 4), TDS = c(105L, 181L, 112L, 144L, 114L, 308L, 96L, 430L, 108L, 108L, 125L, 129L, 360L, 140L, 95L, 120L, 280L, 130L, 352L, 148L, 107L, 125L, 139L, 188L, 201L, 178L, 197L, 187L, 182L, 165L, 186L, 191L, 190L, 176L, 175L, 220L, 163L, 163L, 152L, 221L, 171L, 204L, 174L, 190L, 174L, 210L, 190L, 180L, 200L, 180L, NA, 120L, 135L, 228L, 14L, NA, 156L, 140L, 128L, 160L, 215L, 230L, 316L, 163L)), .Names = c(Ca, Cl, Cond, Mg, Na, SO4, TDS), class = data.frame, row.names = c(NA, -64L)) B77S wrote: Please see ?dput use dput(your data) and paste the output into a reply, thanks. This way we know what you are working with. Rich Shepard wrote: I would appreciate pointers on what I should read to understand this output: summary(lm(TDS ~ Cond + Ca + Cl + Mg + Na + SO4)) Call: lm(formula = TDS ~ Cond + Ca + Cl + Mg + Na + SO4) Residuals: ALL 1 residuals are 0: no residual degrees of freedom! Coefficients: (6 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept) 125 NA NA NA Cond NA NA NA NA CaNA NA NA NA ClNA NA NA NA MgNA NA NA NA NaNA NA NA NA SO4 NA NA NA NA Residual standard error: NaN on 0 degrees of freedom (63 observations deleted due to missingness) When I look at the summary for the data frame used for this model I do not see an excessive number of missing values or indications why there are no residual degrees of freedom. The same model applied to 8 other data frames did not produce similar results. Puzzled, Rich __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-Multiple-Linear-Regression-Summary-tp4020516p4021355.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] ggplot stat_summary (mean_cl_boot)
On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot stat_summary(mean_cl_boot)
David Winsemius dwinsemius at comcast.net writes: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. In defense of the OP, this is a very confusing situation. mean_cl_boot is a ggplot2 function that wraps smean.cl.boot from the Hmisc package: it's almost impossible to figure this out from looking at the raw code of mean_cl_boot, although the help page for ?mean_cl_boot does reference smean.cl.boot. ?smean.cl.boot (in Hmisc, so you'll need to have that package loaded) has a B=1000 parameter for bootstrapping. I don't know if stat_summary(fun.data=mean_cl_boot,B=1) will work or not, but it would be worth a try (try setting B to a small number and see if your CIs get very noisy, or set it to a large number and see if your plot starts taking a lot longer to compute ...) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot stat_summary (mean_cl_boot)
On Nov 9, 2011, at 4:10 PM, David Winsemius wrote: mean_cl_boot OK. Things do change. Hadley has written a wrapper for some of the Hmisc functions and you appear to be looking for smean.cl.boot() (Note that Hadley's functions use _'s and Harrells use .'s. And this could be found by ??mean_cl_boot # at the R console And then reading the help page for the wrap_hmisc function, the only entry that came up on my machine. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot stat_summary (mean_cl_boot)
Sorry, I didn't realize I was being so obscure. Within ggplot it is possible to use stat_summary() to generate confidence intervals about a mean. One method for generating these CI assumes normality. The other uses bootstrapping to generate the CI. I am using the second method which requires code like this stat_summary(fun.data=mean_cl_boot, geom=errorbar,width=0.1,colour = red) I've added some extra flourishes to make them look like errorbars, alter the width and specify color. I would like some details regarding how this bootstrapped CI is calculated. If I type ?mean_cl_boot at the R command line I get a minimal help file for wrap_hmisc {ggplot2} which is described wrap up a selection of Hmisc to make it easy to use with stat_summary I did not mean to suggest that ggplot2 calls Hmisc when I run stat_summary(), but simply that it appears that stat_summary() seems to have been based upon a selection of Hmisc, hence I went looking in Hmisc to try to find details regarding stat_summary(). I was unsuccessful in this attempt. I don't believe a great deal of debugging is necessary. I am simply looking for details regarding how mean_cl_boot works. If you don't have information regarding how it works (such as the default number of resamplings) there is no need to respond. Thanks for any assistance, Nate On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius dwinsem...@comcast.netwrote: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_**cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. -- 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.
Re: [R] Help with tryCatch with a for loop
Without a sample data set that fails the first pass and succeeds on the second pass this is a pain to test. Don't forget to read the posting guide... Reproducible sample code isn't too reproducible without some specified data or autogenerated data. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Spencer S scheid...@gmail.com wrote: Hello all, I'm a beginner in R working on a script that will produce a set of models (linear, polynomial and logistic) for each location in a dataset. However, the self-starting logistic model often fails - if this happens I would like to just skip to the next iteration of the loop using tryCatch. I've looked at a few examples and read the help file, but didn't understand tryCatch in the context of my script. Any help or suggestions (even telling me where to insert the tryCatch command) would be much appreciated!! Below is the script I am currently working on: data-read.csv(file.choose(),sep=,,header=T) #File name is cbc.subset data$location.code = as.character(data$location.code) locs = unique(location.code) pdf(mygraphs.pdf,height=8, width=10) par(mfrow=c(3,4)) for(s in 1:length(locs)){ #To plot data from a particular stateroute: sub.ECDO-data[data$location.code == locs[s],] plot(abund~year, data=sub.ECDO, main=locs[s]) #To plot the linear model for the specified location: lmodel-lm(abund~year, data=sub.ECDO) abline(lmodel$coefficients[1],lmodel$coefficients[2],lty=2) #To plot the polynomial model for the specified location: polymodel-lm(abund~year+I(year^2), data=sub.ECDO) xv-seq(min(sub.ECDO$year),max(sub.ECDO$year),0.1) yv-predict(polymodel,list(year=xv)) lines(xv,yv) #To plot the logistic model #tryCatch logis-nls(abund~SSlogis(year,a,b,c),data=sub.ECDO) yv-predict(logis,list(year=xv)) lines(xv,yv) #To find which model is the best fit: if (logis %in% ls()) { AIC.results = AIC(lmodel,polymodel,logis) } else { AIC.results = AIC(lmodel,polymodel) } #Add text to plot text(min(sub.ECDO$year)+2,0.9*max(sub.ECDO$abund),paste(linear = ,AIC.results[1,2],\npolynomial = ,AIC.results[2,2],\nlogistic = ,AIC.results[3,2],sep=)) rm(logis) rm(polymodel) rm(lmodel) } dev.off() Thank you! -- View this message in context: http://r.789695.n4.nabble.com/Help-with-tryCatch-with-a-for-loop-tp4020475p4020475.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Stack trace?
Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.na(x) !is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help trace down the problem. Is there some function or technique that I could use to help get a call stack? Thank you. Kevin [[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] installing java on ubuntu 11.10 installation
Dear list members, I am starting to get acquainted with linux on a ubuntu 11.10 installation on an external hard disk. I have just installed R and all the packages available in the r-cran-* list. Now, I would like to get on with the installation of packages like Deducer and Acinonyx. The former requires JGR which in turn requires Java. I have tried to follow the instructions available at the following link on the R wiki : http://rwiki.sciviews.org/doku.php?id=getting-started:installation:debian which in turn points at : http://rosuda.org/JGR/linux But these instructions do not seem to have worked. I get the following output : ravi@raviM1330:~$ java -version The program 'java' can be found in the following packages: * gcj-4.4-jre-headless * gcj-4.6-jre-headless * openjdk-6-jre-headless * gcj-4.5-jre-headless * openjdk-7-jre-headless Try: sudo apt-get install selected package ravi@raviM1330:~$ I would like to know how I should install java. Is it preferable to install the sun jdk version or the open jdk? By doing a search on R seek, I don't see any instructions on the currently valid procedure for installiing java. I would appreciate getting help on installation and sufficient configuration. Also, on first uninstalling whatever I have installed with the command : sudo apt-get install sun-java* Before this, I tried with : sudo apt-get install sun-java6-jdk But nothing seemed to happen after this (as far as I can remember). Thanks, Ravi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stack trace?
On Thu, Nov 10, 2011 at 10:35 AM, rkevinbur...@charter.net wrote: Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.na(x) !is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help trace down the problem. Is there some function or technique that I could use to help get a call stack? traceback() gets you a stack trace at the last error options(warn=2) makes warnings into errors options(error=recover) starts the post-mortem debugger at any error, allowing you to inspect the stack interactively. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot stat_summary (mean_cl_boot)
Ok, I got it. smean.cl.boot(x, conf.int=.95, B=1000, na.rm=TRUE, reps=FALSE) Looks like its 1000. Cool. Thanks for the help, Nate On Wed, Nov 9, 2011 at 1:35 PM, Nathan Miller natemille...@gmail.comwrote: Sorry, I didn't realize I was being so obscure. Within ggplot it is possible to use stat_summary() to generate confidence intervals about a mean. One method for generating these CI assumes normality. The other uses bootstrapping to generate the CI. I am using the second method which requires code like this stat_summary(fun.data=mean_cl_boot, geom=errorbar,width=0.1,colour = red) I've added some extra flourishes to make them look like errorbars, alter the width and specify color. I would like some details regarding how this bootstrapped CI is calculated. If I type ?mean_cl_boot at the R command line I get a minimal help file for wrap_hmisc {ggplot2} which is described wrap up a selection of Hmisc to make it easy to use with stat_summary I did not mean to suggest that ggplot2 calls Hmisc when I run stat_summary(), but simply that it appears that stat_summary() seems to have been based upon a selection of Hmisc, hence I went looking in Hmisc to try to find details regarding stat_summary(). I was unsuccessful in this attempt. I don't believe a great deal of debugging is necessary. I am simply looking for details regarding how mean_cl_boot works. If you don't have information regarding how it works (such as the default number of resamplings) there is no need to respond. Thanks for any assistance, Nate On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius dwinsem...@comcast.netwrote: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_**cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. -- 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.
Re: [R] raking weighting
2011/11/10 Sebastián Daza sebastian.d...@gmail.com: I did. However, I am not sure that I can create a weight variable in my database with the rake function you mention. That is why I am asking. Yes, you can. -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Kmeans with hamming distance?
Hello, I need to do kmeans clustering with hamming distance instead of the euclidean. The kmeans function only uses euclidean. How can I do it? Thank you Rui [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot stat_summary (mean_cl_boot)
On Nov 9, 2011, at 4:35 PM, Nathan Miller wrote: Sorry, I didn't realize I was being so obscure. Within ggplot it is possible to use stat_summary() to generate confidence intervals about a mean. One method for generating these CI assumes normality. The other uses bootstrapping to generate the CI. I am using the second method which requires code like this stat_summary(fun.data=mean_cl_boot, geom=errorbar,width=0.1,colour = red) I've added some extra flourishes to make them look like errorbars, alter the width and specify color. I would like some details regarding how this bootstrapped CI is calculated. If I type ?mean_cl_boot at the R command line I get a minimal help file for wrap_hmisc {ggplot2} which is described wrap up a selection of Hmisc to make it easy to use with stat_summary I did not mean to suggest that ggplot2 calls Hmisc when I run stat_summary(), Actually it does. but simply that it appears that stat_summary() seems to have been based upon a selection of Hmisc, hence I went looking in Hmisc to try to find details regarding stat_summary(). I was unsuccessful in this attempt. I don't believe a great deal of debugging is necessary. I am simply looking for details regarding how mean_cl_boot works. It doesn't. That is not the right name. If you don't have information regarding how it works (such as the default number of resamplings) there is no need to respond. Hadley's help files in ggplot2 are terse (or the links to outside resources crash my R sessions) to the point of being too frustrating for me to consider using that package, so I don't know if optional parameters can be passed to the Hmisc functions. If they are, then you should set reps=TRUE and then see what happens to the number of reps from the returned object ... if the wrap_hmisc function does happen to catch it. x - rnorm(100) smean.cl.boot(x) Mean Lower Upper -0.0211511 -0.2013623 0.1469728 smean.cl.boot(x, reps=TRUE) Mean Lower Upper -0.03465361 -0.21233213 0.15178655 attr(,reps) [1] 0.0283330508 -0.1250784237 0.0744640779 0.1310826601 -0.1373094536 [6] 0.0629291714 0.0145916070 -0.0860141221 0.0549134451 0.0732892908 snipped pages of intervening output. [991] 0.1029922424 0.0613358597 -0.0645577851 -0.1664905503 -0.1249615180 [996] -0.0751783377 -0.0043747455 -0.1155948060 -0.0750075659 0.1244430930 I don't see where the number of reps is returned, but the B setting defaults to 1000. -- david. Thanks for any assistance, Nate On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. -- 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] ggplot stat_summary(mean_cl_boot)
On Nov 9, 2011, at 4:30 PM, Ben Bolker wrote: David Winsemius dwinsemius at comcast.net writes: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in the way of context to support debugging efforts). You are referring to ggplot functions. As far as I know there is no connection between the Hmisc and ggplot (or ggplot2) packages. Al things change, I know, but Frank just completed switching over to Lattice a couple of years ago. In defense of the OP, this is a very confusing situation. mean_cl_boot is a ggplot2 function Another ggplot2 function with no help page, although it does bring up a help page with a link to smean.cl.boot that wraps smean.cl.boot from the Hmisc package: it's almost impossible to figure this out from looking at the raw code of mean_cl_boot, although the help page for ?mean_cl_boot does reference smean.cl.boot. Right. And the code for mean_cl_boot threatens to pass any extra parameters. But I'm still scratching my head about how smean.cl.boot get called because it is never mentioned by name and then there is an ignore.dots parameter that apparently renegs on the promise to pass the B argument. ?smean.cl.boot (in Hmisc, so you'll need to have that package loaded) has a B=1000 parameter for bootstrapping. As I almost always do. I don't know if stat_summary(fun.data=mean_cl_boot,B=1) Might need to be: stat_summary(fun.data=mean_cl_boot,B=1, ignore.dots=FALSE) will work or not, but it would be worth a try (try setting B to a small number and see if your CIs get very noisy, or set it to a large number and see if your plot starts taking a lot longer to compute ...) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] latent class models
I would like to extract the information criteria from an hlme object (lcmm package). Would you please advise me on how to extract just the BIC (AIC)? On another topic, when I apply hlme (lcmm) and flexmix (flexmix package) to the same data set, I get BIC values that suggest two different latent class structures. Flexmix using FLXMRlmm predicts two classes while hlme says 4. Can you suggest a reason? Respectfully, Frank Lawrence [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R to automate scatter plots
Hi R people! I have a directory of .csv files I would like to make into objects then scatter plots. I have been having varying degrees of progress. I was able make an object of all files, loop through it, and make a pdf of the last file I looped through. I kept renaming the pdf so instead of ending up with 27 pdfs I got one, with the data from the last file I have been tweaking with it and now can't even make the data object and I am not sure why. I am a bit brain dead at this point :) I am new to R and have been programming in perl - but not all that long Could you please have al look at it.. here is the script I have been using # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/ fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex #test-files[i] # tried to use as variable to name each pdf this object is the name of last file in loop data - read.csv(files[i]) # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well pdf(data.pdf) plot(data$fpkma,data$fpkmb, main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) dev.off() } # change back to the original directory setwd(initial.dir) the command I have been using : R CMD BATCH /data/homes/ccpage/ngs/rscripts/test_for.R The Rout # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/ fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ + # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex + #test-files[i] # tried to use as variable to name each pdf this object is the name of last file + +data - read.csv(files[i]) + + # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf + # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well + + pdf(data.pdf) + plot(data$fpkma,data$fpkmb,main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) + dev.off() + } Error in plot.window(...) : need finite 'xlim' values Calls: plot - plot.default - localWindow - plot.window In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf Execution halted Thanks for any help! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] path.diagram in SEM--display covariances without variances
Dear Dustin, -Original Message- From: Dustin Fife [mailto:fife.dus...@gmail.com] Sent: November-09-11 2:12 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] path.diagram in SEM--display covariances without variances Thanks for the quick response...I've never edited someone else's package before. How do I go about doing that? I wouldn't change the sem package, but rather create your own version of pathDiagram(). You could examine the package sources, but, more simply, to see the code for the function, type its name at the command prompt: library(sem) Loading required package: MASS Loading required package: matrixcalc pathDiagram function (model, ...) { UseMethod(pathDiagram) } bytecode: 06E1CEA8 environment: namespace:sem So pathDiagram() is a generic function. What methods are available? methods(pathDiagram) [1] pathDiagram.sem* Non-visible functions are asterisked There is, therefore just one method, for objects of class sem, hidden in the sem namespace. To see it (most lines elided): sem:::pathDiagram.sem function (model, file, min.rank = NULL, max.rank = NULL, same.rank = NULL, variables = model$var.names, parameters = rownames(model$ram), ignore.double = TRUE, edge.labels = c(names, values, both), size = c(8, 8), node.font = c(Helvetica, 14), edge.font = c(Helvetica, 10), rank.direction = c(LR, TB), digits = 2, standardize = FALSE, output.type = c(graphics, dot), graphics.fmt = pdf, dot.options = NULL, ...) { . . . cat(file = handle, }\n) if (output.type == graphics !missing(file)) { cmd - paste(dot -T, graphics.fmt, -o , graph.file, , dot.options, , dot.file, sep = ) cat(Running , cmd, \n) result - try(system(cmd)) } invisible(NULL) } bytecode: 071B9568 environment: namespace:sem Just copy the functions into an editor and make whatever changes you want. Best, John On Wed, Nov 9, 2011 at 12:47 PM, John Fox j...@mcmaster.ca wrote: Dear Dustin, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Dustin Fife Sent: November-09-11 10:57 AM To: r-help@r-project.org Subject: [R] path.diagram in SEM--display covariances without variances Forgive me if I'm posting to the wrong placeIt's my first time posting. Here's the situation: I'm using the sem package and making path diagrams using path.diagrams. Suppose I have the following code: . . . The diagram is produces is hard to read because of the many variances that are shown. The covariance estimates are important for my diagram, but the variances are not. Is there a way to suppress the variance arrows without suppressing the covariance arrows? No, but (1) pathDiagram() (the name of the function in the current version of the sem package) produces an editable text file, from which you could remove the arrows that you don't want to see; and (2) you could modify pathDiagram() -- the code for the function is, after all, available to you -- so that it does what you want. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -- Dustin Fife Graduate Student, Quantitative Psychology University of Oklahoma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Dustin Fife Fife Photography www.fifephotography.com i...@fifephotography.com fife.dus...@gmail.com 405.414.5599 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 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 to automate scatter plots
On Nov 9, 2011, at 4:22 PM, Cynthia Lee Page wrote: Hi R people! I have a directory of .csv files I would like to make into objects then scatter plots. I have been having varying degrees of progress. I was able make an object of all files, loop through it, and make a pdf of the last file I looped through. I kept renaming the pdf so instead of ending up with 27 pdfs I got one, with the data from the last file I have been tweaking with it and now can't even make the data object and I am not sure why. I am a bit brain dead at this point :) I am new to R and have been programming in perl - but not all that long Could you please have al look at it.. here is the script I have been using # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/ fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex #test-files[i] # tried to use as variable to name each pdf this object is the name of last file in loop data - read.csv(files[i]) # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well pdf(data.pdf) At this point you might have been better off if you had just typed: pdf() The default name for a pdf document is set by this code from the help page for pdf() pdf(file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf), Notice that %03d. That means the system pots in a number tthat is one grater than the largest current Rplot_N.pdf in the directory. plot(data$fpkma,data$fpkmb, main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) dev.off() } # change back to the original directory setwd(initial.dir) the command I have been using : R CMD BATCH /data/homes/ccpage/ngs/rscripts/test_for.R The Rout # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/ fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ + # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex + #test-files[i] # tried to use as variable to name each pdf this object is the name of last file + +data - read.csv(files[i]) + + # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf + # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well + + pdf(data.pdf) + plot(data$fpkma,data$fpkmb,main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) + dev.off() + } Error in plot.window(...) : need finite 'xlim' values Without the data that created that error, we are not going to be able to give a clear answer. Calls: plot - plot.default - localWindow - plot.window In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf Execution halted Thanks for any help!\ 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] Web based R-help not a list
Hello, Is there a web version of this R-Help user group (such as the ones under Google Groups) such that 1. I can do a search on any topic over thousands of posts on R easily and effectively 2. My mailbox do not overflow with emails so that I do not need to edit it every day 3. I can arrange to receive only the responses to my posts automatically 4. The content of the post might be better formatted for more information other than just the text (we now have HTML!) 5. I can attach pictures to my posts for questions related to plots, results etc. be quick and effective rather than just links to other sites Sincerely, Cem Girit [[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] [ reached getOption(max.print) -- omitted 8178 rows ]]
Hi, I have a weird thing I don¹t understand. Here¹s what I did: I read some data: data=read.table(fileName²) then I printed the data to the screen: data But it didn¹t finish: lot¹s of data was written out, but not all of it... Then it interrupted and said: [ reached getOption(max.print) -- omitted 8178 rows ]] Is there a setting somewhere that I can change to get to see all of my data? Thanks Sean [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with tryCatch with a for loop
My apologies for not including some test data. Attached is a sample dataset that fails with the first stateroute and works with the second. http://r.789695.n4.nabble.com/file/n4021696/testdata.csv testdata.csv -- View this message in context: http://r.789695.n4.nabble.com/Help-with-tryCatch-with-a-for-loop-tp4020475p4021696.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] Web based R-help not a list
On Nov 9, 2011, at 5:38 PM, Cem Girit wrote: Hello, Is there a web version of this R-Help user group (such as the ones under Google Groups) such that There is Nabble. It's not going to make you any friends unless you learn to post in plain text AND to include context ... too often not done by Nabble users. Gmane is also a possible website that can mirror rhelp. 1. I can do a search on any topic over thousands of posts on R easily and effectively Yes, several. Have you read the information page and the posting guide yet? 2. My mailbox do not overflow with emails so that I do not need to edit it every day Yes. You were offered an option to get a digest when you signed up. 3. I can arrange to receive only the responses to my posts automatically Most people reply to both the poster and the the list, but there is no enforcement mechanism. Your unwillingness to do any extra work to educate yourself is duly noted. Speaking only for myself, I will NOT respond to any of your further posts because of your demonstrated privileged attitude. It would not bother me if other regular readers followed my example. 4. The content of the post might be better formatted for more information other than just the text (we now have HTML!) We do not agree that HTML is a better format. You are welcome to take your questions elsewhere if plain text is not acceptable. 5. I can attach pictures to my posts for questions related to plots, results etc. be quick and effective rather than just links to other sites .pdf and .txt files are acceptable attachments. [[alternative HTML version deleted]] I say again: You are welcome to take your questions elsewhere if plain text is not acceptable. -- 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] Stack trace?
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley Sent: Wednesday, November 09, 2011 1:53 PM To: rkevinbur...@charter.net Cc: r-help Subject: Re: [R] Stack trace? On Thu, Nov 10, 2011 at 10:35 AM, rkevinbur...@charter.net wrote: Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.na(x) !is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help trace down the problem. Is there some function or technique that I could use to help get a call stack? traceback() gets you a stack trace at the last error options(warn=2) makes warnings into errors options(error=recover) starts the post-mortem debugger at any error, allowing you to inspect the stack interactively. And options(warning.expression=quote(recover())) will start that same debugger at each warning. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Web based R-help not a list
Such a resource would no longer be R-help. You might like stackoverflow. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Cem Girit gi...@biopticon.com wrote: Hello, Is there a web version of this R-Help user group (such as the ones under Google Groups) such that 1. I can do a search on any topic over thousands of posts on R easily and effectively 2. My mailbox do not overflow with emails so that I do not need to edit it every day 3. I can arrange to receive only the responses to my posts automatically 4. The content of the post might be better formatted for more information other than just the text (we now have HTML!) 5. I can attach pictures to my posts for questions related to plots, results etc. be quick and effective rather than just links to other sites Sincerely, Cem Girit [[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] Stack trace?
To Bill's suggestion for a stack trace on warnings: Question: What would this do in situations where one might get, e.g. 100 warnings? -- Bert On Wed, Nov 9, 2011 at 3:08 PM, William Dunlap wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley Sent: Wednesday, November 09, 2011 1:53 PM To: rkevinbur...@charter.net Cc: r-help Subject: Re: [R] Stack trace? On Thu, Nov 10, 2011 at 10:35 AM, rkevinbur...@charter.net wrote: Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.na(x) !is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help trace down the problem. Is there some function or technique that I could use to help get a call stack? traceback() gets you a stack trace at the last error options(warn=2) makes warnings into errors options(error=recover) starts the post-mortem debugger at any error, allowing you to inspect the stack interactively. And options(warning.expression=quote(recover())) will start that same debugger at each warning. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] path.diagram in SEM--display covariances without variances
Perfect! Thanks for the help. On Wed, Nov 9, 2011 at 4:27 PM, John Fox j...@mcmaster.ca wrote: Dear Dustin, -Original Message- From: Dustin Fife [mailto:fife.dus...@gmail.com] Sent: November-09-11 2:12 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] path.diagram in SEM--display covariances without variances Thanks for the quick response...I've never edited someone else's package before. How do I go about doing that? I wouldn't change the sem package, but rather create your own version of pathDiagram(). You could examine the package sources, but, more simply, to see the code for the function, type its name at the command prompt: library(sem) Loading required package: MASS Loading required package: matrixcalc pathDiagram function (model, ...) { UseMethod(pathDiagram) } bytecode: 06E1CEA8 environment: namespace:sem So pathDiagram() is a generic function. What methods are available? methods(pathDiagram) [1] pathDiagram.sem* Non-visible functions are asterisked There is, therefore just one method, for objects of class sem, hidden in the sem namespace. To see it (most lines elided): sem:::pathDiagram.sem function (model, file, min.rank = NULL, max.rank = NULL, same.rank = NULL, variables = model$var.names, parameters = rownames(model$ram), ignore.double = TRUE, edge.labels = c(names, values, both), size = c(8, 8), node.font = c(Helvetica, 14), edge.font = c(Helvetica, 10), rank.direction = c(LR, TB), digits = 2, standardize = FALSE, output.type = c(graphics, dot), graphics.fmt = pdf, dot.options = NULL, ...) { . . . cat(file = handle, }\n) if (output.type == graphics !missing(file)) { cmd - paste(dot -T, graphics.fmt, -o , graph.file, , dot.options, , dot.file, sep = ) cat(Running , cmd, \n) result - try(system(cmd)) } invisible(NULL) } bytecode: 071B9568 environment: namespace:sem Just copy the functions into an editor and make whatever changes you want. Best, John On Wed, Nov 9, 2011 at 12:47 PM, John Fox j...@mcmaster.ca wrote: Dear Dustin, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Dustin Fife Sent: November-09-11 10:57 AM To: r-help@r-project.org Subject: [R] path.diagram in SEM--display covariances without variances Forgive me if I'm posting to the wrong placeIt's my first time posting. Here's the situation: I'm using the sem package and making path diagrams using path.diagrams. Suppose I have the following code: . . . The diagram is produces is hard to read because of the many variances that are shown. The covariance estimates are important for my diagram, but the variances are not. Is there a way to suppress the variance arrows without suppressing the covariance arrows? No, but (1) pathDiagram() (the name of the function in the current version of the sem package) produces an editable text file, from which you could remove the arrows that you don't want to see; and (2) you could modify pathDiagram() -- the code for the function is, after all, available to you -- so that it does what you want. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -- Dustin Fife Graduate Student, Quantitative Psychology University of Oklahoma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. -- Dustin Fife Fife Photography www.fifephotography.com i...@fifephotography.com fife.dus...@gmail.com 405.414.5599 -- Dustin Fife Fife Photography www.fifephotography.com i...@fifephotography.com fife.dus...@gmail.com 405.414.5599 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with tryCatch with a for loop
If your loop is of the form for(i in 1:n) { doSomethingSafe() x - doSomethingThatFailsSometimes() doSomethingWithX(x) # cannot do this if previous line fails doSomethingElseSafe() } and you want it to somehow recover when doSomethingThatFailsSometimes() throws an error, then change it to use try() with for(i in 1:n) { doSomethingSafe() tmp - try({ x - doSomethingThatFailsSometimes() doSomethingWithX(x) }) if (inherits(try, try-error)) { recoverFromFailure() } doSomethingElseSafe() } or to use tryCatch() with for(i in 1:n) { doSomethingSafe() tryCatch({ x - doSomethingThatFailsSometimes() doSomethingWithX(x) }, error = function(e) { message(Had a problem at iteration , i, : , conditionMessage(e)) recoverFromFailure() }) doSomethingElseSafe() } Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Spencer S Sent: Wednesday, November 09, 2011 2:57 PM To: r-help@r-project.org Subject: Re: [R] Help with tryCatch with a for loop My apologies for not including some test data. Attached is a sample dataset that fails with the first stateroute and works with the second. http://r.789695.n4.nabble.com/file/n4021696/testdata.csv testdata.csv -- View this message in context: http://r.789695.n4.nabble.com/Help-with-tryCatch-with-a-for-loop- tp4020475p4021696.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] Web based R-help not a list
Cem, Thanks for your comments. 1. http://cran.r-project.org/ and select Search in the left-hand panel. 2. Use a filter to funnel r-help into it's own area and review as desired. 3. I find that there are many posts that have been quite educational and have helped me with analyses. 4. Although HTML produces pretty posts many of us don't find that the information content is increased. 5. Yes, a picture is often worth 1K words and I'll agree there are times when they are needed. However, mailbox size (a picture is often 10K words or more) may be more important than number of messages. Reproducible code usually is sufficient to demonstrate the problem. Clint -- Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Wed, 9 Nov 2011, Cem Girit wrote: Hello, Is there a web version of this R-Help user group (such as the ones under Google Groups) such that 1. I can do a search on any topic over thousands of posts on R easily and effectively 2. My mailbox do not overflow with emails so that I do not need to edit it every day 3. I can arrange to receive only the responses to my posts automatically 4. The content of the post might be better formatted for more information other than just the text (we now have HTML!) 5. I can attach pictures to my posts for questions related to plots, results etc. be quick and effective rather than just links to other sites Sincerely, Cem Girit [[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] Web based R-help not a list
On 9 November 2011 15:24, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Such a resource would no longer be R-help. You might like stackoverflow. Perhaps our man was looking for a searchable mail archive? If no one has one, I can set one up pretty quickly. Just let me know... Thanks in advance! -- H -- Sent from my mobile device Envoyait de mon portable __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stack trace?
It will call recover() for each warning. When you exit recover() the code continues on. This is handy if you expect the first warning or two but are curious about the third. I'd expect that you could reset options(warning.expression=NULL) when in recover() so that recover() would not be called at the remaining warnings. options(warning.expression=quote(recover())) f - function() { + warning(Hmmm) + retval - c(1,2) + c(5,6,7) + warning(Really?) + retval + } f() Enter a frame number, or 0 to exit 1: f() 2: #2: warning(Hmmm) 3: #2: .signalSimpleWarning(Hmmm, quote(f())) 4: #2: withRestarts({ 5: #2: withOneRestart(expr, restarts[[1]]) 6: #2: doWithOneRestart(return(expr), restart) Selection: 0 Enter a frame number, or 0 to exit 1: f() 2: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 3: #3: withRestarts({ 4: #3: withOneRestart(expr, restarts[[1]]) 5: #3: doWithOneRestart(return(expr), restart) Selection: 1 Called from: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) Browse[1] options(warning.expression=NULL) Browse[1] # hit control-D Browse[1] Enter a frame number, or 0 to exit 1: f() 2: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 3: #3: withRestarts({ 4: #3: withOneRestart(expr, restarts[[1]]) 5: #3: doWithOneRestart(return(expr), restart) Selection: 0 [1] 6 8 8 Warning message: In f() : Really? I think you could also use tryCatch(warning=function(e)...) to only call recover() at certain types of warnings, perhaps by examining the text in conditionMessage(e). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Wednesday, November 09, 2011 3:40 PM To: William Dunlap Cc: r-help Subject: Re: [R] Stack trace? To Bill's suggestion for a stack trace on warnings: Question: What would this do in situations where one might get, e.g. 100 warnings? -- Bert On Wed, Nov 9, 2011 at 3:08 PM, William Dunlap wdun...@tibco.commailto:wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley Sent: Wednesday, November 09, 2011 1:53 PM To: rkevinbur...@charter.netmailto:rkevinbur...@charter.net Cc: r-help Subject: Re: [R] Stack trace? On Thu, Nov 10, 2011 at 10:35 AM, rkevinbur...@charter.netmailto:rkevinbur...@charter.net wrote: Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.nahttp://is.na(x) !is.nahttp://is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help trace down the problem. Is there some function or technique that I could use to help get a call stack? traceback() gets you a stack trace at the last error options(warn=2) makes warnings into errors options(error=recover) starts the post-mortem debugger at any error, allowing you to inspect the stack interactively. And options(warning.expression=quote(recover())) will start that same debugger at each warning. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.comhttp://tibco.com -thomas -- Thomas Lumley Professor of Biostatistics University of Auckland __ R-help@r-project.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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.orgmailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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
Re: [R] path.diagram in SEM--display covariances without variances
For those who have the same question laterafter following John's steps of extracting the function, I just replaced the line of code that says: if ((!ignore.double) || (heads[par] == 1)) with if (((!ignore.double) || (heads[par] == 1)) variables[from[par]] != variables[to[par]]) That seems to do just what I want. Thanks again John! On Wed, Nov 9, 2011 at 5:40 PM, Dustin Fife fife.dus...@gmail.com wrote: Perfect! Thanks for the help. On Wed, Nov 9, 2011 at 4:27 PM, John Fox j...@mcmaster.ca wrote: Dear Dustin, -Original Message- From: Dustin Fife [mailto:fife.dus...@gmail.com] Sent: November-09-11 2:12 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] path.diagram in SEM--display covariances without variances Thanks for the quick response...I've never edited someone else's package before. How do I go about doing that? I wouldn't change the sem package, but rather create your own version of pathDiagram(). You could examine the package sources, but, more simply, to see the code for the function, type its name at the command prompt: library(sem) Loading required package: MASS Loading required package: matrixcalc pathDiagram function (model, ...) { UseMethod(pathDiagram) } bytecode: 06E1CEA8 environment: namespace:sem So pathDiagram() is a generic function. What methods are available? methods(pathDiagram) [1] pathDiagram.sem* Non-visible functions are asterisked There is, therefore just one method, for objects of class sem, hidden in the sem namespace. To see it (most lines elided): sem:::pathDiagram.sem function (model, file, min.rank = NULL, max.rank = NULL, same.rank = NULL, variables = model$var.names, parameters = rownames(model$ram), ignore.double = TRUE, edge.labels = c(names, values, both), size = c(8, 8), node.font = c(Helvetica, 14), edge.font = c(Helvetica, 10), rank.direction = c(LR, TB), digits = 2, standardize = FALSE, output.type = c(graphics, dot), graphics.fmt = pdf, dot.options = NULL, ...) { . . . cat(file = handle, }\n) if (output.type == graphics !missing(file)) { cmd - paste(dot -T, graphics.fmt, -o , graph.file, , dot.options, , dot.file, sep = ) cat(Running , cmd, \n) result - try(system(cmd)) } invisible(NULL) } bytecode: 071B9568 environment: namespace:sem Just copy the functions into an editor and make whatever changes you want. Best, John On Wed, Nov 9, 2011 at 12:47 PM, John Fox j...@mcmaster.ca wrote: Dear Dustin, -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Dustin Fife Sent: November-09-11 10:57 AM To: r-help@r-project.org Subject: [R] path.diagram in SEM--display covariances without variances Forgive me if I'm posting to the wrong placeIt's my first time posting. Here's the situation: I'm using the sem package and making path diagrams using path.diagrams. Suppose I have the following code: . . . The diagram is produces is hard to read because of the many variances that are shown. The covariance estimates are important for my diagram, but the variances are not. Is there a way to suppress the variance arrows without suppressing the covariance arrows? No, but (1) pathDiagram() (the name of the function in the current version of the sem package) produces an editable text file, from which you could remove the arrows that you don't want to see; and (2) you could modify pathDiagram() -- the code for the function is, after all, available to you -- so that it does what you want. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox -- Dustin Fife Graduate Student, Quantitative Psychology University of Oklahoma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-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] Stack trace?
Bert, At the end of my previous message I mentioned tryCatch(). I should have said withCallingHandlers(). E.g., f - function() { + warning(Hmmm) + retval - c(1,2) + c(5,6,7) # warns about incompatible lengths in + + warning(Really?) + retval + } options(warning.expression=NULL) # just in case it had been set withCallingHandlers(f(), warning=function(e){ + cat(encountered warning: , conditionMessage(e), \n) + if (grepl(multiple of shorter, conditionMessage(e))) { recover() } + invokeRestart(muffleWarning) + }) encountered warning: Hmmm encountered warning: longer object length is not a multiple of shorter object length Enter a frame number, or 0 to exit 1: withCallingHandlers(f(), warning = function(e) { 2: f() 3: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 4: #3: withRestarts({ 5: #3: withOneRestart(expr, restarts[[1]]) 6: #3: doWithOneRestart(return(expr), restart) 7: #3: function (e) Selection: 0 encountered warning: Really? [1] 6 8 8 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Wednesday, November 09, 2011 3:51 PM To: Bert Gunter Cc: r-help Subject: Re: [R] Stack trace? It will call recover() for each warning. When you exit recover() the code continues on. This is handy if you expect the first warning or two but are curious about the third. I'd expect that you could reset options(warning.expression=NULL) when in recover() so that recover() would not be called at the remaining warnings. options(warning.expression=quote(recover())) f - function() { + warning(Hmmm) + retval - c(1,2) + c(5,6,7) + warning(Really?) + retval + } f() Enter a frame number, or 0 to exit 1: f() 2: #2: warning(Hmmm) 3: #2: .signalSimpleWarning(Hmmm, quote(f())) 4: #2: withRestarts({ 5: #2: withOneRestart(expr, restarts[[1]]) 6: #2: doWithOneRestart(return(expr), restart) Selection: 0 Enter a frame number, or 0 to exit 1: f() 2: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 3: #3: withRestarts({ 4: #3: withOneRestart(expr, restarts[[1]]) 5: #3: doWithOneRestart(return(expr), restart) Selection: 1 Called from: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) Browse[1] options(warning.expression=NULL) Browse[1] # hit control-D Browse[1] Enter a frame number, or 0 to exit 1: f() 2: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 3: #3: withRestarts({ 4: #3: withOneRestart(expr, restarts[[1]]) 5: #3: doWithOneRestart(return(expr), restart) Selection: 0 [1] 6 8 8 Warning message: In f() : Really? I think you could also use tryCatch(warning=function(e)...) to only call recover() at certain types of warnings, perhaps by examining the text in conditionMessage(e). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Wednesday, November 09, 2011 3:40 PM To: William Dunlap Cc: r-help Subject: Re: [R] Stack trace? To Bill's suggestion for a stack trace on warnings: Question: What would this do in situations where one might get, e.g. 100 warnings? -- Bert On Wed, Nov 9, 2011 at 3:08 PM, William Dunlap wdun...@tibco.commailto:wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.orgmailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley Sent: Wednesday, November 09, 2011 1:53 PM To: rkevinbur...@charter.netmailto:rkevinbur...@charter.net Cc: r-help Subject: Re: [R] Stack trace? On Thu, Nov 10, 2011 at 10:35 AM, rkevinbur...@charter.netmailto:rkevinbur...@charter.net wrote: Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.nahttp://is.na(x) !is.nahttp://is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help trace down the problem. Is there some function or technique that I could use to help get a call stack? traceback() gets you a stack trace at
Re: [R] algorithm that iteratively drops columns of a data-frame
great, thank you both! On 09.11.2011, at 17:27, Jeff Newmiller wrote: Try data[,!names(data) %in% names(col_means)] On Wed, 9 Nov 2011, Martin Batholdy wrote: Dear R-Users, I have a problem with an algorithm that iteratively goes over a data.frame and exclude n-columns each step based on a statistical criterion. So that the 'column-space' gets smaller and smaller with each iteration (like when you do stepwise regression). The problem is that in every round I use a new subset of my data.frame. However, as soon as I generate this subset by indexing the data.frame I get of course different column-numbers (compared to my original data-frame). How can I solve this? I prepared a small example to make my problem easier to understand: Here I generate a data.frame containing 6 vectors with different means. The loop now should exclude the vector with the smallest mean in each round. At the end I want to have a vector ('drop') which contains the column numbers that I can apply on the original data.frame to get a subset with the highest means. But the problem is that this is not working, since every time I generate a subset ('data[,-drop]') I of course get now different column-numbers that differ from the column-numbers of the original data-frame. So, in the end I can't use my drop-vector on my original data-frame ? since the dimension of the testing data-frame changes in every loop-round. How can I deal with this kind of problem? Any suggestions are highly appreciated! (of course for the example code, there are much easier method to achieve the goal of finding the columns with the smallest means ? It is a pretty generic example) here is the sample code: x1 - rnorm(200, 5, 2) x2 - rnorm(200, 6, 2) x3 - rnorm(200, 1, 2) x4 - rnorm(200, 12, 2) x5 - rnorm(200, 8, 2) x6 - rnorm(200, 9, 2) data - data.frame(x1, x2, x3, x4, x5,x6) col_means - colMeans(data) drop - match(min(col_means), col_means) for(i in 1:4) { col_means - colMeans(data[,-drop]) drop - c(drop, match(min(col_means), col_means)) } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot stat_summary (mean_cl_boot)
For all those that are interested. To adjust the number of reps in the stat_summary() mean_cl_boot function simply specify B to the number of bootstrap resamples. I set B to 2000 resamplings below. stat_summary(fun.data=mean_cl_boot, geom=errorbar,width=0.1,colour = red, B=2000 ) If you run mean_cl_boot within stat_summary() and ggplot setting reps=T does not appear to return a vector of the resampled means as an attribute that I could locate anywhere. However, you can run smean.cl.boot code outside of ggplot. x-smean.cl.boot(OsmData$Mean, B=2000, reps=T) attr(x,reps) Thus, outside of ggplot you can use reps=T to check the resampling is proceeding as you expect, before adding it to the ggplot code. I did some checks setting B=1 and B=5 as well as large numbers both inside and outside of the ggplot code to assure myself that my adjustments to B within stat_summary() within ggplot were actually doing what I thought. Finally, despite the fact that the Hmisc function is called smean.cl.boot, as David points out, within ggplot and stat_summary you must use mean_cl_boot without the s before mean. Within ggplot mean_cl_boot is the correct notation and it does work. I really like ggplot, but can agree that it isn't always clear how to get from point A to point B. My hope in writing this out is that someone else might start their own exploration of these issues a little further down the road than I found myself when I started looking into this. Thanks, Nate On Wed, Nov 9, 2011 at 1:46 PM, David Winsemius dwinsem...@comcast.netwrote: On Nov 9, 2011, at 4:35 PM, Nathan Miller wrote: Sorry, I didn't realize I was being so obscure. Within ggplot it is possible to use stat_summary() to generate confidence intervals about a mean. One method for generating these CI assumes normality. The other uses bootstrapping to generate the CI. I am using the second method which requires code like this stat_summary(fun.data=mean_**cl_boot, geom=errorbar,width=0.1,**colour = red) I've added some extra flourishes to make them look like errorbars, alter the width and specify color. I would like some details regarding how this bootstrapped CI is calculated. If I type ?mean_cl_boot at the R command line I get a minimal help file for wrap_hmisc {ggplot2} which is described wrap up a selection of Hmisc to make it easy to use with stat_summary I did not mean to suggest that ggplot2 calls Hmisc when I run stat_summary(), Actually it does. but simply that it appears that stat_summary() seems to have been based upon a selection of Hmisc, hence I went looking in Hmisc to try to find details regarding stat_summary(). I was unsuccessful in this attempt. I don't believe a great deal of debugging is necessary. I am simply looking for details regarding how mean_cl_boot works. It doesn't. That is not the right name. If you don't have information regarding how it works (such as the default number of resamplings) there is no need to respond. Hadley's help files in ggplot2 are terse (or the links to outside resources crash my R sessions) to the point of being too frustrating for me to consider using that package, so I don't know if optional parameters can be passed to the Hmisc functions. If they are, then you should set reps=TRUE and then see what happens to the number of reps from the returned object ... if the wrap_hmisc function does happen to catch it. x - rnorm(100) smean.cl.boot(x) Mean Lower Upper -0.0211511 -0.2013623 0.1469728 smean.cl.boot(x, reps=TRUE) Mean Lower Upper -0.03465361 -0.21233213 0.15178655 attr(,reps) [1] 0.0283330508 -0.1250784237 0.0744640779 0.1310826601 -0.1373094536 [6] 0.0629291714 0.0145916070 -0.0860141221 0.0549134451 0.0732892908 snipped pages of intervening output. [991] 0.1029922424 0.0613358597 -0.0645577851 -0.1664905503 -0.1249615180 [996] -0.0751783377 -0.0043747455 -0.1155948060 -0.0750075659 0.1244430930 I don't see where the number of reps is returned, but the B setting defaults to 1000. -- david. Thanks for any assistance, Nate On Wed, Nov 9, 2011 at 1:10 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 9, 2011, at 2:59 PM, Nathan Miller wrote: Hello, This is a pretty simple question, but after spending quite a bit of time looking at Hmisc and using Google, I can't find the answer. If I use stat_summary(fun.data=mean_**cl_boot) in ggplot to generate 95% confidence intervals, how many bootstrap iterations are preformed by default? Can this be changed? I would at least like to be able to report the number of boot strap interations used to generate the CIs. I haven't been able to find mean_cl_boot as a function itself or something ressembling it in the Hmisc documentation, but it seems as though Hmisc is wrapped up in stat_summary() and is called to compute mean_cl_boot. You seem really, really confused (and you offer very little in
Re: [R] Web based R-help not a list
On Nov 9, 2011, at 5:40 PM, Hasan Diwan wrote: On 9 November 2011 15:24, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Such a resource would no longer be R-help. You might like stackoverflow. Perhaps our man was looking for a searchable mail archive? If no one has one, I can set one up pretty quickly. Just let me know... Thanks in advance! -- H No need: ?RSiteSearch http://tolstoy.newcastle.edu.au/R/ http://finzi.psych.upenn.edu/nmz.html http://www.mail-archive.com/r-help@stat.math.ethz.ch/ http://dir.gmane.org/gmane.comp.lang.r.general http://www.rseek.org/ HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Stack trace?
Very nifty tricks re: getting recover on warnings. Thanks, Michael On Wed, Nov 9, 2011 at 7:11 PM, William Dunlap wdun...@tibco.com wrote: Bert, At the end of my previous message I mentioned tryCatch(). I should have said withCallingHandlers(). E.g., f - function() { + warning(Hmmm) + retval - c(1,2) + c(5,6,7) # warns about incompatible lengths in + + warning(Really?) + retval + } options(warning.expression=NULL) # just in case it had been set withCallingHandlers(f(), warning=function(e){ + cat(encountered warning: , conditionMessage(e), \n) + if (grepl(multiple of shorter, conditionMessage(e))) { recover() } + invokeRestart(muffleWarning) + }) encountered warning: Hmmm encountered warning: longer object length is not a multiple of shorter object length Enter a frame number, or 0 to exit 1: withCallingHandlers(f(), warning = function(e) { 2: f() 3: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 4: #3: withRestarts({ 5: #3: withOneRestart(expr, restarts[[1]]) 6: #3: doWithOneRestart(return(expr), restart) 7: #3: function (e) Selection: 0 encountered warning: Really? [1] 6 8 8 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of William Dunlap Sent: Wednesday, November 09, 2011 3:51 PM To: Bert Gunter Cc: r-help Subject: Re: [R] Stack trace? It will call recover() for each warning. When you exit recover() the code continues on. This is handy if you expect the first warning or two but are curious about the third. I'd expect that you could reset options(warning.expression=NULL) when in recover() so that recover() would not be called at the remaining warnings. options(warning.expression=quote(recover())) f - function() { + warning(Hmmm) + retval - c(1,2) + c(5,6,7) + warning(Really?) + retval + } f() Enter a frame number, or 0 to exit 1: f() 2: #2: warning(Hmmm) 3: #2: .signalSimpleWarning(Hmmm, quote(f())) 4: #2: withRestarts({ 5: #2: withOneRestart(expr, restarts[[1]]) 6: #2: doWithOneRestart(return(expr), restart) Selection: 0 Enter a frame number, or 0 to exit 1: f() 2: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 3: #3: withRestarts({ 4: #3: withOneRestart(expr, restarts[[1]]) 5: #3: doWithOneRestart(return(expr), restart) Selection: 1 Called from: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) Browse[1] options(warning.expression=NULL) Browse[1] # hit control-D Browse[1] Enter a frame number, or 0 to exit 1: f() 2: #3: .signalSimpleWarning(longer object length is not a multiple of shorter object length, quote(c(1, 2) + c(5, 6, 7))) 3: #3: withRestarts({ 4: #3: withOneRestart(expr, restarts[[1]]) 5: #3: doWithOneRestart(return(expr), restart) Selection: 0 [1] 6 8 8 Warning message: In f() : Really? I think you could also use tryCatch(warning=function(e)...) to only call recover() at certain types of warnings, perhaps by examining the text in conditionMessage(e). Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Wednesday, November 09, 2011 3:40 PM To: William Dunlap Cc: r-help Subject: Re: [R] Stack trace? To Bill's suggestion for a stack trace on warnings: Question: What would this do in situations where one might get, e.g. 100 warnings? -- Bert On Wed, Nov 9, 2011 at 3:08 PM, William Dunlap wdun...@tibco.commailto:wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.orgmailto:r-help-boun...@r-project.org] On Behalf Of Thomas Lumley Sent: Wednesday, November 09, 2011 1:53 PM To: rkevinbur...@charter.netmailto:rkevinbur...@charter.net Cc: r-help Subject: Re: [R] Stack trace? On Thu, Nov 10, 2011 at 10:35 AM, rkevinbur...@charter.netmailto:rkevinbur...@charter.net wrote: Currently I have a for loop executing functions and at the end I get a message like: There were 50 or more warnings (use warnings() to see the first 50) If I do what it says and type warnings(), I get 50 messages like: 2: In !is.nahttp://is.na(x) !is.nahttp://is.na(rowSums(xreg)) : longer object length is not a multiple of shorter object length I am not sure what function these errors are originating from. I don't think it is from any of the 'R' script that I wrote. I would like to see which function is being called when this error is thrown and which called that . . . and so on. I have the same problem with error messages. An error is thrown but I don't have a call stack to help
Re: [R] [ reached getOption(max.print) -- omitted 8178 rows ]]
? options options(max.print = Inf) Michael On Wed, Nov 9, 2011 at 4:48 PM, Sean Robert McGuffee sean.mcguf...@gmail.com wrote: Hi, I have a weird thing I don¹t understand. Here¹s what I did: I read some data: data=read.table(fileName²) then I printed the data to the screen: data But it didn¹t finish: lot¹s of data was written out, but not all of it... Then it interrupted and said: [ reached getOption(max.print) -- omitted 8178 rows ]] Is there a setting somewhere that I can change to get to see all of my data? Thanks Sean [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with SEM package: Error message
Dear Lisa, Here's a little CFA simulation of my own. I used the development version 2.1-0 of the sem package (on R-Forge) to allow equation-style specification of the model, but you should get the same results with version 2.0-0: --- snip library(MASS) # for mvrnorm() set.seed(12345) # for replication R - matrix(1, 5, 5) R[lower.tri(R)] - R[upper.tri(R)] - round(runif(10, min=0.2, max=0.8), 3) R [,1] [,2] [,3] [,4] [,5] [1,] 1.000 0.633 0.725 0.732 0.395 [2,] 0.633 1.000 0.657 0.474 0.506 [3,] 0.725 0.474 1.000 0.300 0.637 [4,] 0.657 0.300 0.506 1.000 0.794 [5,] 0.732 0.395 0.637 0.794 1.000 eigen(R)$values [1] 3.3449466 0.7678584 0.4168595 0.3160630 0.1542725 F - mvrnorm(1000, rep(0, 5), R) Lambda - matrix(0, 15, 5) Lambda[c(1:3, 18+1:3, 36+1:3, 54+1:3, 72+1:3)] - round(runif(15, min=0.5, max=0.8), 3) Lambda [,1] [,2] [,3] [,4] [,5] [1,] 0.637 0.000 0.000 0.000 0.000 [2,] 0.505 0.000 0.000 0.000 0.000 [3,] 0.579 0.000 0.000 0.000 0.000 [4,] 0.000 0.602 0.000 0.000 0.000 [5,] 0.000 0.574 0.000 0.000 0.000 [6,] 0.000 0.712 0.000 0.000 0.000 [7,] 0.000 0.000 0.692 0.000 0.000 [8,] 0.000 0.000 0.611 0.000 0.000 [9,] 0.000 0.000 0.749 0.000 0.000 [10,] 0.000 0.000 0.000 0.586 0.000 [11,] 0.000 0.000 0.000 0.648 0.000 [12,] 0.000 0.000 0.000 0.768 0.000 [13,] 0.000 0.000 0.000 0.000 0.692 [14,] 0.000 0.000 0.000 0.000 0.639 [15,] 0.000 0.000 0.000 0.000 0.559 Y - (F %*% t(Lambda)) + matrix(rnorm(1000*15), 1000, 15) colnames(Y) - paste(y, 1:15, sep=) library(sem) Loading required package: matrixcalc mod.cfa - specifyEquations(covs=c(F1, F2, F3, F4, F5)) 1: y1 = lam1*F1 2: y2 = lam2*F1 3: y3 = lam3*F1 4: y4 = lam4*F2 5: y5 = lam5*F2 6: y6 = lam6*F2 7: y7 = lam7*F3 8: y8 = lam8*F3 9: y9 = lam9*F3 10: y10 = lam10*F4 11: y11 = lam11*F4 12: y12 = lam12*F4 13: y13 = lam13*F5 14: y14 = lam14*F5 15: y15 = lam15*F5 16: v(F1) = 1 17: v(F2) = 1 18: v(F3) = 1 19: v(F4) = 1 20: v(F5) = 1 21: Read 20 records NOTE: adding 15 variances to the model (sem.cfa - sem(mod.cfa, data=data.frame(Y))) Model Chisquare = 54.61949 Df = 80 lam1 lam2 lam3 lam4 lam5 lam6 0.5529479 0.5126612 0.5365723 0.5533220 0.5852442 0.6283580 lam7 lam8 lam9 lam10 lam11 lam12 0.6313437 0.5655048 0.8395153 0.5735607 0.6884884 0.8166616 lam13 lam14 lam15 C[F1,F2] C[F1,F3] C[F1,F4] 0.6888107 0.6866472 0.5291979 0.7321806 0.7387977 0.6232119 C[F1,F5] C[F2,F3] C[F2,F4] C[F2,F5] C[F3,F4] C[F3,F5] 0.8189901 0.5298096 0.2800764 0.4247156 0.5145992 0.6809838 C[F4,F5] V[y1] V[y2] V[y3] V[y4] V[y5] 0.8249320 0.9865355 1.0098899 1.0390452 0.9690317 0.9421020 V[y6] V[y7] V[y8] V[y9]V[y10]V[y11] 1.0879510 0.9610472 0.9888304 0.9835167 1.0599708 1.0522614 V[y12]V[y13]V[y14]V[y15] 0.9653279 1.0703453 0.9421894 1.1277448 Iterations = 16 --- snip Best, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Lisa Pham Sent: November-08-11 4:17 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] Help with SEM package: Error message Dear John, Thank you for your reply. My data is actually simulated under the model X = Lambda*F + E. Since my post, I've simplified the simulation of my data and I still get the error. This is what I've done since my last post. I constructed Lambda apriori (so I know exactly which observed variables load onto which factors), E follows a Gaussian with mean 0 and var-cov matrix given by the Identity matrix. For my particular model, I sample the factor scores F_i (for sample i) from a multivariate normal F_i ~ N(mu_i, Phi). mu_i is fixed to Phi*z_i, where z_i is a 5x1 vector. Thinking I could have an ill-conditioned var-cov matrix, I looked at the condition number of Phi (the factor var-cov matrix). I recently adjusted Phi to ensure that the condition number was indeed small (it is now about 2). I then sample Y_i ~ N(Lambda*F_i, Psi). If the data I'm simulating is ill conditioned, I'm not even sure how to fix it because the simulation itself is pretty straightforward. Even with a well conditioned factor var-cov matrix Phi that I used to sample my factor scores, I still get that same problem. In any case, I am so grateful for your help- I've been working on this all day and I can't seem to figure out where I go wrong. I made Lambda pretty sparse and with 150 samples, I certainly don't have too many parameters... besides identifiability, I'm not sure what to check for if its not a problem with my coding. Your post has already helped me to think about this problem a little differently. Sincerely, Lisa On Tue, Nov 8, 2011 at 9:32 PM, John Fox j...@mcmaster.ca wrote: Dear Lisa, There doesn't seem to be anything logically wrong with your
Re: [R] R to automate scatter plots
It sounds like something is going wrong in your data read -- the warnings indicate that R probably isn't data to the plotting commands. My totally off the wall guess is that if your data is coming by way of excel, the commas are leading to your data becoming characters and hence not plotting nicely, but that's just a guess. add browser() inside your loop between the read commands and the plot just to see what your data actually looks like inside R and try to track down the error. As to your pdf() question -- you can also just put it outside the loop and close dev.off() after the loop. Then all your plots will be in one pdf. Though, perhaps this is what you were looking for as far as name manipulation: pdf(file = paste( substr(files[i],1, nchar(files[i]-4)), .pdf, sep = ) Michael On Wed, Nov 9, 2011 at 5:32 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 9, 2011, at 4:22 PM, Cynthia Lee Page wrote: Hi R people! I have a directory of .csv files I would like to make into objects then scatter plots. I have been having varying degrees of progress. I was able make an object of all files, loop through it, and make a pdf of the last file I looped through. I kept renaming the pdf so instead of ending up with 27 pdfs I got one, with the data from the last file I have been tweaking with it and now can't even make the data object and I am not sure why. I am a bit brain dead at this point :) I am new to R and have been programming in perl - but not all that long Could you please have al look at it.. here is the script I have been using # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex #test-files[i] # tried to use as variable to name each pdf this object is the name of last file in loop data - read.csv(files[i]) # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well pdf(data.pdf) At this point you might have been better off if you had just typed: pdf() The default name for a pdf document is set by this code from the help page for pdf() pdf(file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf), Notice that %03d. That means the system pots in a number tthat is one grater than the largest current Rplot_N.pdf in the directory. plot(data$fpkma,data$fpkmb, main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) dev.off() } # change back to the original directory setwd(initial.dir) the command I have been using : R CMD BATCH /data/homes/ccpage/ngs/rscripts/test_for.R The Rout # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ + # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex + #test-files[i] # tried to use as variable to name each pdf this object is the name of last file + + data - read.csv(files[i]) + + # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf + # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well + + pdf(data.pdf) + plot(data$fpkma,data$fpkmb,main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) + dev.off() + } Error in plot.window(...) : need finite 'xlim' values Without the data that created that error, we are not going to be able to give a clear answer. Calls: plot - plot.default - localWindow - plot.window In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no non-missing arguments to max; returning -Inf 3: In min(x) : no non-missing arguments to min; returning Inf 4: In max(x) : no non-missing arguments to max; returning -Inf
Re: [R] R to automate scatter plots
Sorry for the rambling answer: On Wed, Nov 9, 2011 at 8:28 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: It sounds like something is going wrong in your data read -- the warnings indicate that R probably isn't data** meant to say: getting numerical data. to the plotting commands. My totally off the wall guess is that if your data is coming by way of excel, the commas are leading to your data becoming characters and hence not plotting nicely, but that's just a guess. add browser() inside your loop between the read commands and the plot just to see what your data actually looks like inside R and try to track down the error. As to your pdf() question -- you can also just put it outside the loop and close dev.off() after the loop. Then all your plots will be in one pdf. Though, perhaps this is what you were looking for as far as name manipulation: pdf(file = paste( substr(files[i],1, nchar(files[i]-4)), .pdf, sep = ) Michael On Wed, Nov 9, 2011 at 5:32 PM, David Winsemius dwinsem...@comcast.net wrote: On Nov 9, 2011, at 4:22 PM, Cynthia Lee Page wrote: Hi R people! I have a directory of .csv files I would like to make into objects then scatter plots. I have been having varying degrees of progress. I was able make an object of all files, loop through it, and make a pdf of the last file I looped through. I kept renaming the pdf so instead of ending up with 27 pdfs I got one, with the data from the last file I have been tweaking with it and now can't even make the data object and I am not sure why. I am a bit brain dead at this point :) I am new to R and have been programming in perl - but not all that long Could you please have al look at it.. here is the script I have been using # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex #test-files[i] # tried to use as variable to name each pdf this object is the name of last file in loop data - read.csv(files[i]) # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well pdf(data.pdf) At this point you might have been better off if you had just typed: pdf() The default name for a pdf document is set by this code from the help page for pdf() pdf(file = ifelse(onefile, Rplots.pdf, Rplot%03d.pdf), Notice that %03d. That means the system pots in a number tthat is one grater than the largest current Rplot_N.pdf in the directory. plot(data$fpkma,data$fpkmb, main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) dev.off() } # change back to the original directory setwd(initial.dir) the command I have been using : R CMD BATCH /data/homes/ccpage/ngs/rscripts/test_for.R The Rout # source of this code below #http://cran.r-project.org/doc/contrib/Lemon-kickstart/kr_scrpt.html # store the current directory initial.dir-getwd() # change to the new directory setwd(/data/homes/ccpage/ngs/Argueso/Tophat/flocculated/cuffdiff/fpkmgt) # source of this code below # https://stat.ethz.ch/pipermail/r-help/2008-March/158336.html files - Sys.glob(*.csv) # get names of files to process #result - numeric(length(files)) # preallocate assuming single value from each file for (i in seq_along(files)){ + # want to give each object a unique name would like to use file[i] MINUS the .csv extention regex + #test-files[i] # tried to use as variable to name each pdf this object is the name of last file + + data - read.csv(files[i]) + + # I want to name the pdf the same name as the object with a .pdf extention here I think it will be file[i].csv.pdf + # I don't know how to use regex in R I could readLines(objectnames.txt) and loop through those as well + + pdf(data.pdf) + plot(data$fpkma,data$fpkmb,main=Scatter plot of data,xlab=FPKM of First Time Point,ylab=FPKM of Second Time Point) + dev.off() + } Error in plot.window(...) : need finite 'xlim' values Without the data that created that error, we are not going to be able to give a clear answer. Calls: plot - plot.default - localWindow - plot.window In addition: Warning messages: 1: In min(x) : no non-missing arguments to min; returning Inf 2: In max(x) : no
Re: [R] Error in drawing
Your code is not reproducible. Where is the lidar data coming from? Michael On Wed, Nov 9, 2011 at 2:29 PM, Gyanendra Pokharel gyanendra.pokha...@gmail.com wrote: I have got following error in drawing wavelet fitting. can some one help? library(faraway) data(lidar) newlidar-lidar[c(1:128),] library(wavethresh) wds - wd(newlidar$logratio) draw(wds) Error in plot.default(x = x, y = zwr, main = main, sub = sub, xlab = xlab, : formal argument type matched by multiple actual arguments [[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 handle empty arguments
Perhaps the missing() command will help in regards to suggestion a. I'd caution against b for obvious reasons, though I think options(error = ) can get you that behavior (you'll have to figure out what XXX is, I have never tried to lessen my error messages...) Michael On Tue, Nov 8, 2011 at 3:04 PM, Alaios ala...@yahoo.com wrote: Dear all, I am having a data stucture that contains Products and Time Stamps, I have made also two lists ProductList=list(c('Example1','Example2'...) TimeStamp=list(c(1990-02-03 12:57:60),c(1990-02-03 12:57:60), then I have made few functions that call each other do_analysis_for_all the data-function(arguments){ . return(lapply(ProductList,do_analysis_for_one_product_list_for_all_time_stamps) } do_analysis_for_one_product_list_for_all_time_stamps-function(arguments){ return(lapply(TimeStamps,do_analysis_for_one_product_list_for_one_time_stamps) } (this is mostly just an algorithm to show you the main logic). as one is getting down to the chain I have described, there are functions that chop the data as requested. For example for a specific TimeFram one will get the entries that correspond to the specific dates. The problem I have though is that sometimes (is not too often) there are no entries for a specific interval and thus the next function will rely on the chopped data will explode with an error. I want to ask you for a clear solution to handle this cases I have two ideas in mind a). I change all the function in my code so to check that the input argument is empty (how to do that?) and in that case I return an empty list b) I change nothing to the code and I ask kindly from the R in that case to return a lovely error message (Best is to find it saved in the list that lapply returns) and continue to the next case. I have tried earlier to add the try(myfunction,silent=TRUE) but I ended up changing all my code with the try(..) which of course is a bit of dirty solution. Do you know if I can ask globally R (perhaps add some directive in the beginning of my file) to handle all these errors in a silent manner so to skip them. What should I try to a or b and why? I would like to thank you in advance for your time spent to read this email B.R Alex [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.