Re: [R] Using locator() to digitise
(Ted Harding) wrote: Hi Folks, I'm contemplating using locator() to digitise external graphics. To set context, I would be using X11 display on Linux. Hi, Ted! Beside searching for specialized packages, I would suggest you to try my package RImgViewer which uses Gtk2 library to import and display images in R-session. It is not available on CRAN because it depends on two other packages (RGtk2 and GdkDrawing) which conflict with Duncan T. Lang RGtk package. All of them can be downloaded from my homepage (www.hppi.troitsk.ru/Kondrin/r_img_viewer_html.html , www.hppi.troitsk.ru/Kondrin ). It is mainly untested (except by me) and I hope you would send me bug-reports if you find the package worth it. For your purposes this package can be used in this way. You can use the image viewer to import and display your scanned image (because RImgViewer use specialized widget for image displaying it is quite fast). Then you can convert displayed graphics into R-array and with markers provided by RImgViewer select region of interest. In your case it could be selecting axii' directions. From coordinates of this markers you can construct rotation matrix and calculate true coordinates of each point from its array indexes. The coordinates of drawn curves are the coordinates of points with values 0 (i.e.black). I usually digitize the whole picture and then use R to delete points which I do not need and to smooth the rest. Hope this helps. To pre-empt the obvious comment: I've found on the R site the suggestion to use the 'pixmap' package. I've tried this, and it works; but it involves building a big R object (the internal pixmap representation), and this chokes my somewhat puny laptop (e.g. it can take about 1 minute to draw the graphic inside a plot area using addlogo(), with mucho swappo, and subsequently working knee-deep in treacle). The following idea would be a lot slicker. For examples: I have something like a) A scatterplot of data printed in a journal (but the data values are not available; b) A contour map (on paper) of a region. So, I can scan the document, and obtain a file in some graphics format (jpeg, pbm or png, say). Now: an idea which I find attractive is to be able to overlay an R plot with axes onto a display of the graphics file (produced as an X window by any suitable program such as 'xv' or 'display') so that (if the overlay were possible) clicking on the points of the graphic would in fact be clicking on the R plot and, via locator(), generate the R-plot coordinates of the mouse clicks which would correspond to the selected points on the graphic. Provided the coordinate system of the R plot were properly related to the graphic, the results would be a digitisation of the selected points on the graphic. What seems to be needed for this idea to work is that the R-plot should be displayed in an X11() device whose background was completely transparent, so that when moved over the (independently generated) display of the graphic the latter would be visible (but locator() would still be working on the R-plot itself). Window resizing could look after the correspondence between graphic coordinates and R-plot coordinates. The R plot itself could be empty (apart from coordinate axes) or could contain helper elements such as grid lines, circles (e.g. I want to digitise graphics points within a certain circle), etc. Helper elements could be added to the R-plot by subsequent 'lines' or 'points' commands (e.g. I identify two points on the graphic, R-plot the line joining them, and then pick off graphic-points which lie on the R-line). So this question is really about producing a bare R plot on, as it were, a virtual acrylic transparency. It's certainly possible to do such a thing in X: e.g. the cute xteddy is in fact a picture of a bear on a completely transparent rectangular background, though you'd never know by looking! Any comments? With thanks, and best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Mar-05 Time: 16:09:11 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Interaction term in anova - how it should be written in a manuscript table?
Thanks a lot cheers Eryk Marc Schwartz wrote: For a me too post, I agree with Andy's recommendation, which in turn is supported by How to Report Statistics in Medicine by Lang and Secic, ACP, 1997. There is an example table (8.2) on page 133. HTH, Marc Schwartz On Sun, 2005-03-20 at 15:44 -0500, Liaw, Andy wrote: I'd suggest a $\times$ b, as you'd find in most stat textbook. Andy From: Witold Eryk Wolski Dear Rgurus, Interaction terms in the linear models function lm are specified by the colon : eg: x ~ a + b + a:b a shortcut for the above is: x ~ a*b the output if calling anova on the lm object will be the same in both cases a b a:b ... Resdiuals ... What I am wondering is how the interaction term (a:b) given above should be written in a table in an manuscript? a ) a*b b ) a$\cdot$ b c ) a:b d) Cheers Eryk. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Witold Eryk Wolski __( School of Mathematics and Statistics _ \__/ University of Newcastle 'v' ||Newcastle upon Tyne, NE1 7RU, ENGLAND / \ ^^mail: [EMAIL PROTECTED] m m Phone : 044 (0)191 222 5376 FAX : 044 (0)191 222 8020 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Sv: [R] Using locator() to digitise
Hi, Splus allows pasting a graphics object into the plotting window, which makes it possible to do what you describe below. Now I use R which doesn't seem to allow pasting the picture into the graphics window, so I copy the graph onto a transparency sheet, and stick it onto my screen using tape. The coordinates need to be converted to make sense (as you describe). My methodology with the transparency has a stoneage appearance, but it works quite well, if I may say so myself. I have written down some notes that describes what I did, but it's in Swedish so I guess it's not of much help. Kind regards, Sixten. Ted Harding [EMAIL PROTECTED] 2005-03-20 17:09 Hi Folks, I'm contemplating using locator() to digitise external graphics. To set context, I would be using X11 display on Linux. To pre-empt the obvious comment: I've found on the R site the suggestion to use the 'pixmap' package. I've tried this, and it works; but it involves building a big R object (the internal pixmap representation), and this chokes my somewhat puny laptop (e.g. it can take about 1 minute to draw the graphic inside a plot area using addlogo(), with mucho swappo, and subsequently working knee-deep in treacle). The following idea would be a lot slicker. For examples: I have something like a) A scatterplot of data printed in a journal (but the data values are not available; b) A contour map (on paper) of a region. So, I can scan the document, and obtain a file in some graphics format (jpeg, pbm or png, say). Now: an idea which I find attractive is to be able to overlay an R plot with axes onto a display of the graphics file (produced as an X window by any suitable program such as 'xv' or 'display') so that (if the overlay were possible) clicking on the points of the graphic would in fact be clicking on the R plot and, via locator(), generate the R-plot coordinates of the mouse clicks which would correspond to the selected points on the graphic. Provided the coordinate system of the R plot were properly related to the graphic, the results would be a digitisation of the selected points on the graphic. What seems to be needed for this idea to work is that the R-plot should be displayed in an X11() device whose background was completely transparent, so that when moved over the (independently generated) display of the graphic the latter would be visible (but locator() would still be working on the R-plot itself). Window resizing could look after the correspondence between graphic coordinates and R-plot coordinates. The R plot itself could be empty (apart from coordinate axes) or could contain helper elements such as grid lines, circles (e.g. I want to digitise graphics points within a certain circle), etc. Helper elements could be added to the R-plot by subsequent 'lines' or 'points' commands (e.g. I identify two points on the graphic, R-plot the line joining them, and then pick off graphic-points which lie on the R-line). So this question is really about producing a bare R plot on, as it were, a virtual acrylic transparency. It's certainly possible to do such a thing in X: e.g. the cute xteddy is in fact a picture of a bear on a completely transparent rectangular background, though you'd never know by looking! Any comments? With thanks, and best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Mar-05 Time: 16:09:11 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] anomalous result for wilcox.exact in exactRankTests
Roger Levy [EMAIL PROTECTED] writes: Hi, In the exactRankTest package, I've become aware that you can get anomalous p-values (i.e., above 1) from the wilcox.exact method, as in: wilcox.exact(c(-0.6,0.8,-0.5)) Exact Wilcoxon signed rank test data: c(-0.6, 0.8, -0.5) V = 3, p-value = 1.25 alternative hypothesis: true mu is not equal to 0 This is disturbing. Has anyone encountered this before, and if so is there an obvious reason why this should happen? Presumably by counting the observed value towards both tails: dsignrank(0:6,3) [1] 0.125 0.125 0.125 0.250 0.125 0.125 0.125 sum(dsignrank(0:3,3))+sum(dsignrank(3:6,3)) [1] 1.25 which looks a bit odd, but of course only happens when the correct p-value is 1.0, so it is fairly harmless. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Median in Classes
Hello, I've got a problem to find an effective calculation. There are x,y data and I want to build classes for the x values. For each class then I want to calculate the median, N%-Quantiles, outliers, etc. for the corresponding y values and store all in a vector or matrix. Is there a direct possibility to do this without storing to much temporary data? Thank's in advance, Michael Hecht - | Dipl.-Math. Michael Hecht | 66748 Dillingen / Germany | E-Mail : mailto:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: Sv: [R] Using locator() to digitise
On 21-Mar-05 Sixten Borg wrote: Hi, Splus allows pasting a graphics object into the plotting window, which makes it possible to do what you describe below. Now I use R which doesn't seem to allow pasting the picture into the graphics window, so I copy the graph onto a transparency sheet, and stick it onto my screen using tape. The coordinates need to be converted to make sense (as you describe). My methodology with the transparency has a stoneage appearance, but it works quite well, if I may say so myself. Hi Sixten, Such things often work well! You take me back many years to my earliest digitising, using a flat-bed pen plotter. I bought a cheap little pocket microscope (the top and bottom lenses folded out from the upright), plucked two hairs from my head, and fixed these as *literal* cross-hairs on the lower lens with sellotape. To use this, I would remove the pen from its holder on the plotter arm and attach the microscope to the pen holder with a rubber band. The sheet to be digitised was laid on the plotter bed in the usual way. I then wrote a program (BASIC for CP/M) which would move the pen-holder under control of the arrow-keys on the computer, and keep an internal record of the point moved to. Pressing Return would store the plotter coordinates of the current point in an array. Any other anecdotes, anyone? Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 21-Mar-05 Time: 09:55:58 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Using locator() to digitise
On 21-Mar-05 M.Kondrin wrote: (Ted Harding) wrote: Hi Folks, I'm contemplating using locator() to digitise external graphics. To set context, I would be using X11 display on Linux. Hi, Ted! Beside searching for specialized packages, I would suggest you to try my package RImgViewer which uses Gtk2 library to import and display images in R-session. It is not available on CRAN because it depends on two other packages (RGtk2 and GdkDrawing) which conflict with Duncan T. Lang RGtk package. All of them can be downloaded from my homepage (www.hppi.troitsk.ru/Kondrin/r_img_viewer_html.html , www.hppi.troitsk.ru/Kondrin ). [...] Thanks for pointing this out! From your description, it looks well worth a try, and if I use it I will be happy to give you feedback. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 21-Mar-05 Time: 09:34:29 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Convex hull line coordinates..
Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with approx to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the yleft or yright doesnt seem to help.. Any suggestions? Thank you in advance Achilleas Psomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Violin plot for discrete variables.
Dear Rgurus, To my knowledge the best way to visualize the distribution of a discrete variable X is plot(table(X)) The problem which I have is the following. I have to discrete variables X and Y which distribution I would like to compare. To overlay the distribution of Y with lines(table(Y)) gives not satisfying results. This is the same in case of using density or histogram. Hence, I am wondering if there is a equivalent of the vioplot function (package vioplot) for discrete variables which starts with a boxplot and than adds a rotated plot(table()) plot to each side of the box plot. Maybee I should ask it first: Does such a plot make any sense? If not are there better solutions? cheers Eryk. -- Witold Eryk Wolski __( School of Mathematics and Statistics _ \__/ University of Newcastle 'v' ||Newcastle upon Tyne, NE1 7RU, ENGLAND / \ ^^mail: [EMAIL PROTECTED] m m Phone : 044 (0)191 222 5376 FAX : 044 (0)191 222 8020 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Median in Classes
you could try something like this: dat - data.frame(x=rep(1:4, each=25), y=rnorm(100)) tapply(dat$y, dat$x, summary) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Hecht Michael, F+E/ST [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' r-help@stat.math.ethz.ch Sent: Monday, March 21, 2005 10:59 AM Subject: [R] Median in Classes Hello, I've got a problem to find an effective calculation. There are x,y data and I want to build classes for the x values. For each class then I want to calculate the median, N%-Quantiles, outliers, etc. for the corresponding y values and store all in a vector or matrix. Is there a direct possibility to do this without storing to much temporary data? Thank's in advance, Michael Hecht - | Dipl.-Math. Michael Hecht | 66748 Dillingen / Germany | E-Mail : mailto:[EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Remove columns from data-frame
Hello, I'm new to the list, hello everybody! :-) I have a question. I looked carefully through the documentation and googled, and found no answer, so I'm posting it here. Let's say I have a data frame with lots of columns (about 300), which are factors. Many columns-factors have only one level, for example all are Yes or all are No. If I try to do a regression with that, I get an error message, that contrasts can be used only when number of factors is at least 2. glm(mortality ~ ., family = binomial, data = ecdb_PROC88) Error in contrasts-(`*tmp*`, value = contr.treatment) : contrasts can be applied only to factors with 2 or more levels Of course, I could not include them in the model formula, but I don't feel like typing 150 descriptive variables. I would like to remove the one-level columns autimatically from the data frame. Is it possible? Regards, Maciej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] menu() and commands assigned to choices -break out a repeat loop so that the next code lines to be read
first:I'd like to have the choice between breaking out a repeat loop or continue it then: i'd would like my code after the end of my repeat loop not to be read unless I type 2 (to continue executing the content of my repeat loop) THAT'S THE PROBLEM Is there any way to go straight out of the loop (like a goto associated to a label) or a pause like command to prevent R from reading the entire script?? I actually have this kind of code reapeat{ ... ... ... switch(menu(c(continue to select points,modelling),next,break)) } ... ... Thanks a lot Guillaume STORCHI __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove columns from data-frame
try this: dat - data.frame(y=rnorm(100), f1=sample(c(Yes, No), 100, TRUE), f2=rep(Yes, 100), f3=rep(No, 100)) # dat[!sapply(dat, function(x) all(x==x[1]))] I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Maciej Bliziski [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Monday, March 21, 2005 11:12 AM Subject: [R] Remove columns from data-frame Hello, I'm new to the list, hello everybody! :-) I have a question. I looked carefully through the documentation and googled, and found no answer, so I'm posting it here. Let's say I have a data frame with lots of columns (about 300), which are factors. Many columns-factors have only one level, for example all are Yes or all are No. If I try to do a regression with that, I get an error message, that contrasts can be used only when number of factors is at least 2. glm(mortality ~ ., family = binomial, data = ecdb_PROC88) Error in contrasts-(`*tmp*`, value = contr.treatment) : contrasts can be applied only to factors with 2 or more levels Of course, I could not include them in the model formula, but I don't feel like typing 150 descriptive variables. I would like to remove the one-level columns autimatically from the data frame. Is it possible? Regards, Maciej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] menu() and commands assigned to choices -break out a repeat loop so that the next code lines to be read
Guillaume STORCHI wrote: first:I'd like to have the choice between breaking out a repeat loop or continue it then: i'd would like my code after the end of my repeat loop not to be read unless I type 2 (to continue executing the content of my repeat loop) THAT'S THE PROBLEM Is there any way to go straight out of the loop (like a goto associated to a label) or a pause like command to prevent R from reading the entire script?? I actually have this kind of code reapeat{ ... ... ... switch(menu(c(continue to select points,modelling),next,break)) With the parantheses correct you get switch(menu(c(continue to select points,modelling)), next, break) which seems to work ... Uwe Ligges } ... ... Thanks a lot Guillaume STORCHI __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] classes of data (with a variable size)
How is it possible to split a data.frame in order to get classes with variable size. actually I'd like to get classes of data with classe size (cs) so that cs becomes bigger with an other increasing value. Guillaume Storchi __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] menu() and continue a repeat loop without executing the code that follows the loop!!?
first:I'd like to have the choice between breaking out a repeat loop or continue it then: i'd would like my code after the end of my repeat loop not to be read unless I type 2 (to continue executing the content of my repeat loop) THAT'S THE PROBLEM Is there any way to go straight out of the loop (like a goto associated to a label) or a pause like command to prevent R from reading the entire script?? I actually have this kind of code reapeat{ ... ... ... switch(menu(c(continue to select points,modelling)),next,break) } ... ... With the right brackets, it doesn't work either! R read the entire code that follows the switch(...) when I choose continue to select points instead of ONLY reading the repeat loop. Guillaume Storchi __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Count missing variables in dataset
I have a problem about how to count missing variables in dataset. I have a question for my customer. They are must choice one of answer for example: A, B, C, D and E. Now, I have dataset which is the result from my question, for instance: x1 x2 x3 x4 x5 A A A B A C A A A A B B A B A B B B C A A B B B B C B B B A I know that my customer only choice A, B and C. Are there any way to count variables that are not include in dataset. I mean D and E is missing in dataset. Thanks for your help. Jan Sabee __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] X11 Fonts sizes
In postscript graphs (pointsize = 10, different sizes in graph adjusted via cex) I would like to use different font sizes but get the following warning message: Warning messages: 1: X11 used font size 8 when 9 was requested 2: X11 used font size 8 when 7 was requested 3: X11 used font size 8 when 5 was requested This is probably not a R but a X11 problem, nevertheless I would be most obliged for any help how to actually use font sizes 9, 7, and 5 and others. Sincerely Wolfgang Waser __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Remove save workspace image? window when exit R
R-help, I wish to remove the message at the end of a session save workspace image? . By googling I found no answer . Thanks in advance I run on Windows XP version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Count missing variables in dataset
Something like: sum(sapply(dat, function(x) ! x %in% c(A, B, C))) probably would work. HTH, Andy From: Jan Sabee I have a problem about how to count missing variables in dataset. I have a question for my customer. They are must choice one of answer for example: A, B, C, D and E. Now, I have dataset which is the result from my question, for instance: x1 x2 x3 x4 x5 A A A B A C A A A A B B A B A B B B C A A B B B B C B B B A I know that my customer only choice A, B and C. Are there any way to count variables that are not include in dataset. I mean D and E is missing in dataset. Thanks for your help. Jan Sabee __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Count missing variables in dataset
On Mon, 21 Mar 2005 12:07:16 +0100 Jan Sabee wrote: I have a problem about how to count missing variables in dataset. I have a question for my customer. They are must choice one of answer for example: A, B, C, D and E. Now, I have dataset which is the result from my question, for instance: x1 x2 x3 x4 x5 A A A B A C A A A A B B A B A B B B C A A B B B B C B B B A I know that my customer only choice A, B and C. Are there any way to count variables that are not include in dataset. I mean D and E is missing in dataset. You just need to set up the variables properly. If you just say: R x - factor(sample(LETTERS[1:3], 5, replace = TRUE)) R summary(x) A B C 1 2 2 R will assume that the only levels available are A-C. But if you tell R R x - factor(x, levels = LETTERS[1:5]) R summary(x) A B C D E 1 2 2 0 0 it will do what you want. Just provide the full choice set as levels to the corresponding variables. Z Thanks for your help. Jan Sabee __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Training data
Hello! I would like to prepare training data to predict stock flow. Prediction should be based on 2 inputs (date, stock currency) input data : date, stock_currency 1.1.2004, 1000.00 2.1.2004, 1120.00 5.1.2004, 1230.00 7.1.2004, 1150.00 10.1.2004,1040.00 11.1.2004, 999.00 1.2.2004, 945.00 How should training instances look like? I use nnet function to train the model and predict function with parameter type=raw, because output must be a numerical value. I would appreciate if someone could give me any opinion to solve the problem I mentioned above. Regards, Leonn Turner! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Remove save workspace image? window when exit R
Luis Ridao Cruz wrote: R-help, I wish to remove the message at the end of a session save workspace image? . By googling I found no answer . Well, I found at once, e.g. look for a thread that started with Quit asking me ... and ended up in a nice quiz. Uwe Ligges Thanks in advance I run on Windows XP version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] X11 Fonts sizes
Wolfgang Waser [EMAIL PROTECTED] writes: In postscript graphs (pointsize = 10, different sizes in graph adjusted via cex) I would like to use different font sizes but get the following warning message: Warning messages: 1: X11 used font size 8 when 9 was requested 2: X11 used font size 8 when 7 was requested 3: X11 used font size 8 when 5 was requested This is probably not a R but a X11 problem, nevertheless I would be most obliged for any help how to actually use font sizes 9, 7, and 5 and others. The main issue is to have them... If you are using nonscalable fonts, the available sizes are 8,10,11, etc. Some distributions turn off scalable fonts because they tend to look ugly compared to the ones that have been tuned to a particular gridsize, but you can generally turn them on again by configuring the fontserver. E.g. I have catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled, /usr/X11R6/lib/X11/fonts/75dpi:unscaled, /usr/X11R6/lib/X11/fonts/100dpi:unscaled, in /etc/X11/fs/config and dropping the :unscaled should allow the server to generate the in-between sizes, at the expense of appearance. Also, notice that the X11 font sizes are only relevant for postscript graphics if you are using dev.print() or dev.copy2eps(). If you use the postscript() driver directly, X11 never comes into play. (There might be a minimum legible size, though. I forget.) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Remove save workspace image? window when exit R
from the command line q(no) is one way to do it R-help, I wish to remove the message at the end of a session save workspace image? . By googling I found no answer . Thanks in advance I run on Windows XP version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R Send instant messages to your online friends http://uk.messenger.yahoo.com [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Sweave/margin
On Fri, Mar 18, 2005 at 10:49:32PM +0100, Katharina Hoff wrote: I am currently using Sweave for writing my bachelor thesis - and I have a problem: I am using a LaTeX style (report) with quite big margin spaces. The Sweave generated LaTeX code floats into the margin - and it looks ugly. The text is blocked and fine... then there comes some flattering code running over the margin... and blocked text again. Considering the LaTeX output, I guess that Sweave puts the source code somehow in LaTeX-boxes and I suppose there is a place where I could change the width of the source code boxes (At a certain point, there is a break, closely before the text would drift out of the page. Then the code continues in new lines below.) Does anyone know where I could change or insert the box width? Or probably I am totally wrong and someone knows another solution... Hoping for help - and excuse if anyone asked this stupid question before, I did not find it in the archive, I assume you talk about R code lines extending into the right margin of pages. These are due to the formatting of such stuff using Verbatim environments. To gain control over code formatting, you can copy the pertinent lines from Sweave.sty into your document's preamble: \usepackage{fancyvrb} % \usepackage{Sweave} \DefineVerbatimEnvironment{Sinput}{Verbatim}{fontshape=sl} \DefineVerbatimEnvironment{Soutput}{Verbatim}{} \DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl} \newenvironment{Schunk}{}{} The comment % \usepackage{Sweave} is needed, it suppresses the insertion of that usepackage line by Sweave. My Sweave manual just mentions that you are to define Sinput and Soutput, but in fact, both are wrapped by the currently (R 2.0.1) unused Schunk environment, providing you with a convenient handle for altering the font size, as e.g. in: \newenvironment{Schunk}{\tiny}{} Alternatively, you can make use of the fontsize parameter provided by the Verbatim package of LaTeX. Finally, you can always try to tweak your R code to consist of, and to produce shorter lines. Best regards, Jan -- +- Jan T. Kim ---+ |*NEW*email: [EMAIL PROTECTED] | |*NEW*WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Violin plot for discrete variables.
I'd suggest dotcharts, such as: x1 - sample(letters[1:4], 100, replace=TRUE, prob=c(.2, .3, .4, .1)) x2 - sample(letters[1:4], 100, replace=TRUE, prob=c(.1, .4, .3, .2)) f1 - table(x1) / length(x1) f2 - table(x2) / length(x2) lev - factor(c(names(f1), names(f2))) require(lattice) dotplot(lev ~ c(f1, f2), groups=rep(1:2, c(length(f1), length(f2))), panel=panel.superpose) HTH, Andy From: Witold Eryk Wolski Dear Rgurus, To my knowledge the best way to visualize the distribution of a discrete variable X is plot(table(X)) The problem which I have is the following. I have to discrete variables X and Y which distribution I would like to compare. To overlay the distribution of Y with lines(table(Y)) gives not satisfying results. This is the same in case of using density or histogram. Hence, I am wondering if there is a equivalent of the vioplot function (package vioplot) for discrete variables which starts with a boxplot and than adds a rotated plot(table()) plot to each side of the box plot. Maybee I should ask it first: Does such a plot make any sense? If not are there better solutions? cheers Eryk. -- Witold Eryk Wolski __( School of Mathematics and Statistics _ \__/ University of Newcastle 'v' ||Newcastle upon Tyne, NE1 7RU, ENGLAND / \ ^^mail: [EMAIL PROTECTED] m m Phone : 044 (0)191 222 5376 FAX : 044 (0)191 222 8020 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Remove save workspace image? window when exit R
If you are using Rgui, right-click on the icon you use to start R and click on Properties, and add --no-save to the command that starts R. Andy From: Luis Ridao Cruz R-help, I wish to remove the message at the end of a session save workspace image? . By googling I found no answer . Thanks in advance I run on Windows XP version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] type=raw vs type=class
Hello! Could someone explain me the meaning of predict function parameter named type: 1. type=raw 2.type=class Thank you. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] type=raw vs type=class
For what class? Those don't sound like they apply to _all_ predict methods. Andy From: Leonn Turner Hello! Could someone explain me the meaning of predict function parameter named type: 1. type=raw 2.type=class Thank you. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Force labelling of x-axis
On Sun, 2005-03-20 at 23:15 -0500, Bill Kranec wrote: Hi, I'm trying to do a box-whisker plot of two columns of a data frame, a list of category names in one column vs. some numerical values in the other. The plot itself works fine, but only a few points of the x-axis ( the category names ) are labelled. I think that this is because the category names are too long. Is there any way to force R to label each x-axis value, preferably at a 45-degree slant so that each one can be seen? I feel like this should be pretty easy to do, but I can't find anything obvious from the R-manual. Bill, there have been a couple of other suggestions, but I'll throw in my $0.02 here: Without a specific example it is hard to know which way to recommend to you, but a couple of possibilities if you are using R's base graphics: 1. Reduce the font size of the labels by using 'cex.axis' as an argument in your call to boxplot(). The default is 1, but you may be able to reduce it to something that gets your labels printed and still be readable. Here is an example: group - sample(c(Long Label 1, Long Label 2, Long Label 3), 40, replace = TRUE) N - rnorm(40) df - data.frame(group, N) boxplot(N ~ Group, data = df) # Now reduce the size of the labels boxplot(N ~ group, data = df, cex.axis = 0.75) 2. You can split the labels on two lines by using a \n in the labels: boxplot(N ~ group, data = df, xaxt = n) mtext(1, at = 1:3, text = c(Long\nLabel 1, Long\nLabel 2, Long\nLabel 3), line = 2) If you want to reduce the font size in the above use 'cex = ...' in the call to mtext(). 3. If neither of the above (or a combination of the two) helps, there is a FAQ (7.27) that provides an example of how to rotate axis labels at: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated- axis-labels_003f Beware of line wrapping in the above URL. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Convert numeric to class
Dear all, I have a script about iteration classification, like this below data(iris) N - 5 ir.tr.iter - vector('list',N) ir.tr - vector('list',N) for (j in 1:N) { ir.tr[[j]] - rpart(Species ~., data=iris) ir.tr.iter[j] - ir.tr[[j]]$frame result - list(ir.tr=ir.tr, ir.tr.iter=ir.tr.iter) } as.data.frame(as.matrix(ir.tr.iter)) Because I need the result as dataframe I convert to as.matrix, but all it only numeric as.data.frame(as.matrix(ir.tr.iter)) V1 1 4, 1, 5, 1, 1 2 4, 1, 5, 1, 1 3 4, 1, 5, 1, 1 4 4, 1, 5, 1, 1 5 4, 1, 5, 1, 1 ir.tr.iter [[1]] [1] Petal.Length leaf Petal.Width leaf leaf Levels: leaf Sepal.Length Sepal.Width Petal.Length Petal.Width . . . [[5]] [1] Petal.Length leaf Petal.Width leaf leaf Levels: leaf Sepal.Length Sepal.Width Petal.Length Petal.Width I don't know where are 1, 4 and 5 (numeric) come from, but I guest 1 (leaf), 4 (Petal.Length) and 5 (Petal.Width). I want to convert the species (class/type) like, V1 Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf How can I do? Thanks in advance. Xiyan Lon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Bug on the stem function or in my brain ?
Good day R-ers! I was running the basic statistics for the exam that my students took last week and something does not make sense with the stem() fucntion. Here are two of my variables: time, is time to complete the exam in minutes exam.1, is the grade for the exam In stem(), to the left of the vertical bar are the leading digits of the grades. To the right of the vertical bar are the last digits of the grades. Each single digit on the right represents one grade. time [1] 32 41 47 50 59 64 66 66 67 67 68 69 73 78 83 90 93 93 95 [20] 100 100 110 stem(time) The decimal point is 1 digit(s) to the right of the | 2 | 2 4 | 1709 6 | 466778938 8 | 30335 10 | 000 The stem and leaf plot does not reflect the actual data, the bottom line for instance says there were 3 people that spent 100 minutes working on the test. The next to bottom line says there were one 80, three 83s, one 85. And so forth. exam.1 [1] 82 100 86 81 88 78 92 23 91 49 97 9 89 78 93 60 80 80 83 [20] 94 51 100 stem(exam.1) The decimal point is 1 digit(s) to the right of the | 0 | 9 2 | 3 4 | 91 6 | 088 8 | 0012368912347 10 | 00 The Stem-and-Leaf plots DO NOT correspond to the data. Any educational insights on this issue would be appreciated. Regards, Jose class(exam.1) [1] numeric class(time) [1] numeric version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R -- Jose A. Hernandez Ph.D. Candidate Precision Agriculture Center Department of Soil, Water, and Climate University of Minnesota 1991 Upper Buford Circle St. Paul, MN 55108 Ph. (612) 625-0445, Fax. (612) 625-2208 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Convert numeric to class
-Original Message- From: Xiyan Lon Dear all, I have a script about iteration classification, like this below data(iris) N - 5 ir.tr.iter - vector('list',N) ir.tr - vector('list',N) for (j in 1:N) { ir.tr[[j]] - rpart(Species ~., data=iris) ir.tr.iter[j] - ir.tr[[j]]$frame result - list(ir.tr=ir.tr, ir.tr.iter=ir.tr.iter) } as.data.frame(as.matrix(ir.tr.iter)) Because I need the result as dataframe I convert to as.matrix, The `frame' component of an rpart object should already be a data frame. You just need to make sure to assign them to components of ir.tr.iter, as, e.g., ir.tr.iter[[j]] - ir.tr[[j]]$frame BTW, why would you want to duplicate the data in `result'? You can easily get the `frame' component from ir.tr, so why store a separate copy? Andy but all it only numeric as.data.frame(as.matrix(ir.tr.iter)) V1 1 4, 1, 5, 1, 1 2 4, 1, 5, 1, 1 3 4, 1, 5, 1, 1 4 4, 1, 5, 1, 1 5 4, 1, 5, 1, 1 ir.tr.iter [[1]] [1] Petal.Length leaf Petal.Width leaf leaf Levels: leaf Sepal.Length Sepal.Width Petal.Length Petal.Width . . . [[5]] [1] Petal.Length leaf Petal.Width leaf leaf Levels: leaf Sepal.Length Sepal.Width Petal.Length Petal.Width I don't know where are 1, 4 and 5 (numeric) come from, but I guest 1 (leaf), 4 (Petal.Length) and 5 (Petal.Width). I want to convert the species (class/type) like, V1 Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf Petal.Length leaf Petal.Width leaf leaf How can I do? Thanks in advance. Xiyan Lon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Maximum amount of memory
Hi, I have a problem:I need to use the maximum amount of memory in order to perform a very tough analysis. By purchasing the suitable computer, what's the maximum amount of memory obtainable in R? Thanks, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] rpart memory problem
Hi everyone, I have a problem using rpart (R 2.0.1 under Unix) Indeed, I have a large matrix (9271x7), my response variable is numeric and all my predictor variables are categorical (from 3 to 8 levels). Here is an example : mydata[1:5,] distance group3 group4 group5 group6 group7 group8 pos_10.141836040224967 a c e a g g pos_501 0.153605961621317 a a a a g g pos_1001 0.152246705384699 a c e a g g pos_1501 0.145563737522463 a c e a g g pos_2001 0.143940027378837 a c e e g g When using rpart() as follow, the program runs for ages, and after a few hours, R is abruptly killed : library(rpart) fit - rpart(distance ~ ., data = mydata) When I change the categorical variables into numeric values (e.g. a = 1, b = 2, c = 3, etc...), the program runs normally in a few seconds. But this is not what I want because it separates my variables according to group7 4.5 (continuous) and not group7 = a,b,d,f or c,e,g (discrete). here is the result : fit n= 9271 node), split, n, deviance, yval * denotes terminal node 1) root 9271 28.43239000 0.1768883 2) group7=4.5 5830 4.87272700 0.1534626 4) group5 5.5 5783 3.29538700 0.1520110 8) group5=4.5 3068 0.68517040 0.1412967 * 9) group5 4.5 2715 1.86003600 0.1641184 * 5) group5=5.5 47 0.06597044 0.3320614 * 3) group7 4.5 3441 14.93984000 0.2165781 6) group5 1.5 1461 1.00414700 0.1906630 * 7) group5=1.5 1980 12.2305 0.2357002 14) group6=2.5 1659 2.95395700 0.2090232 28) group3=2.5 1315 1.65184200 0.1957505 * 29) group3 2.5 344 0.18490260 0.2597607 * 15) group6 2.5 321 1.99404400 0.3735729 * When I create a small dataframe such as the example above, e.g. : distance = rnorm(5,0.15,0.01) group3 = c(a,a,a,a,a) group4 = c(c,a,c,c,c) group5 = c(e,a,e,e,e) group6 = c(a,a,a,a,e) smalldata = data.frame(cbind(distance,group3,group4,group5,group6)) The program runs normally in a few seconds. Why does it work using the large dataset whith only numeric values but not with categorical predictor variables ? I have the impression that it considers my response variable also as a categorical variable and therefore it can't handle 9271 levels, which is quite normal. Is there a way to solve this problem ? I thank you all for your time and help, Jennifer Becq __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] How to do knn regression
How can I do a simple k nearest neighbor regression in R? My training data have 1 predictor and 1 outcome, both are numeric. I also need to use FPE and SC to find the optimal model. I know there is knn() in class package, but it's for knn classification. I also find a kknn package. What function should I use? Thanks in advance! Menghui __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] How to do knn regression
ksmooth() will work for you, since you only have one predictor. There are better choices, though, such as loess(). Andy From: Menghui Chen How can I do a simple k nearest neighbor regression in R? My training data have 1 predictor and 1 outcome, both are numeric. I also need to use FPE and SC to find the optimal model. I know there is knn() in class package, but it's for knn classification. I also find a kknn package. What function should I use? Thanks in advance! Menghui __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convert numeric to class
On Mon, 21 Mar 2005 10:15:37 -0500, Liaw, Andy [EMAIL PROTECTED] wrote: The `frame' component of an rpart object should already be a data frame. You just need to make sure to assign them to components of ir.tr.iter, as, e.g., ir.tr.iter[[j]] - ir.tr[[j]]$frame BTW, why would you want to duplicate the data in `result'? You can easily get the `frame' component from ir.tr, so why store a separate copy? Andy Thanks for your quick respons. Because I want to make iteration for my classification, I want to see what class/type (in this example, Species) was possible exits in my iteration. Best regrads Xiyan Lon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Violin plot for discrete variables.
Witold Eryk Wolski W.E.Wolski at ncl.ac.uk writes: : : Dear Rgurus, : : To my knowledge the best way to visualize the distribution of a discrete : variable X is : plot(table(X)) : : The problem which I have is the following. I have to discrete variables : X and Y which distribution I would like to compare. To overlay the : distribution of Y with lines(table(Y)) gives not satisfying results. : This is the same in case of using density or histogram. : : Hence, I am wondering if there is a equivalent of the vioplot function : (package vioplot) for discrete variables : which starts with a boxplot and than adds a rotated plot(table()) plot : to each side of the box plot. : : Maybee I should ask it first: Does such a plot make any sense? If not : are there better solutions? You could try a barplot or a balloonplot: tab - table(stack(list(x1 = x1, x2 = x2))) # x1, x2 from Andy's post barplot(t(tab), beside = TRUE) library(gplots) balloonplot(tab) Although intended for comparing data to a theoretical distribution, rootogram can compare two discrete distributions: library(vcd) rootogram(tab[,1], tab[,2]) Another possibility is to fit each distribution to a parametric form using vcd::distplot as shown in the examples on its help page. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Bug on the stem function or in my brain ?
José, Notice that the values to the left of the | in your stem plot are all even. Odd numbers are included in the same line. Try stem(time,scale=2) The decimal point is 1 digit(s) to the right of the | 3 | 2 4 | 17 5 | 09 6 | 4667789 7 | 38 8 | 3 9 | 0335 10 | 00 11 | 0 ignacio -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jose A. Hernandez Sent: Monday, March 21, 2005 9:15 AM To: r-help@stat.math.ethz.ch Subject: [R] Bug on the stem function or in my brain ? Good day R-ers! I was running the basic statistics for the exam that my students took last week and something does not make sense with the stem() fucntion. Here are two of my variables: time, is time to complete the exam in minutes exam.1, is the grade for the exam In stem(), to the left of the vertical bar are the leading digits of the grades. To the right of the vertical bar are the last digits of the grades. Each single digit on the right represents one grade. time [1] 32 41 47 50 59 64 66 66 67 67 68 69 73 78 83 90 93 93 95 [20] 100 100 110 stem(time) The decimal point is 1 digit(s) to the right of the | 2 | 2 4 | 1709 6 | 466778938 8 | 30335 10 | 000 The stem and leaf plot does not reflect the actual data, the bottom line for instance says there were 3 people that spent 100 minutes working on the test. The next to bottom line says there were one 80, three 83s, one 85. And so forth. exam.1 [1] 82 100 86 81 88 78 92 23 91 49 97 9 89 78 93 60 80 80 83 [20] 94 51 100 stem(exam.1) The decimal point is 1 digit(s) to the right of the | 0 | 9 2 | 3 4 | 91 6 | 088 8 | 0012368912347 10 | 00 The Stem-and-Leaf plots DO NOT correspond to the data. Any educational insights on this issue would be appreciated. Regards, Jose class(exam.1) [1] numeric class(time) [1] numeric version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R -- Jose A. Hernandez Ph.D. Candidate Precision Agriculture Center Department of Soil, Water, and Climate University of Minnesota 1991 Upper Buford Circle St. Paul, MN 55108 Ph. (612) 625-0445, Fax. (612) 625-2208 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Maximum amount of memory
Hi, I have a problem:I need to use the maximum amount of memory in order to perform a very tough analysis. By purchasing the suitable computer, what's the maximum amount of memory obtainable in R? Thanks, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] NaN
On Mon, 21 Mar 2005, Brett Stansfield wrote: Dear R What does NaN mean? Not a Number. It is the result of improper mathematical expressions such as 0/0, Inf/Inf, logarithms of negative numbers, and so on. Might you have some zeros in `para' giving -Inf logpara? -thomas I recently did a correlation on a batch of data for some reason it didn't like one column cor(sleep,use=complete.obs) BodyWt BrainWt SlowSleep ParaSleep TotalSleep BodyWt 1. 0.95584875 -0.3936373 -0.07488845 -0.3428373 BrainWt 0.95584875 1. -0.3867947 -0.07427740 -0.3370815 SlowSleep -0.39363729 -0.38679474 1.000 0.51824287 0.9676730 ParaSleep -0.07488845 -0.07427740 0.5182429 1. 0.7171864 TotalSleep -0.34283732 -0.33708151 0.9676730 0.71718643 1.000 Lifespan 0.46982146 0.62938940 -0.3722345 -0.26834006 -0.3824462 Gestation0.71434413 0.73353206 -0.6061048 -0.40893177 -0.6144743 PredIndex0.09588524 -0.01538017 -0.3526558 -0.39795310 -0.4047155 ExposeIndex 0.40563880 0.32318968 -0.5802789 -0.50363338 -0.6213578 DangerIndex 0.25932512 0.15093686 -0.5346247 -0.57194862 -0.6043029 logbrw 0.47461094 0.53992522 -0.6302266 -0.36884187 -0.6223073 loglife 0.37351520 0.45819097 -0.3549184 -0.38521174 -0.4028017 loggest 0.41308558 0.45045240 -0.5754478 -0.57234786 -0.6376850 logbw0.50905390 0.52255094 -0.6603217 -0.26930774 -0.6174775 logpara NaN NaNNaN NaNNaN Lifespan Gestation PredIndex ExposeIndex DangerIndex BodyWt 0.46982146 0.71434413 0.09588524 0.4056388 0.25932512 BrainWt 0.62938940 0.73353206 -0.01538017 0.3231897 0.15093686 SlowSleep -0.37223446 -0.60610477 -0.35265576 -0.5802789 -0.53462471 ParaSleep -0.26834006 -0.40893177 -0.39795310 -0.5036334 -0.57194862 TotalSleep -0.38244618 -0.61447431 -0.40471545 -0.6213578 -0.60430286 Lifespan 1. 0.64638866 -0.16973575 0.3157456 0.01468596 Gestation0.64638866 1. 0.09079823 0.5734727 0.30623551 PredIndex -0.16973575 0.09079823 1. 0.6256876 0.92731729 ExposeIndex 0.31574564 0.57347265 0.62568764 1.000 0.78980702 DangerIndex 0.01468596 0.30623551 0.92731729 0.7898070 1. logbrw 0.73584286 0.78178948 0.07112786 0.6132218 0.28600619 loglife 0.87677362 0.63260838 -0.09023386 0.5042496 0.14082719 loggest 0.56014783 0.88539870 0.09040680 0.5830778 0.30998808 logbw0.64683285 0.75938272 0.13046983 0.6473671 0.33957121 logpara NaN NaN NaN NaN NaN logbrw loglifeloggest logbw logpara BodyWt 0.47461094 0.37351520 0.4130856 0.5090539 NaN BrainWt 0.53992522 0.45819097 0.4504524 0.5225509 NaN SlowSleep -0.63022657 -0.35491836 -0.5754478 -0.6603217 NaN ParaSleep -0.36884187 -0.38521174 -0.5723479 -0.2693077 NaN TotalSleep -0.62230729 -0.40280169 -0.6376850 -0.6174775 NaN Lifespan 0.73584286 0.87677362 0.5601478 0.6468328 NaN Gestation0.78178948 0.63260838 0.8853987 0.7593827 NaN PredIndex0.07112786 -0.09023386 0.0904068 0.1304698 NaN ExposeIndex 0.61322176 0.50424965 0.5830778 0.6473671 NaN DangerIndex 0.28600619 0.14082719 0.3099881 0.3395712 NaN logbrw 1. 0.79233406 0.7771888 0.9514144 NaN loglife 0.79233406 1. 0.6417551 0.7079108 NaN loggest 0.77718882 0.64175514 1.000 0.7069276 NaN logbw0.95141435 0.70791078 0.7069276 1.000 NaN logpara NaN NaNNaNNaN 1 for some reason log para has this NaN symbol come up __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convex hull line coordinates..
Hello, I'm not sure i got your question right, but i think the whole point is to find the equation of a line which passes by two points See ?lm Romain. Le 21.03.2005 11:09, [EMAIL PROTECTED] a écrit : Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with approx to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the yleft or yright doesnt seem to help.. Any suggestions? Thank you in advance Achilleas Psomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Romain FRANCOIS : [EMAIL PROTECTED] page web : http://addictedtor.free.fr/ (en construction) 06 18 39 14 69 / 01 46 80 65 60 ___ Etudiant en 3eme année Institut de Statistique de l'Université de Paris (ISUP) Filière Industrie et Services http://www.isup.cicrp.jussieu.fr/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Graphics (for goodness of fit) Question
In regards to your plot question, you could use points() or lines(): a - sample(1:50,10) b - sample(20:40,10) plot(1:10,a,pch=20,col=red) points(1:10,b,pch=20,col=blue) #or #lines(1:10,b,pch=20,col=blue,type=o) -Original Message- From: Mohammad Ehsanul Karim [mailto:[EMAIL PROTECTED] Sent: Sunday, March 20, 2005 10:46 AM To: r-help@stat.math.ethz.ch Subject: [R] Graphics (for goodness of fit) Question Dear List, Suppose, I have some observed and expected frequencies, such as following. I need to draw a graph where plots of observed and expected frequencies are merged into one. m - c(1,2,3,4,5,6,7,8,9,10,12,13,17) k - c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 19) ExpWW - c(0.309330628803245, 0.213645190887434, 0.147558189649435, 0.101913922060107, 0.0703888244654489, 0.0486154051328303, 0.0335771712935674, 0.0231907237838939, 0.0160171226134196, 0.0110625360037919, 0.00764055478558038, 0.00527709716935116, 0.000395627498345897) ExpDD - c(0.420249653259362, 0.243639882194748, 0.141250306182253, 0.0818899139863827, 0.0474757060281664, 0.0275240570315860, 0.0159570816077711, 0.00925112359507395, 0.00536334211198462, 0.00310939944911175, 0.00104510169329968, 0.00060589806906972, 6.84484529305126e-05) ObjDD - c(0.468646864686469, 0.198019801980198, 0.151815181518152, 0.0759075907590759, 0.0396039603960396, 0.0198019801980198, 0.0165016501650165, 0.0099009900990099, 0.0033003300330033, 0.0033003300330033, 0.0033003300330033, 0.0066006600660066, 0.0033003300330033) ObjWW - c(0.373770491803279, 0.150819672131148, 0.127868852459016, 0.0721311475409836, 0.0885245901639344, 0.0622950819672131, 0.039344262295082, 0.0327868852459016, 0.0360655737704918, 0.00327868852459016, 0.00655737704918033, 0.00327868852459016, 0.00327868852459016) par(mfrow=c(2,2)) plot(k,ObjWW, type=l) # Plot 1 plot(k,ExpWW, type=l) # Plot 2 plot(m,ObjDD, type=l) # Plot 3 plot(m,ExpDD, type=l) # Plot 4 # I need to see plot 1 and 2 in same axis, and plot 3 and 4 in another # (i.e., 3, 4 both in same axis too, but not with 1 and 2's). # How can i use different types of legends in the same graph?? sum(((ObjWW-ExpWW)^2)/ExpWW) # Chi-Squared Goodness of Fit Test sum(((ObjDD-ExpDD)^2)/ExpDD) # Chi-Squared Goodness of Fit Test # Also, is there any other convenient way of doing chi-squared goodness of fit test (any function or package may be, to do this directly)? # And how can i find the P-values of the respective chi-squared tests in R? Any suggestion, direction, references, help, replies will be highly appreciated. Thank you for your time. Mohammad Ehsanul Karim Web: http://snipurl.com/ehsan Institute of Statistical Reseach and Training University of Dhaka, Dhaka - 1000, Bangladesh __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Violin plot for discrete variables.
AndyL == Liaw, Andy [EMAIL PROTECTED] on Mon, 21 Mar 2005 08:14:20 -0500 writes: AndyL I'd suggest dotcharts, such as: AndyL x1 - sample(letters[1:4], 100, replace=TRUE, prob=c(.2, .3, .4, .1)) AndyL x2 - sample(letters[1:4], 100, replace=TRUE, prob=c(.1, .4, .3, .2)) AndyL f1 - table(x1) / length(x1) AndyL f2 - table(x2) / length(x2) AndyL lev - factor(c(names(f1), names(f2))) AndyL require(lattice) AndyL dotplot(lev ~ c(f1, f2), groups=rep(1:2, c(length(f1), length(f2))), AndyL panel=panel.superpose) yes. Maybe slightly even more useful --- and closer to the plot(table(.)), ...) that Witold mentioned would be the following slight variation: dotplot(lev ~ c(f1, f2), groups=rep(1:2, c(length(f1), length(f2))), panel=panel.superpose, type =c(p,h)) Note the nice lattice feature (thanks to Deepayan Sarkar!) of allowing type to be a union of two basic types. Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convex hull line coordinates..
?chull states: Value: An integer vector giving the indices of the points lying on the convex hull, in clockwise order. therefore (see Example in ?chull) you have the end points of each line segment from which you can compute the equation of each line segment. Since the precision of the calculation is finite, there will necessarily be some portion of each line that may fall on one side or the other of the true convex hull. Or am I off base? Clint On Mon, 21 Mar 2005, Romain Francois wrote: Hello, I'm not sure i got your question right, but i think the whole point is to find the equation of a line which passes by two points See ?lm Romain. Le 21.03.2005 11:09, [EMAIL PROTECTED] a écrit : Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with approx to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the yleft or yright doesnt seem to help.. Any suggestions? Thank you in advance Achilleas Psomas __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Clint BowmanINTERNET: [EMAIL PROTECTED] Air Quality Modeler INTERNET: [EMAIL PROTECTED] Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360) 407-7534 Olympia, WA 98504-7600 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] NEXT WEEK: New York City Data Mining Conference: Two full-days of Case Study Presentations
Apologies for cross posting - Salford Systems Data Mining 2005 New York, March 28-30, 2005 Focusing on the Contributions of Data Mining to Solving Real World Challenges Two Full Days of Case Study Presentations CONFERENCE SCHEDULE http://www.salforddatamining.com/program.htm -- TRACKS: Data Mining Issues and Implementation Real World Success Stories: Business Real World Success Stories: Biomedical Real World Success Stories: Environmental Novel Methodologies POST-CONFERENCE HANDS-ON TRAINING March 31 - April 1, 2005 Network with Data Mining Experts and Pick up Pointers from Companies, Research Centers and Laboratories Including: The International Monetary Fund, American Express, Barnes and Noble, Visa, Pfizer, International Steel, Wells Fargo Bank, Ciphergen, Stanford Linear Accelerator, Johns Hopkins University Medical School, ATT Labs - Research and the Columbia University School of Public Health. If you have an interest in attending this conference or the post-conference training, please contact Lisa Solomon: Phone: 619-543-8880 x14, Email: [EMAIL PROTECTED] Conference Website: http://www.salforddatamining.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Read a dataset with different lengths
Dear useR again, How can I read a dataset if lines in dataset did not have same elements (have different lengths), For example: 12, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 22, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 34, 5, 11, 1, 1, 6, 1, 1, 5, 14, 1, 1, 15, 1, 1 42, 5, 9, 1, 1, 14, 1, 1, 8, 16, 1, 1, 13, 1, 1 53, 7, 14, 1, 1, 14, 1, 1, 5, 21, 1, 1, 8, 1, 1 66, 3, 1, 12, 1, 1, 5, 8, 1, 1, 15, 1, 1 76, 3, 1, 11, 1, 1, 10, 7, 1, 1, 21, 1, 1 8 21, 20, 9, 1, 1, 6, 1, 1, 13, 10, 1, 1, 1 95, 7, 21, 1, 1, 13, 1, 1, 14, 2, 1, 1, 6, 1, 1 10 8, 14, 10, 1, 1, 5, 1, 1, 10, 5, 1, 1, 5, 1, 1 11 5, 20, 17, 1, 1, 19, 1, 1, 14, 7, 1, 1, 6, 1, 1 12 7, 4, 11, 1, 1, 2, 1, 1, 5, 13, 1, 1, 14, 1, 1 13 7, 14, 13, 1, 1, 6, 1, 1, 13, 16, 1, 1, 17, 1, 1 14 7, 14, 5, 1, 1, 5, 1, 1, 5, 17, 1, 1, 17, 1, 1 15 3, 9, 12, 1, 1, 18, 1, 1, 6, 1, 4, 1, 1 16 7, 10, 5, 1, 1, 12, 1, 1, 5, 17, 1, 1, 13, 1, 1 17 12, 8, 16, 1, 1, 5, 1, 1, 8, 10, 1, 1, 14, 1, 1 18 5, 11, 7, 1, 1, 5, 1, 1, 18, 13, 1, 1, 17, 1, 1 19 7, 13, 8, 1, 1, 14, 1, 1, 5, 17, 1, 1, 13, 1, 1 20 7, 18, 21, 1, 1, 16, 1, 1, 5, 17, 1, 1, 13, 1, 1 I know that in BioC package rmutil have a function (read.list) to handle different lengths sets of lines but it did not work. library(rmutil) Error in library(rmutil) : 'rmutil' is not a valid package -- installed 2.0.0? Are there any others function to handle this. Best regards Xiyan Lon version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] classes of data (with a variable size)
Have you looked at sample and the various ways of subscripting in, e.g., An Introduction to R [the upper left option after help.start() in R 2.0.1]? Beyond that, I'm very sorry, but I can't understand what you are asking. If this does NOT answer your question, please read the posting guide (http://www.R-project.org/posting-guide.html). Only last week, we had several comments from people saying they had solved their own problem in the process of preparing a very simple example of what they were trying to do, as suggested in the posting guide. Even if that process does not answer your question, I believe it will increase the chances you will get a useful reply from your nest post to this list. hope this helps. spencer Guillaume STORCHI wrote: How is it possible to split a data.frame in order to get classes with variable size. actually I'd like to get classes of data with classe size (cs) so that cs becomes bigger with an other increasing value. Guillaume Storchi __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Maximum amount of memory
On 21 Mar 2005, at 4:42 pm, [EMAIL PROTECTED] wrote: Hi, I have a problem:I need to use the maximum amount of memory in order to perform a very tough analysis. By purchasing the suitable computer, what's the maximum amount of memory obtainable in R? Assuming that R is happy to use 64-bit memory pointers, the limit will be your wallet. You could buy an SGI Altix and just keep buying more and more memory for it. I don't know the limit - I know that SGI have sold one machine in Japan with 13 terabytes of memory. We have two of them here with 192 GB of RAM each, but I haven't tried R on them yet - they're used for other things. Whether such a course of action is sensible is another matter. Large memory machines rapidly become *extremely* expensive; once you have to use DIMMs larger than 1GB each, the price becomes prohibitive. Consider spending the same amount of money on employing several programmers and/or statisticians to break your problem down into smaller tasks than are tractable on smaller machines. Our 192 GB machine cost quite a lot more than 192 desktop PCs with 1GB of RAM each. In fact, the memory becomes so expensive the rest of the machine is virtually free, in comparison. :-) If you can get away with more modest amounts of memory, then a machine like the HP DL-585 might suit you - a quad processor Opteron, which can take up to 32GB or so of memory. Fairly modest price. Tim -- Dr Tim Cutts Informatics Systems Group, Wellcome Trust Sanger Institute GPG: 1024D/E3134233 FE3D 6C73 BBD6 726A A3F5 860B 3CDD 3F56 E313 4233 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Read a dataset with different lengths
If the file is formatted as you've shown, you should be able to read it with read.fwf(). Andy From: Xiyan Lon Dear useR again, How can I read a dataset if lines in dataset did not have same elements (have different lengths), For example: 12, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 22, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 34, 5, 11, 1, 1, 6, 1, 1, 5, 14, 1, 1, 15, 1, 1 42, 5, 9, 1, 1, 14, 1, 1, 8, 16, 1, 1, 13, 1, 1 53, 7, 14, 1, 1, 14, 1, 1, 5, 21, 1, 1, 8, 1, 1 66, 3, 1, 12, 1, 1, 5, 8, 1, 1, 15, 1, 1 76, 3, 1, 11, 1, 1, 10, 7, 1, 1, 21, 1, 1 8 21, 20, 9, 1, 1, 6, 1, 1, 13, 10, 1, 1, 1 95, 7, 21, 1, 1, 13, 1, 1, 14, 2, 1, 1, 6, 1, 1 10 8, 14, 10, 1, 1, 5, 1, 1, 10, 5, 1, 1, 5, 1, 1 11 5, 20, 17, 1, 1, 19, 1, 1, 14, 7, 1, 1, 6, 1, 1 12 7, 4, 11, 1, 1, 2, 1, 1, 5, 13, 1, 1, 14, 1, 1 13 7, 14, 13, 1, 1, 6, 1, 1, 13, 16, 1, 1, 17, 1, 1 14 7, 14, 5, 1, 1, 5, 1, 1, 5, 17, 1, 1, 17, 1, 1 15 3, 9, 12, 1, 1, 18, 1, 1, 6, 1, 4, 1, 1 16 7, 10, 5, 1, 1, 12, 1, 1, 5, 17, 1, 1, 13, 1, 1 17 12, 8, 16, 1, 1, 5, 1, 1, 8, 10, 1, 1, 14, 1, 1 18 5, 11, 7, 1, 1, 5, 1, 1, 18, 13, 1, 1, 17, 1, 1 19 7, 13, 8, 1, 1, 14, 1, 1, 5, 17, 1, 1, 13, 1, 1 20 7, 18, 21, 1, 1, 16, 1, 1, 5, 17, 1, 1, 13, 1, 1 I know that in BioC package rmutil have a function (read.list) to handle different lengths sets of lines but it did not work. library(rmutil) Error in library(rmutil) : 'rmutil' is not a valid package -- installed 2.0.0? Are there any others function to handle this. Best regards Xiyan Lon version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convex hull line coordinates..
Romain Francois wrote: Hello, I'm not sure i got your question right, but i think the whole point is to find the equation of a line which passes by two points See ?lm Or see a basic geometry book, where you will find a formula such as: (x-x1)/(y-y1) = (x2-x1)/(y2-y1) for the equation of a line passing through (x1,y1) and (x2,y2). Just watch out for y2==y1 and the inevitable division by zero. Might be better to ask what you want the line for in order to find a representation that better suits your need - a single point and slope, perhaps. Baz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Read a dataset with different lengths
Xiyan Lon wrote: Dear useR again, How can I read a dataset if lines in dataset did not have same elements (have different lengths), For example: 12, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 22, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 34, 5, 11, 1, 1, 6, 1, 1, 5, 14, 1, 1, 15, 1, 1 42, 5, 9, 1, 1, 14, 1, 1, 8, 16, 1, 1, 13, 1, 1 53, 7, 14, 1, 1, 14, 1, 1, 5, 21, 1, 1, 8, 1, 1 66, 3, 1, 12, 1, 1, 5, 8, 1, 1, 15, 1, 1 76, 3, 1, 11, 1, 1, 10, 7, 1, 1, 21, 1, 1 8 21, 20, 9, 1, 1, 6, 1, 1, 13, 10, 1, 1, 1 95, 7, 21, 1, 1, 13, 1, 1, 14, 2, 1, 1, 6, 1, 1 10 8, 14, 10, 1, 1, 5, 1, 1, 10, 5, 1, 1, 5, 1, 1 11 5, 20, 17, 1, 1, 19, 1, 1, 14, 7, 1, 1, 6, 1, 1 12 7, 4, 11, 1, 1, 2, 1, 1, 5, 13, 1, 1, 14, 1, 1 13 7, 14, 13, 1, 1, 6, 1, 1, 13, 16, 1, 1, 17, 1, 1 14 7, 14, 5, 1, 1, 5, 1, 1, 5, 17, 1, 1, 17, 1, 1 15 3, 9, 12, 1, 1, 18, 1, 1, 6, 1, 4, 1, 1 16 7, 10, 5, 1, 1, 12, 1, 1, 5, 17, 1, 1, 13, 1, 1 17 12, 8, 16, 1, 1, 5, 1, 1, 8, 10, 1, 1, 14, 1, 1 18 5, 11, 7, 1, 1, 5, 1, 1, 18, 13, 1, 1, 17, 1, 1 19 7, 13, 8, 1, 1, 14, 1, 1, 5, 17, 1, 1, 13, 1, 1 20 7, 18, 21, 1, 1, 16, 1, 1, 5, 17, 1, 1, 13, 1, 1 For data structured as above, read.fwf() should work. I know that in BioC package rmutil have a function (read.list) to handle different lengths sets of lines but it did not work. library(rmutil) Error in library(rmutil) : 'rmutil' is not a valid package -- installed 2.0.0? You have to install a version that has been compiled for R-2.0.x Uwe Ligges Are there any others function to handle this. Best regards Xiyan Lon version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Read a dataset with different lengths
Without some sort of formatting or prior knowledge to indicate which fields are present and which are missing, I don't see how such a file can be properly read. With such formatting present, there are several ways. e.g. See ?read.table, ?readLines, ?scan, ?connections, ... -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Xiyan Lon Sent: Monday, March 21, 2005 9:41 AM To: R-help@stat.math.ethz.ch Subject: [R] Read a dataset with different lengths Dear useR again, How can I read a dataset if lines in dataset did not have same elements (have different lengths), For example: 12, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 22, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 34, 5, 11, 1, 1, 6, 1, 1, 5, 14, 1, 1, 15, 1, 1 42, 5, 9, 1, 1, 14, 1, 1, 8, 16, 1, 1, 13, 1, 1 53, 7, 14, 1, 1, 14, 1, 1, 5, 21, 1, 1, 8, 1, 1 66, 3, 1, 12, 1, 1, 5, 8, 1, 1, 15, 1, 1 76, 3, 1, 11, 1, 1, 10, 7, 1, 1, 21, 1, 1 8 21, 20, 9, 1, 1, 6, 1, 1, 13, 10, 1, 1, 1 95, 7, 21, 1, 1, 13, 1, 1, 14, 2, 1, 1, 6, 1, 1 10 8, 14, 10, 1, 1, 5, 1, 1, 10, 5, 1, 1, 5, 1, 1 11 5, 20, 17, 1, 1, 19, 1, 1, 14, 7, 1, 1, 6, 1, 1 12 7, 4, 11, 1, 1, 2, 1, 1, 5, 13, 1, 1, 14, 1, 1 13 7, 14, 13, 1, 1, 6, 1, 1, 13, 16, 1, 1, 17, 1, 1 14 7, 14, 5, 1, 1, 5, 1, 1, 5, 17, 1, 1, 17, 1, 1 15 3, 9, 12, 1, 1, 18, 1, 1, 6, 1, 4, 1, 1 16 7, 10, 5, 1, 1, 12, 1, 1, 5, 17, 1, 1, 13, 1, 1 17 12, 8, 16, 1, 1, 5, 1, 1, 8, 10, 1, 1, 14, 1, 1 18 5, 11, 7, 1, 1, 5, 1, 1, 18, 13, 1, 1, 17, 1, 1 19 7, 13, 8, 1, 1, 14, 1, 1, 5, 17, 1, 1, 13, 1, 1 20 7, 18, 21, 1, 1, 16, 1, 1, 5, 17, 1, 1, 13, 1, 1 I know that in BioC package rmutil have a function (read.list) to handle different lengths sets of lines but it did not work. library(rmutil) Error in library(rmutil) : 'rmutil' is not a valid package -- installed 2.0.0? Are there any others function to handle this. Best regards Xiyan Lon version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major2 minor0.1 year 2004 month11 day 15 language R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Maximum amount of memory
The amount of memory you can access depends on many things, most of which are not related to R. With a 64-bit processor and suitable OS we've used R on a machines with 16GB of RAM (and accessed most of it). Of course, the memory does get very expensive after a certain point -roger [EMAIL PROTECTED] wrote: Hi, I have a problem:I need to use the maximum amount of memory in order to perform a very tough analysis. By purchasing the suitable computer, what's the maximum amount of memory obtainable in R? Thanks, Marco __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Roger D. Peng http://www.biostat.jhsph.edu/~rpeng/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Generating Interaction Factors (combinations of Data Frame columns)
Thomas Hopper wrote: I'm starting to do a fair amount of DOE in my day job and need to generate full- and fractional-factorial designs. One of the things I'd like to do is generate all possible interaction effects, given the main effects. I've been searching through the documentation, packages and mail list archives, but the closest I can find are combin() in package combinat and combine() and combinations() in gregsmisc, none of which actually produces the results I want. Given a data frame with columns labeled A, B, C and D, I would like to generate a data frame with columns that are the combination of each of the columns in the original data frame. The output columns would be A*B, A*C, A*D, A*E, A*B*C, A*B*D,..., A*B*C*D. Alternatively, I'd want to generate the interactions for a given level (2-factor or 3-factor). If such a function already exists, I'd be more than happy to use it. If it doesn't, I can write it, but I would appreciate a little help with the algorithm for generating the combinations...how do I loop through the given factors to generate all possible combinations? Thanks, Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html library(BHH2) # on CRAN ?ffDesMatrix ?ffFullMatrix -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra -- No virus found in this outgoing message. Checked by AVG Anti-Virus. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Maximum amount of memory
Tim Cutts [EMAIL PROTECTED] writes: On 21 Mar 2005, at 4:42 pm, [EMAIL PROTECTED] wrote: Hi, I have a problem:I need to use the maximum amount of memory in order to perform a very tough analysis. By purchasing the suitable computer, what's the maximum amount of memory obtainable in R? Assuming that R is happy to use 64-bit memory pointers, the limit will be your wallet. You could buy an SGI Altix and just keep buying more and more memory for it. I don't know the limit - I know that SGI have sold one machine in Japan with 13 terabytes of memory. We have two of them here with 192 GB of RAM each, but I haven't tried R on them yet - they're used for other things. Actually, before the wallet-limit, you might bump into the limit on the size of a single object, about 2G-items (i.e 16GB with 8-byte doubles). We could fairly easily raise that limit, but beneath it is another restriction, namely that Fortran subroutines tend to work with integer sizes, so even if we had larger objects, it might be difficult to do anything with them. Whether such a course of action is sensible is another matter. Large memory machines rapidly become *extremely* expensive; once you have to use DIMMs larger than 1GB each, the price becomes prohibitive. Consider spending the same amount of money on employing several programmers and/or statisticians to break your problem down into smaller tasks than are tractable on smaller machines. Our 192 GB machine cost quite a lot more than 192 desktop PCs with 1GB of RAM each. In fact, the memory becomes so expensive the rest of the machine is virtually free, in comparison. :-) If you can get away with more modest amounts of memory, then a machine like the HP DL-585 might suit you - a quad processor Opteron, which can take up to 32GB or so of memory. Fairly modest price. Tim -- Dr Tim Cutts Informatics Systems Group, Wellcome Trust Sanger Institute GPG: 1024D/E3134233 FE3D 6C73 BBD6 726A A3F5 860B 3CDD 3F56 E313 4233 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Read a dataset with different lengths
Xiyan Lon xiyanlon at gmail.com writes: : : Dear useR again, : How can I read a dataset if lines in dataset did not have same : elements (have different lengths), For example: : : 12, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 : 22, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1 : 34, 5, 11, 1, 1, 6, 1, 1, 5, 14, 1, 1, 15, 1, 1 : 42, 5, 9, 1, 1, 14, 1, 1, 8, 16, 1, 1, 13, 1, 1 : 53, 7, 14, 1, 1, 14, 1, 1, 5, 21, 1, 1, 8, 1, 1 : 66, 3, 1, 12, 1, 1, 5, 8, 1, 1, 15, 1, 1 : 76, 3, 1, 11, 1, 1, 10, 7, 1, 1, 21, 1, 1 : 8 21, 20, 9, 1, 1, 6, 1, 1, 13, 10, 1, 1, 1 : 95, 7, 21, 1, 1, 13, 1, 1, 14, 2, 1, 1, 6, 1, 1 : 10 8, 14, 10, 1, 1, 5, 1, 1, 10, 5, 1, 1, 5, 1, 1 : 11 5, 20, 17, 1, 1, 19, 1, 1, 14, 7, 1, 1, 6, 1, 1 : 12 7, 4, 11, 1, 1, 2, 1, 1, 5, 13, 1, 1, 14, 1, 1 : 13 7, 14, 13, 1, 1, 6, 1, 1, 13, 16, 1, 1, 17, 1, 1 : 14 7, 14, 5, 1, 1, 5, 1, 1, 5, 17, 1, 1, 17, 1, 1 : 15 3, 9, 12, 1, 1, 18, 1, 1, 6, 1, 4, 1, 1 : 16 7, 10, 5, 1, 1, 12, 1, 1, 5, 17, 1, 1, 13, 1, 1 : 17 12, 8, 16, 1, 1, 5, 1, 1, 8, 10, 1, 1, 14, 1, 1 : 18 5, 11, 7, 1, 1, 5, 1, 1, 18, 13, 1, 1, 17, 1, 1 : 19 7, 13, 8, 1, 1, 14, 1, 1, 5, 17, 1, 1, 13, 1, 1 : 20 7, 18, 21, 1, 1, 16, 1, 1, 5, 17, 1, 1, 13, 1, 1 : : I know that in BioC package rmutil have a function (read.list) to : handle different lengths sets of lines but it did not work. : library(rmutil) : Error in library(rmutil) : 'rmutil' is not a valid package -- installed 2.0.0? : rmutil can be found here: http://popgen.unimaas.nl/~jlindsey/rcode.html : : Are there any others function to handle this. nf - count.fields(myfile, sep = ,) z - read.table(myfile, sep = ,, fill = TRUE, colClass = rep(numeric(), nf)) If the first line is longest you can omit the colClass argument and the nf computation. The above returns a data frame with one line per row and NAs at the end to fill it out as necessary. If you need a list of rows without the NAs: lapply(as.data.frame(t(data.matrix(z))), na.omit) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RSPython
Hello I'd like to try RSPython, but can't make it work. I think I followed all the instructions, and made this shell script to load python: - #!/bin/sh export R_HOME=/usr/local/lib/R export PYTHONPATH=$R_HOME/library/RSPython/Python:$R_HOME/library/RSPython/libs export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$R_HOME/lib python - Now, when I try to 'import RS', this message appears: import RS Error in .PythonInit() : Error in Python call: values Error in library(RSPython) : .First.lib failed for 'RSPython' Traceback (most recent call last): File stdin, line 1, in ? File /usr/local/lib/R/library/RSPython/Python/RS.py, line 69, in ? library(RSPython) File /usr/local/lib/R/library/RSPython/Python/RS.py, line 58, in library return(call(library, name)); File /usr/local/lib/R/library/RSPython/Python/RS.py, line 21, in call return RSInternal.call(name, args, other, convert, ref) RuntimeError: error in calling R: Error in library(RSPython) : .First.lib failed for 'RSPython' Perhaps I'm missing some installation step? Regardas Juan Pablo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Maximum amount of memory
On Mon, 21 Mar 2005, Tim Cutts wrote: On 21 Mar 2005, at 4:42 pm, [EMAIL PROTECTED] wrote: Hi, I have a problem:I need to use the maximum amount of memory in order to perform a very tough analysis. By purchasing the suitable computer, what's the maximum amount of memory obtainable in R? Assuming that R is happy to use 64-bit memory pointers, the limit will be your wallet. I believe there are still some limits on sizes of individual objects, such as C and Fortran code that uses int or INTEGER to hold dimensions. Many packages will definitely have problems: for example, the survival package cannot correctly handle a design matrix with more than 2^31-1 elements, no matter how much memory it has. I don't know how much of the internal R code would also break when vectors have more than 2^31-1 entries. Now, 2^31-1 entries in a numeric matrix is 16Gb in one object, so your wallet is still likely to be the practical limit. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] rpart memory problem
[EMAIL PROTECTED] wrote: Hi everyone, I have a problem using rpart (R 2.0.1 under Unix) Indeed, I have a large matrix (9271x7), my response variable is numeric and all my predictor variables are categorical (from 3 to 8 levels). Your problem is the number of levels. You get a similar number of dummy variables and your problem becomes really huge. Uwe Ligges Here is an example : mydata[1:5,] distance group3 group4 group5 group6 group7 group8 pos_10.141836040224967 a c e a g g pos_501 0.153605961621317 a a a a g g pos_1001 0.152246705384699 a c e a g g pos_1501 0.145563737522463 a c e a g g pos_2001 0.143940027378837 a c e e g g When using rpart() as follow, the program runs for ages, and after a few hours, R is abruptly killed : library(rpart) fit - rpart(distance ~ ., data = mydata) When I change the categorical variables into numeric values (e.g. a = 1, b = 2, c = 3, etc...), the program runs normally in a few seconds. But this is not what I want because it separates my variables according to group7 4.5 (continuous) and not group7 = a,b,d,f or c,e,g (discrete). here is the result : fit n= 9271 node), split, n, deviance, yval * denotes terminal node 1) root 9271 28.43239000 0.1768883 2) group7=4.5 5830 4.87272700 0.1534626 4) group5 5.5 5783 3.29538700 0.1520110 8) group5=4.5 3068 0.68517040 0.1412967 * 9) group5 4.5 2715 1.86003600 0.1641184 * 5) group5=5.5 47 0.06597044 0.3320614 * 3) group7 4.5 3441 14.93984000 0.2165781 6) group5 1.5 1461 1.00414700 0.1906630 * 7) group5=1.5 1980 12.2305 0.2357002 14) group6=2.5 1659 2.95395700 0.2090232 28) group3=2.5 1315 1.65184200 0.1957505 * 29) group3 2.5 344 0.18490260 0.2597607 * 15) group6 2.5 321 1.99404400 0.3735729 * When I create a small dataframe such as the example above, e.g. : distance = rnorm(5,0.15,0.01) group3 = c(a,a,a,a,a) group4 = c(c,a,c,c,c) group5 = c(e,a,e,e,e) group6 = c(a,a,a,a,e) smalldata = data.frame(cbind(distance,group3,group4,group5,group6)) The program runs normally in a few seconds. Why does it work using the large dataset whith only numeric values but not with categorical predictor variables ? I have the impression that it considers my response variable also as a categorical variable and therefore it can't handle 9271 levels, which is quite normal. Is there a way to solve this problem ? I thank you all for your time and help, Jennifer Becq __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Hazard function or cumulative Hazard function in R
Hi, I'm student from canada, and i'work in survival analysis.I want to know if there is a hazard function or cumulative hazard function in R or not, i know how to program it, but it is easy to use it if they exists in R. Thanks. Yassir __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convex hull line coordinates..
achilleas.psomas at wsl.ch writes: : : Hello R-Helpers.. : : I am still new in R and I have the following question.. : I am applying the function chull on a 2D dataset and have the convex hull : nicely : calculated and plotted. : Do you know if there is a way to extract the coordinates of the line created : from the connection of the chull data points.. : I have alredy tried with approx to lineary interpolate but its not working : correctly since the interpolated values sometimes fall inside the convex . : Using the yleft or yright doesnt seem to help.. : : Any suggestions? 1. First suggestion is not to post by following up on an unrelated thread since some people won't see it. e.g. try finding it on gmane. Its there but good luck on finding it. 2. Second suggestion is an example which creates a matrix z whose columns are the regression coefficients of the successive line segments. Note use of lm's subset= arg to simplify code: example(chull) # creates hpts and X and plots convex hull z - sapply(2:length(hpts), function(i) coef(lm(X[,2] ~ X[,1], subset = hpts[i-1:0])) ) # we can use z to display _full_ lines, on top of the line # _segments_ that were displyed in example(chull): for(i in 1:ncol(z)) abline(coef = z[,i], col = red, lty = 2) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Read a dataset with different lengths
Thank you for your quick respons, helps, advise, links, etc. I have solved my problems now. Best wishes, Xiyan Lon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] flatten a matrix and unflatten it
I want to flatten a matrix and unflatten it again. Please tell me how to do it. 1. given a matrix: x1 y1 z1 x2 y2 z2 ... xk yk zk convert it to a vector: x1, y1, z1, x2, y2, z2, ..., xk, yk, zk 2. given a vector: x1, y1, z1, x2, y2, z2, ..., xk, yk, zk convert it to a matrix x1 y1 z1 x2 y2 z2 ... xk yk zk It is known that the number of dimensions is 3. Thanks for any help! Bill __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] working with tables
Hi, two questions - I think simple to solve for you ... (1) I've written a function containing some loops. Each loop will generate a few outputs. Finally I have to combine them to get something like a spreadsheet that my colleagues can import in EXCEL. Up to now I'm doing it as follows: With each loop-step I assign new values for each column of my desired output like colum_A=c(column_A,new_value) At the end I combine all columns: my_table=cbind(column_A,column_B ... ) I think there should be another easier way to assign the new lines directly, isn't it? (2) I often have to use the fitdistr function included in library MASS. The generated output for e.g. $estimate has the following format: mean sd 0.01664940 0.97682797 Now I want to write ONLY THE VALUE in a new variable. By doing mean_a = ...$estimate[1] I always have the string mean IN the variable. How can I eliminate this? Thanks a lot for your answer ! Carsten __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] flatten a matrix and unflatten it
If you can rearrange things to work column-wise rather than row-wise, then dim(x) - NULL makes a matrix into a vector by concatenating columns, and dim(x) - c(m,n) makes the vector x into a matrix with column 1 equal to the first m elements of x, column 2 equal to the next m elements, etc. If you need row-major order, you can do x - as.vector(t(x)) and x - matrix(x,nrow=m,ncol=n,byrow=TRUE) Reid Huntsinger -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bill Simpson Sent: Monday, March 21, 2005 4:44 PM To: r-help Subject: [R] flatten a matrix and unflatten it I want to flatten a matrix and unflatten it again. Please tell me how to do it. 1. given a matrix: x1 y1 z1 x2 y2 z2 ... xk yk zk convert it to a vector: x1, y1, z1, x2, y2, z2, ..., xk, yk, zk 2. given a vector: x1, y1, z1, x2, y2, z2, ..., xk, yk, zk convert it to a matrix x1 y1 z1 x2 y2 z2 ... xk yk zk It is known that the number of dimensions is 3. Thanks for any help! Bill __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Highlighting points in a scatter plot matrix
Dear R I recently did a scatterplot matrix using the following command pairs(sleep[c(SlowSleep, ParaSleep, logbw, logbrw, loglife, loggest)],col=1+as.integer(ParaSleep 5.5 | SlowSleep 15.7)) this highlighted outlying points for some of the x,y plots that I needed to identify. Unfortunately this highlights all the x,y plots some for which these points are not necessarily outliers. Is there a way to specify highlighting selected points at selected x,y plots within a matrix? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] flatten a matrix and unflatten it
Bill Simpson William.Simpson at drdc-rddc.gc.ca writes: : : I want to flatten a matrix and unflatten it again. Please tell me how to : do it. : : 1. given a matrix: : x1 y1 z1 : x2 y2 z2 : ... : xk yk zk : convert it to a vector: : x1, y1, z1, x2, y2, z2, ..., xk, yk, zk : : 2. given a vector: : x1, y1, z1, x2, y2, z2, ..., xk, yk, zk : convert it to a matrix : x1 y1 z1 : x2 y2 z2 : ... : xk yk zk : : It is known that the number of dimensions is 3. : myvector - c(t(mymatrix)) mymatrix - matrix(myvector, byrow = TRUE, nc=3) If column-wise is ok rather than row-wise as you show, then omit t() in the first line and byrow = TRUE in the second. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Hazard function or cumulative Hazard function in R
yassir rabhi wrote: Hi, I'm student from canada, and i'work in survival analysis.I want to know if there is a hazard function or cumulative hazard function in R or not, i know how to program it, but it is easy to use it if they exists in R. Thanks. Yassir __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html library(survival) -- Kjetil Halvorsen. Peace is the most effective weapon of mass construction. -- Mahdi Elmandjra -- No virus found in this outgoing message. Checked by AVG Anti-Virus. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Hazard function or cumulative Hazard function in R
1. Have you looked at the survival package? Venables and Ripley (2002) Modern Applied Statistics with S (Springer) has a chapter on survival analysis that I found quite helpful. The survival package includes hazard plots, which are discussed in Venables and Ripley. 2. If that is not adequate, have you tried an R Site Search (from www.r-project.org - search)? hope this helps. spencer graves yassir rabhi wrote: Hi, I'm student from canada, and i'work in survival analysis.I want to know if there is a hazard function or cumulative hazard function in R or not, i know how to program it, but it is easy to use it if they exists in R. Thanks. Yassir __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Using locator() to digitise
I've used rimage to read in graphics files (jpeg.) If I recall correctly, I think I had to install some libraries. What I can't recall is if it was any faster than pixmap, as I was mainly concerned with the file format and the forensic image processing possibilities. Tom -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, 21 March 2005 12:09 AM To: r-help@stat.math.ethz.ch Subject: [R] Using locator() to digitise Hi Folks, I'm contemplating using locator() to digitise external graphics. To set context, I would be using X11 display on Linux. To pre-empt the obvious comment: I've found on the R site the suggestion to use the 'pixmap' package. I've tried this, and it works; but it involves building a big R object (the internal pixmap representation), and this chokes my somewhat puny laptop (e.g. it can take about 1 minute to draw the graphic inside a plot area using addlogo(), with mucho swappo, and subsequently working knee-deep in treacle). The following idea would be a lot slicker. For examples: I have something like a) A scatterplot of data printed in a journal (but the data values are not available; b) A contour map (on paper) of a region. So, I can scan the document, and obtain a file in some graphics format (jpeg, pbm or png, say). Now: an idea which I find attractive is to be able to overlay an R plot with axes onto a display of the graphics file (produced as an X window by any suitable program such as 'xv' or 'display') so that (if the overlay were possible) clicking on the points of the graphic would in fact be clicking on the R plot and, via locator(), generate the R-plot coordinates of the mouse clicks which would correspond to the selected points on the graphic. Provided the coordinate system of the R plot were properly related to the graphic, the results would be a digitisation of the selected points on the graphic. What seems to be needed for this idea to work is that the R-plot should be displayed in an X11() device whose background was completely transparent, so that when moved over the (independently generated) display of the graphic the latter would be visible (but locator() would still be working on the R-plot itself). Window resizing could look after the correspondence between graphic coordinates and R-plot coordinates. The R plot itself could be empty (apart from coordinate axes) or could contain helper elements such as grid lines, circles (e.g. I want to digitise graphics points within a certain circle), etc. Helper elements could be added to the R-plot by subsequent 'lines' or 'points' commands (e.g. I identify two points on the graphic, R-plot the line joining them, and then pick off graphic-points which lie on the R-line). So this question is really about producing a bare R plot on, as it were, a virtual acrylic transparency. It's certainly possible to do such a thing in X: e.g. the cute xteddy is in fact a picture of a bear on a completely transparent rectangular background, though you'd never know by looking! Any comments? With thanks, and best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 20-Mar-05 Time: 16:09:11 -- XFMail -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] error with polr()
Dear Sir, I get an error message when I use polr() in MASS package. My data is ord.dat. I made y a factor. y y1 y2 x lx 1 0 0 0 3.2e-02 -1.49485 2 0 0 0 3.2e-02 -1.49485 3 0 0 0 1.0e-01 -1.0 4 0 0 0 1.0e-01 -1.0 5 0 0 0 3.2e-01 -0.49485 6 0 0 0 3.2e-01 -0.49485 7 1 1 0 1.0e+00 0.0 8 0 0 0 1.0e+00 0.0 9 1 1 0 3.2e+00 0.50515 10 1 1 0 3.2e+00 0.50515 11 0 0 0 1.0e+01 1.0 12 1 1 0 1.0e+01 1.0 13 1 1 0 3.2e+01 1.50515 14 2 1 1 3.2e+01 1.50515 15 2 1 1 1.0e+02 2.0 16 1 1 0 1.0e+02 2.0 17 2 1 1 3.2e+02 2.50515 18 1 1 0 3.2e+02 2.50515 19 2 1 1 1.0e+03 3.0 20 2 1 1 1.0e+03 3.0 When I try, polr(y~lx,data=ord.dat) I gives me a output, which is the same as that from SAS. But when I try, summary(polr(y~lx,data=ord.dat)) Re-fitting to get Hessian Error in optim(start, fmin, gmin, method = BFGS, hessian = Hess, ...) : initial value in vmmin is not finite And the weird thing is that it's fine if I use x instead of lx, where lx=log10(x). thanks Sincerely, cahn __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem in textConnection function
Dear all-helpers: I create one package ,code like this: output - function(x,y) { zz -textConnection(foo,w) sink(zz) a -5 b -6 z -a*b z e -spss h -c(1,2,3) ls() r-c(s,p,s,s) p-list(1:10) p sink() close(zz) x - foo y - foo # .C(output,as.character(x),as.character(y)) } packege making is ok , but when I use output in Rgui, none of object x ory can get the result what I expect(textConnection result),when I copy the code and paste on Rgui ,it is ok.what should I do ? thanks in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] problem in textConnection function
It seems to me that you are trying to do too much at a time. Firstly I think it would be a good idea to get you code working before you try and make a package. Some possibilities are that you write somethin meaningful rather than the first thing that pops into your head. What sort of output are you really expecting When I used your code -Original Message- From: Michael S [mailto:[EMAIL PROTECTED] Sent: Tuesday, 22 March 2005 10:59 AM To: r-help@stat.math.ethz.ch Subject: [R] problem in textConnection function Dear all-helpers: I create one package ,code like this: output - function(x,y) { zz -textConnection(foo,w) sink(zz) a -5 b -6 z -a*b z e -spss h -c(1,2,3) ls() r-c(s,p,s,s) p-list(1:10) p sink() close(zz) x - foo y - foo # .C(output,as.character(x),as.character(y)) } packege making is ok , but when I use output in Rgui, none of object x ory can get the result what I expect(textConnection result),when I copy the code and paste on Rgui ,it is ok.what should I do ? thanks in advance __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] I modify my question in textconnection output
dear ALL-R-helper: I modify my question in textconnection output: I wrote one function in Rgui: output - function(y){ x - textConnection(foo,w) sink(x) a -5 b -6 z -a*b z e -spss h -c(1,2,3) ls() r-c(s,p,s,s) p-list(1:10) p y - foo sink() close(x) return(y) } I want to get resulte is : y [1] [1] 30 [2] [1] \a\ \b\ \c\ \d\ \e\ \f\ \foo\\g\ \g.p\\h\ \interp\ \m\ \mytest\ [3] [14] \output\ \p\ \r\ \var1\ \var2\ \x\ \y\ \z\ [4] [[1]] [5] [1] 1 2 3 4 5 6 7 8 9 10 [6] when I copy the command line within the function ,and paste to RGui,result is ok .but when I use the output function ,y show value of y object.I got result character(0) seem to me : I didn't get value of y within function thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] problem in textConnection function
Michael S michael_shen at hotmail.com writes: : : Dear all-helpers: : : I create one package ,code like this: : output - : function(x,y) : { : zz -textConnection(foo,w) : sink(zz) : a -5 : b -6 : z -a*b : z : e -spss : h -c(1,2,3) : ls() : r-c(s,p,s,s) : p-list(1:10) : p : sink() : close(zz) : x - foo : y - foo : # .C(output,as.character(x),as.character(y)) : } : : packege making is ok , but when I use output in Rgui, none of object x : ory can get the result what I expect(textConnection result),when I copy the : code and paste on Rgui ,it is ok.what should I do ? : This is a FAQ: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-is-the-output-not-printed- when-I-source_0028_0029-a-file_003f __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] I modify my question in textconnection output
Michael S michael_shen at hotmail.com writes: : : dear ALL-R-helper: : I modify my question in textconnection output: : I wrote one function in Rgui: : output - function(y){ : x - textConnection(foo,w) : sink(x) : a -5 : b -6 : z -a*b : z : e -spss : h -c(1,2,3) : ls() : r-c(s,p,s,s) : p-list(1:10) : p : y - foo : sink() : close(x) : return(y) : } : : I want to get resulte is : : y : : [1] [1] 30 : [2] [1] \a\ \b\ \c\ \d\ \e\ \f\ : \foo\\g\ \g.p\\h\ \interp\ \m\ : \mytest\ : [3] [14] \output\ \p\ \r\ \var1\ \var2\ \x\ : \y\ \z\ : [4] [[1]] : [5] [1] 1 2 3 4 5 6 7 8 9 10 : [6] : : when I copy the command line within the function ,and paste to RGui,result : is ok .but when I use the output function ,y show value of y object.I got : result character(0) : : seem to me : I didn't get value of y within function You have not defined foo within your function. If you have a foo outside your function then that is being assigned to y. If you haven't a foo anywhere then you should have received an error. You might want to look at ?capture.output y - capture.output({ x - 1 print(x) }) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] List of tables rather than an extra dimension in the table or (l)apply(xtabs)
I'm not sure how to best explain what I am after but here goes. I have a data frame with 2 geographical factors. One is the major region the other is the component regions. I am trying to process all the regions at the same time without using for. So I need (think, I do) a list of matrices each structured according to the number of subregions within each region. So is there a way of using lapply with xtabs or is there a better way to achieve my desired output? Using the Titanic data as an example t1 - as.data.frame(Titanic) t2 - split(t1,t1$Class) # I would then drop any unused levels in the factors for the geography creating distinctly different data.frames (see end of message) xtabs(Freq ~ Age + Sex + Class,t1) , , Class = 1st Sex Age Male Female Child 51 Adult 175 144 , , Class = 2nd Sex Age Male Female Child 11 13 Adult 168 93 , , Class = 3rd Sex Age Male Female Child 48 31 Adult 462 165 , , Class = Crew Sex Age Male Female Child 00 Adult 862 23 Can I do something with t2 to produce a list which is in effect an Age by Sex crosstab with one item for each value of Class. I would be wanting to drop.unused.levels, so that the last part of the table is just Sex Age Male Female Adult 862 23 or in my case each item in the list has the same number of rows as there are subregions for that region. List of 9 $ 1:`data.frame': 4009 obs. of 7 variables: ..$ sex : Factor w/ 2 levels Females,Males: 2 2 2 2 2 2 2 2 2 2 ... ..$ age : Factor w/ 18 levels 0-4,5-9,10-14,..: 1 1 1 1 1 1 1 1 1 1 ... ..$ lga : Factor w/ 23 levels Carnamah (S),..: 1 2 3 4 5 6 7 8 9 10 ... # 23 subregions ..$ psn : num [1:4009] 71 336 26 84 30 133 904 385 99 110 ... ..$ year : num [1:4009] 1991 1991 1991 1991 1991 ... ..$ agecomp : Factor w/ 14 levels 0-4,5-9,10-14,..: 1 1 1 1 1 1 1 1 1 1 ... ..$ RegionNum: num [1:4009] 1 1 1 1 1 1 1 1 1 1 ... $ 2:`data.frame': 720 obs. of 7 variables: ..$ sex : Factor w/ 2 levels Females,Males: 2 2 2 2 2 2 2 2 2 2 ... ..$ age : Factor w/ 18 levels 0-4,5-9,10-14,..: 1 1 1 1 2 2 2 2 3 3 ... ..$ lga : Factor w/ 4 levels Broome (S),De..,..: 1 2 3 4 1 2 3 4 1 2 ... # 4 subregions etc ..$ psn : num [1:720] 495 445 189 377 415 374 189 330 324 319 ... ..$ year : num [1:720] 1991 1991 1991 1991 1991 ... ..$ agecomp : Factor w/ 14 levels 0-4,5-9,10-14,..: 1 1 1 1 2 2 2 2 3 3 ... ..$ RegionNum: num [1:720] 2 2 2 2 2 2 2 2 2 2 ... So these two items would produce round(xtabs(psn ~ lga + agecomp,eas[[1]]),-2) agecomp lga 0-4 5-9 10-14 15-19 20-24 25-29 30-34 35-39 40-44 45-49 50-54 55-59 60-64 65plus Carnamah (S) 500 400 300 200 300 300 500 400 400 300 300 200 100 300 Carnarvon (S) 2800 3000 2600 2100 2400 2700 2800 2600 2400 2200 2000 1600 1300 2800 Chapman Valley (S) 300 400 300 200 200 300 300 300 300 400 400 300 200 300 Coorow (S) 700 700 600 200 300 600 700 600 500 500 400 400 300 500 Cue (S) 200 200 100 100 200 200 300 200 200 200 200 100 100 100 Exmouth (S) 900 1000 800 600 700 1100 1100 1100 1100 800 700 500 400 700 Geraldton (C) 7700 7700 8100 8200 7200 7400 7500 7200 6900 6100 5400 4600 4300 12400 Greenough (S) 4700 5400 5500 4400 3100 3700 4800 5100 5200 4200 3500 2600 1900 3200 Irwin (S) 1000 1100 1000 600 600 900 1000 1200 1000 900 800 900 800 1800 Meekatharra (S) 800 700 600 600 900 1000 900 700 600 500 400 300 200 400 Mingenew (S) 300 300 200 100 200 200 300 300 200 200 200 200 100 200 Morawa (S) 400 500 400 400 200 400 500 400 300 300 300 300 200 500 Mount Magnet (S) 500 400 300 200 400 500 400 400 300 300 200 200 100 200 Mullewa (S) 600 600 800 400 400 500 500 400 300 300 300 300 200 400 Murchison (S)100 100 100 100 0 100 100 0 0 0 100 0 0 0 Northampton (S) 1300 1300 1200 700 700 900 1200 1300 1200 1200 1000 1000 900 2000 Perenjori (S)300 300 300 100 200 200 300 300 300 200 200 200 100 300 Sandstone (S) 0 0 0 0 100 100 100 100 100 100 100 100 0 100 Shark Bay (S)300 300 200 200 200 300 400 400 400 300 300 300 200 600 Three Springs (S)300 300 300 100 200 300 400 300 300 200 300 200 200 400 Upper Gascoyne (S) 100
RE: [R] List of tables rather than an extra dimension in the table or (l)apply(xtabs)
I wrote a function that created the crosstab and removed the extraneous lines and then used lapply aestabs - function(x){ temp - xtabs(psn ~ lga + year,x) temp - temp[rowSums(temp) != 0,] return(temp) } eas2 - lapply(split(ipi$eas,ipi$eas$RegionNum),aestabs) It's not really reuseable. I guess I could pass a formula and work out a better method of subsetting dimensions (where certain factor levels are not used. But maybe someone has an elegant method they could share. Tom -Original Message- From: Mulholland, Tom Sent: Tuesday, 22 March 2005 1:35 PM To: R-Help (E-mail) Subject: [R] List of tables rather than an extra dimension in the table or (l)apply(xtabs) I'm not sure how to best explain what I am after but here goes. I have a data frame with 2 geographical factors. One is the major region the other is the component regions. I am trying to process all the regions at the same time without using for. So I need (think, I do) a list of matrices each structured according to the number of subregions within each region. So is there a way of using lapply with xtabs or is there a better way to achieve my desired output? Using the Titanic data as an example t1 - as.data.frame(Titanic) t2 - split(t1,t1$Class) # I would then drop any unused levels in the factors for the geography creating distinctly different data.frames (see end of message) xtabs(Freq ~ Age + Sex + Class,t1) , , Class = 1st Sex Age Male Female Child 51 Adult 175 144 , , Class = 2nd Sex Age Male Female Child 11 13 Adult 168 93 , , Class = 3rd Sex Age Male Female Child 48 31 Adult 462 165 , , Class = Crew Sex Age Male Female Child 00 Adult 862 23 Can I do something with t2 to produce a list which is in effect an Age by Sex crosstab with one item for each value of Class. I would be wanting to drop.unused.levels, so that the last part of the table is just Sex Age Male Female Adult 862 23 or in my case each item in the list has the same number of rows as there are subregions for that region. List of 9 $ 1:`data.frame': 4009 obs. of 7 variables: ..$ sex : Factor w/ 2 levels Females,Males: 2 2 2 2 2 2 2 2 2 2 ... ..$ age : Factor w/ 18 levels 0-4,5-9,10-14,..: 1 1 1 1 1 1 1 1 1 1 ... ..$ lga : Factor w/ 23 levels Carnamah (S),..: 1 2 3 4 5 6 7 8 9 10 ... # 23 subregions ..$ psn : num [1:4009] 71 336 26 84 30 133 904 385 99 110 ... ..$ year : num [1:4009] 1991 1991 1991 1991 1991 ... ..$ agecomp : Factor w/ 14 levels 0-4,5-9,10-14,..: 1 1 1 1 1 1 1 1 1 1 ... ..$ RegionNum: num [1:4009] 1 1 1 1 1 1 1 1 1 1 ... $ 2:`data.frame': 720 obs. of 7 variables: ..$ sex : Factor w/ 2 levels Females,Males: 2 2 2 2 2 2 2 2 2 2 ... ..$ age : Factor w/ 18 levels 0-4,5-9,10-14,..: 1 1 1 1 2 2 2 2 3 3 ... ..$ lga : Factor w/ 4 levels Broome (S),De..,..: 1 2 3 4 1 2 3 4 1 2 ... # 4 subregions etc ..$ psn : num [1:720] 495 445 189 377 415 374 189 330 324 319 ... ..$ year : num [1:720] 1991 1991 1991 1991 1991 ... ..$ agecomp : Factor w/ 14 levels 0-4,5-9,10-14,..: 1 1 1 1 2 2 2 2 3 3 ... ..$ RegionNum: num [1:720] 2 2 2 2 2 2 2 2 2 2 ... So these two items would produce round(xtabs(psn ~ lga + agecomp,eas[[1]]),-2) agecomp lga 0-4 5-9 10-14 15-19 20-24 25-29 30-34 35-39 40-44 45-49 50-54 55-59 60-64 65plus Carnamah (S) 500 400 300 200 300 300 500 400 400 300 300 200 100 300 Carnarvon (S) 2800 3000 2600 2100 2400 2700 2800 2600 2400 2200 2000 1600 1300 2800 Chapman Valley (S) 300 400 300 200 200 300 300 300 300 400 400 300 200 300 Coorow (S) 700 700 600 200 300 600 700 600 500 500 400 400 300 500 Cue (S) 200 200 100 100 200 200 300 200 200 200 200 100 100 100 Exmouth (S) 900 1000 800 600 700 1100 1100 1100 1100 800 700 500 400 700 Geraldton (C) 7700 7700 8100 8200 7200 7400 7500 7200 6900 6100 5400 4600 4300 12400 Greenough (S) 4700 5400 5500 4400 3100 3700 4800 5100 5200 4200 3500 2600 1900 3200 Irwin (S) 1000 1100 1000 600 600 900 1000 1200 1000 900 800 900 800 1800 Meekatharra (S) 800 700 600 600 900 1000 900 700 600 500 400 300 200 400 Mingenew (S) 300 300 200 100 200 200 300 300 200 200 200 200 100 200 Morawa (S) 400 500 400 400 200 400 500 400 300 300 300 300 200 500 Mount Magnet (S) 500 400 300 200
RE: [R] error with polr()
This is always tricky. Here is a work-around. Try asking for the Hessian with the original fit: fm - polr(factor(y) ~ lx, data = ord.dat, Hess=T) summary(fm) Call: polr(formula = factor(y) ~ lx, data = ord.dat, Hess = T) Coefficients: Value Std. Error t value lx 2.420614 0.8146359 2.971406 Intercepts: Value Std. Error t value 0|1 0.5865 0.8118 0.7224 1|2 4.8966 1.7422 2.8106 Residual Deviance: 20.43286 AIC: 26.43286 --- [I have no idea if this is the same as SAS but if not, please report the problem to SAS Inc.] Bill Venables. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chaehyung Ahn Sent: Tuesday, 22 March 2005 11:44 AM To: r-help@stat.math.ethz.ch Subject: [R] error with polr() Dear Sir, I get an error message when I use polr() in MASS package. My data is ord.dat. I made y a factor. y y1 y2 x lx 1 0 0 0 3.2e-02 -1.49485 2 0 0 0 3.2e-02 -1.49485 3 0 0 0 1.0e-01 -1.0 4 0 0 0 1.0e-01 -1.0 5 0 0 0 3.2e-01 -0.49485 6 0 0 0 3.2e-01 -0.49485 7 1 1 0 1.0e+00 0.0 8 0 0 0 1.0e+00 0.0 9 1 1 0 3.2e+00 0.50515 10 1 1 0 3.2e+00 0.50515 11 0 0 0 1.0e+01 1.0 12 1 1 0 1.0e+01 1.0 13 1 1 0 3.2e+01 1.50515 14 2 1 1 3.2e+01 1.50515 15 2 1 1 1.0e+02 2.0 16 1 1 0 1.0e+02 2.0 17 2 1 1 3.2e+02 2.50515 18 1 1 0 3.2e+02 2.50515 19 2 1 1 1.0e+03 3.0 20 2 1 1 1.0e+03 3.0 When I try, polr(y~lx,data=ord.dat) I gives me a output, which is the same as that from SAS. But when I try, summary(polr(y~lx,data=ord.dat)) Re-fitting to get Hessian Error in optim(start, fmin, gmin, method = BFGS, hessian = Hess, ...) : initial value in vmmin is not finite And the weird thing is that it's fine if I use x instead of lx, where lx=log10(x). thanks Sincerely, cahn __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Highlighting points in a scatter plot matrix
Brett Stansfield wrote: Dear R I recently did a scatterplot matrix using the following command pairs(sleep[c(SlowSleep, ParaSleep, logbw, logbrw, loglife, loggest)],col=1+as.integer(ParaSleep 5.5 | SlowSleep 15.7)) this highlighted outlying points for some of the x,y plots that I needed to identify. Unfortunately this highlights all the x,y plots some for which these points are not necessarily outliers. Is there a way to specify highlighting selected points at selected x,y plots within a matrix? It's tricky, you would have to specify your own panel functions, probably even better using lattice. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Numeric prediction
Noel Anel wrote: Hello! Which class(model) is most appropriate for numeric predition? This is a joke, isn't it? It highly depends on your problem (what numeric predition means), the data, your criterion what most appropriate means, etc. Please read some basic textbook(s) on statistics or look for a local consultant! I used rpart class... Some others start with regression analysis using linear models. Uwe Ligges Thnx, Leonn. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lattice xyplot() postscript (?) problem in R 2.0.0
Gerrit Eichner wrote: Dear all, I work with R Version 2.0.0 on Machine hardware: sun4u OS version: 5.9 Processor type: sparc Hardware: SUNW,Sun-Blade-1000 and I have a very simple data frame (called OR) with the following variables: sapply( OR, class) Xci FTyp factor numeric factor (In OR$ci there are some Inf-values. OR's complete contents are appended below.) If I do library( lattice) xyplot( X ~ ci | FTyp, data= OR) the requested trellis plot appears and everything is fine. BUT, if I want to produce this plot in a postscript file a very strange and reproducible error ocurs: postscript( OR.ps) xyplot( X ~ ci | FTyp, data= OR) Error in [-(`*tmp*`, pos.heights[[nm]], value = numeric(0)) : nothing to replace with This procedure -- applied to this very data frame -- did work fine previously, i.e., when I used R 1.9.1. (traceback() didn't help me tracking the problem further down.) I have the impression that it fails since I've started using R 2.0.0. Could this be a version related problem? Any ideas? a) You should try R-2.0.1 with a recent version of lattice (or help to try out and test R-devel). It works! b) You want to use trellis.device(postscript, ...) rather than psotscript(). Uwe Ligges Thanks for any help! Best regards -- Gerrit PS: Here are the contents of data frame OR: OR X ci FTyp 1 a 0.A 2 a 0.A 3 aInfA 4 a 1.1158B 5 a 0.2578B 6 aInfB 7 b 0.6568A 8 b 0.0159A 9 bInfA 10 b 0.1051B 11 b 0.0164B 12 bInfB 13 cInfA 14 c 0.2217A 15 cInfA 16 c 9.2356B 17 c 1.7123B 18 cInfB 19 d 0.4140A 20 d 0.0099A 21 dInfA 22 d 1.7827B 23 d 0.3606B 24 dInfB --- AR Dr. Gerrit EichnerMathematical Institute [EMAIL PROTECTED] Justus-Liebig-University Giessen Tel: +49-(0)641-99-32104Arndtstr. 2, 35392 Giessen, Germany Fax: +49-(0)641-99-32029 http://www.math.uni-giessen.de/Stochastik __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html