Re: [R] x labels out of Quartz canvas
You do this by adjusting the margin sizes. Can I suggest you read 'An Introduction to R', which has a section on the layout of graphics (perhaps the only area in which it is comprehensive). On Mon, 16 Jun 2008, MeMooMeM wrote: Hi R world, I am such a newbie, with only 4-5 days of R experience. I did a search in forum history but couldn't find a solution to my problem... Sorry if it's obvious: I managed to draw a barplot (yey!) with xlabels of 'long' names (filenames, to be particular). To make them readable, I place them perpendicular to the axis (las=2). When I do that, however, these names don't fit inside the Quartz window and they are truncated. Is there a way to change the Quartz window size after plotting (or, as an alternative, to scale the plot down so it fits in there) ? Thanks a lot! -Memo PS: This is the very first of my zillion of questions! -- View this message in context: http://www.nabble.com/x-labels-out-of-Quartz-canvas-tp17872830p17872830.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re ading OpenOffice Calc spreadsheet into R
I've developed an application which can read in data (doubles and doubles with head) directly from OpenOffice by means of the Java OpenOffice API and Rserve. Presentation: http://www.uni-bielefeld.de/biologie/Oekosystembiologie/bio7app/flashtut/transfertor.htm With kind regards Marcel -- View this message in context: http://www.nabble.com/Reading-OpenOffice-Calc-spreadsheet-into-R-tp17875898p17879366.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice: Superpose bwplot and dotplot [newbie question]
Stephen D. Weigand wrote: y - rnorm(100) g - factor(sample(c(g1, g2), size = 100, replace = TRUE)) x - factor(sample(c(A, B), size = 100, replace = TRUE)) bwplot(g ~ y | x, panel = function(x, y, ...) { panel.dotplot(x, y, ...) panel.bwplot(x, y, pch = |, ...) }) Thanks - that helped! After I realized that for my example, only the first x and y are replaced by my own variables (and not in the panel calls), it worked great! -- View this message in context: http://www.nabble.com/Lattice%3A-Superpose-bwplot-and-dotplot--newbie-question--tp17873822p17879641.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] setvalue of a combobox
if I wanted to set the value of a combobox tt - tktoplevel() box - tkwidget(tt,ComboBox,values=c(1,2,3)) tkgrid(box) tcl(box,setvalue,first) does anybody know how I would access an index other than the first? as second, and numbers do not work.. thanks in advance Andreas Posch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] PCA analysis
Hi, I have a problem with making PCA plots that are readable. I would like to set different sympols instead of the numbers of my samples or their names, that I get plotted (xlabs). How is this possible? With points, i don´t seem to get the right data plotted onto the PCA plot, as I do not quite understand from where it is taken. I dont know how to plot the correct columns of the prcomp outcome (p). I would really appreciate if someone could help me, I have struggled with this for days now. How can I make a function that gives different symbols for the points, depending on how big the number given to it as xlabs is? Making the plots. read.table(file = S:\\SEDIM\\TRFLP\\B90-700.txt,sep=\t, header=T)-boutbout -bout[-1]p - prcomp(bout) biplot(p, choices = c(2,3), scale = 1, pc.biplot = FALSE, var.axes = F, ylabs = NULL, xlabs=c(119,175,135,330,51,422,67,409,470,70,67,89,135,215,330,409,470,51,80,119,175,222,301,422,280,171,256,243,404,37,157,28,187,70,42,283,261,85,147,204,235,411,514,77,204,87,366,306,351,371,38,534,199,407,42,167,480,195,22,35,80,433,43,109,214,363,292,61,115,178,273,521,72,126,253,288,501,83,113,250,359,498,19,130,389,324,24,58,124,388,319,164,101,153,383,345,219,179,161,375,298,450,555,439,54,54,490,465,411,18,85,503,455,394,179,187,416,447,219,461,164,366,474,167,236,507,319,509,467,507,450,359,507,192,453,101,456,512,517), cex=0.67, main=90-700bp) _ [[elided Hotmail spam]] PLink [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reading csv-data from variables
Dear Listmembers, I'm looking for a convenient way to read csv-data which are stored in variables of data frames. I'm working with nested csv-data: one of the columns of the first table stores a long string containing a second csv-coded table. My problem is to parse that second-order csv-table. As the read.csv command requires a link to a file, I couldn't get it to read the data from a variable. I also tried to copy the content of the variable into the clipboard to use the read.csv(pipe(pbpaste))- function, but didn't come to a solution ... Any suggestions? Thanks! Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating Reports from R.
David Keegan wrote: Hi, I have a non-interactive R script that currently produces various graphs in png or pdf format. I need to program the script to combine the graphs with various pages of textual information, including some in tabular format, into an output report in pdf or html format. What is the recommended way of doing this? Hi David, You might find htmlize in the prettyR package will do what you want. The R2HTML package is another possibility. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating Reports from R.
Hi, Thanks for all the helpful suggestions. Regards, David. -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Measuring dispersion
Hi, I'm looking for a function to measure the dispersion of a set of values ranging from 0 to 1. This function should be 0 if all the values are evenly spaced within the interval and it should be 0 if values are clustered. The more clustered the values are, the higher should the function be. An example: [0; 0.2; 0.4; 0.6; 0.8; 1] - function should be ~ 0 [0; 0.1; 0.1; 0.15; 1] - function should be 1 This data comes from time-dependent observations recorded between a start time (0) and an end time (1). I want to find out which series are more clustered, i.e. less evenly distributed. I'm going to test Kurtosis for this but it doesn't seem to be the best tool for the job. As I understand, Kurtosis evaluates the strength of a single central peak. My data can have multiple peaks (clusters). Thanks in advance for your comments, -- Sérgio Nunes __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] alternative to multiple t-test to find steady-state
Hi, My collegue has asked me to calculate the steady state of a pharmacokinetic study. This is defined as where the concentration after a certain time doesn't increase anymore. So if I perform multiple t-tests between the sample points, with alternative less, then I can see which from which time point there isn't an increase in concentration. But this doesn't feel good to me. I don't think that this is the right way to check if the concentration is still increasing. And if I perform multiple comparisons, I should use the bonferroni correction? I was thinking about an ANOVA test to find differences between the time points, but as there are no replications and it's a paired t-test, I'm not able to calculate an ANOVA. Below you find the data, I hope someone can point me to the right way. Kind regards Bart dat -structure(list(Sample = 1:8, X12 = c(0.305, 0.44, 0.6, 0.47, 0.49, 0.17, 0.435, 0.435), X36 = c(0.84, 1.16, 1.32, 1.17, 0.78, 0.43, 0.93, 0.9), X60 = c(1.05, 0.9, 0.98, 1.03, 0.77, 0.47, 0.85, 1.11), X84 = c(0.87, 0.95, 1.31, 1.13, 0.62, 0.93, 1.02, 0.79), X108 = c(0.79, 0.92, 1.29, 0.97, 0.74, 0.86, 1.03, 1.41)), .Names = c(Sample, X12, X36, X60, X84, X108), class = data.frame, row.names = c(NA, -8L)) for (i in 2:5) { print(paste((names(dat)[c(i,i+1)]),collapse=-)) print(t.test(x=dat[,i],y=dat[,i+1],alternative=less,paired=T,conf.level=0.95))} _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] replace column headers
Hello everyone,=I have a question as to how to remove the column headers in a data file and then replace those with titles from another file in this case the file labeled ann ( in which the titles are all in one column).I am unsure which function to use.I tried rm () to remove the column headers but they are numbers and the error message said to only use rm for charactors not numbers Below is the code I used, I abbreviated the file path. dat-read.table(file=C:\\Documents and Settings\\txt,header=F,row.names=1) x.df-as.data.frame(dat) rm(dat[,1]) file.show(file=C:\\Documents and Settingstxt) ann-read.table(C:\\Documents and Settings\\..txt=) file.show(file=C:\\Documents and Settings\\...txt) Any help would be appreciated Paul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading csv-data from variables
?textConnection On Tue, Jun 17, 2008 at 5:08 AM, Felix Schönbrodt [EMAIL PROTECTED] wrote: Dear Listmembers, I'm looking for a convenient way to read csv-data which are stored in variables of data frames. I'm working with nested csv-data: one of the columns of the first table stores a long string containing a second csv-coded table. My problem is to parse that second-order csv-table. As the read.csv command requires a link to a file, I couldn't get it to read the data from a variable. I also tried to copy the content of the variable into the clipboard to use the read.csv(pipe(pbpaste))-function, but didn't come to a solution ... Any suggestions? Thanks! Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plot point patterns
Hello! I want to plot a multitype point pattern called new in package spatstat. When I write plot(new) in the graphic window I can see a strech rectangle with a point inside, not the point pattern.If I write plot(new$x,new$y) the point pattern is plot ok.The problem is that I want do the density plots, quadrat count, etc and in these cases I can´t write density(new$x,new$y), I must do it only whith the name of the point pattern. What is the problem? Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot facet spacing, wrapping
I'm running into some problems with the spacing of some faceted ggplot plots. I have a number of time series faceted to be one above another, but the scale labels of the y axes all clobber each other at the bottom/top of each. for example, try: qplot(x, y, data = data.frame(x = 1:10, y = 1:10, size = 1:10), facets = size ~ ., size = size) + scale_x_continuous(breaks = 1:10) + scale_y_continuous(limits = c(0,10)) and notice the 10's and the 0's on the respective Y axes are mushing each other. Is there a way to adjust the spacing of facets in a faceted plot? Likewise, what about wrapping, so that if I had say 20 or 30 facets it would make a grid of facets rather than 30 in a column (or in a row). thanks, mike -- View this message in context: http://www.nabble.com/ggplot-facet-spacing%2C-wrapping-tp17882383p17882383.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reshape or Stack? (To produce output as columns)
Dear all, I have used 'read.table' to create a data frame of 720 columns and 360 rows (and assigned this to 'Jan'). The row and column names are numeric: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 720)). rnames - sprintf(%.2f, seq(from = -89.75, to = 89.75, length = 360)) colnames(Jan) - columnnames rownames(Jan) - rnames A sample of the data looks like this: head(Jan) -179.75 -179.25 -178.75 -178.25 -177.75 -177.25 -176.75 -176.25 -175.75 -89.75 -56.9 -64.256.2 -90.056.9 -29.0 -91.0 34.0 -9.1 -89.2537.919.3 -0.4 -12.3 -11.8 -92.1 9.2 -23.5 -0.2 -88.7547.4 3.1 -47.446.434.2 6.1 -41.344.7 -10.3 -88.25 -20.334.5 -67.3 -99.937.9 -9.317.7 -17.263.4 -87.75 -46.447.412.4 -48.3 9.3 -33.838.110.8 -34.1 -87.25 -48.410.3 -89.3 -33.0 -1.1 -33.181.2-8.3 -47.2 I'm hoping to get the whole dataset into the form of columns, so that, for example, the first row (as shown above) would look like this: Latitude Longitude Value -89.75 -179.75 -56.9 -89.75 -179.25 -64.2 -89.75 -178.75 56.2 -89.75 -178.25 -90.0 -89.75 -177.75 56.9 -89.75 -177.25 -29.0 -89.75 -176.75 -91.0 -89.75 -176.25 34.0 -89.75 -175.75 -9.1 As you can see, this would require the repeated printing of the the row and column names (in this case '-89.75') - so it's not just a case of rearranging the data, but creating 'more' data too. I've tried to achieve this using 'reshape' and 'stack' (their help files and after looking through the mailing archives), but I'm obviously doing something wrong. For reshape, I'm getting errors relating to the commands I enter, and for stack, I can only produce two columns from my data (with the additional 3rd column being a row count). In any case, these two columns refer to the wrong values (it's producing output in the form of: row count number, Longitude, Value). I'd be very grateful if anyone could help me out with the commands I need to enter in order to achieve the results I'm hoping for. Many thanks, Steve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] replace column headers
Paul Adams wrote: Hello everyone,=I have a question as to how to remove the column headers in a data file and then replace those with titles from another file in this case the file labeled ann ( in which the titles are all in one column). Maybe this will help partially. I am not sure on how to read your new column names from a file into a vector but if you can get them into that format this should let you accomplish your goal. Esmail load(Data/simpleTestData2.rda) df Y X1 X2 X3 X4 X5 X6 1 74.9 10 49.8 0.2 99 50 57 2 79.8 11 49.6 0.4 69 91 57 3 84.4 12 48.8 1.2 30 38 58 4 88.8 13 47.6 2.4 77 87 58 colnames(df) [1] Y X1 X2 X3 X4 X5 X6 altnames=c(A, B1, B2, B3, B4, B5, B6) colnames(df)=altnames df A B1 B2 B3 B4 B5 B6 1 74.9 10 49.8 0.2 99 50 57 2 79.8 11 49.6 0.4 69 91 57 3 84.4 12 48.8 1.2 30 38 58 4 88.8 13 47.6 2.4 77 87 58 save(df, file=example.rda) # new file will contain the new column headers. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RE PCA analysis
Hi, You could try the FactoMineR package and the PCA and plot.PCA functions http://factominer.free.fr/ Jérémy Mazet Département Génie des procédés SOREDAB La Tremblaye 78125 La Boissière Ecole Tel : 01 34 94 37 09 Monna Nygård [EMAIL PROTECTED] Envoyé par : [EMAIL PROTECTED] 17/06/2008 11:05 A r-help@r-project.org cc Objet [R] PCA analysis Hi, I have a problem with making PCA plots that are readable. I would like to set different sympols instead of the numbers of my samples or their names, that I get plotted (xlabs). How is this possible? With points, i don´t seem to get the right data plotted onto the PCA plot, as I do not quite understand from where it is taken. I dont know how to plot the correct columns of the prcomp outcome (p). I would really appreciate if someone could help me, I have struggled with this for days now. How can I make a function that gives different symbols for the points, depending on how big the number given to it as xlabs is? Making the plots. read.table(file = S:\\SEDIM\\TRFLP\\B90-700.txt,sep=\t, header=T)-boutbout -bout[-1]p - prcomp(bout) biplot(p, choices = c(2,3), scale = 1, pc.biplot = FALSE, var.axes = F, ylabs = NULL, xlabs=c(119,175,135,330,51,422,67,409,470,70,67,89,135,215,330,409,470,51,80,119,175,222,301,422,280,171,256,243,404,37,157,28,187,70,42,283,261,85,147,204,235,411,514,77,204,87,366,306,351,371,38,534,199,407,42,167,480,195,22,35,80,433,43,109,214,363,292,61,115,178,273,521,72,126,253,288,501,83,113,250,359,498,19,130,389,324,24,58,124,388,319,164,101,153,383,345,219,179,161,375,298,450,555,439,54,54,490,465,411,18,85,503,455,394,179,187,416,447,219,461,164,366,474,167,236,507,319,509,467,507,450,359,507,192,453,101,456,512,517), cex=0.67, main=90-700bp) _ [[elided Hotmail spam]] PLink [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lpSolve replacement to solve transportation problem
r-help, I'm currently using 'lp.transport' from 'lpSolve' to solve a transportation problem. However, I've experienced some performence issues, and have been told that other solvers may perform better. I've looked briefly at 'Rsymphony' and 'rglpk', but I can't seem to figure out how/if they solve transportation problems... So, is there an 'Rsymphony' and/or 'rglpk' equivalent to: library(lpSolve) x - matrix(c(.91,.32,.86,.14,.59,.36,.67,.34,.87,.56,.10,.09),ncol=3,byrow=T) lp.transport(x, min , rep(==,4) , rep(1,4) , rep(=,3) , rep(1,3) )$solution ...and, if so, does in generally outperform 'lp.transport'? And if not, are there any other R packages that solve transportation problems more efficient than 'lpSolve'? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplot with color coding according to value
[EMAIL PROTECTED] wrote: Hello, I want to use R to produce nice meteograms... For this I would need to color-code my barplot according to the value plotted say if value x 30 ... the bar is red ; if x between 20 and 10, the bar is blue etc... any ideas how to proceed ? Hi Maria, Have a look at barp in the plotrix package. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to output glm summary to csv file
Chua Siang Li wrote: Hello there. I am new to R. I want to output the coefficients and their significance value (Pr(|z|) into a csv file. I managed to do it for the coefficients but not their significances. Pls help. Thanks. mylogit- glm(response~price, family=binomial(link=logit), na.action=na.pass) summary(mylogit) write.csv(c(mylogit$coefficients), file=result.csv) write.csv(I(summary(mylogit)), file=result.csv, append=T) #neither does this shows Pr(|z|) Hi Chua, delim.table in the prettyR package might do what you want. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Calling functions
Another newbie question. I've written a function and saved the file as Xtabs.R, in a central place on a network so others will be able ot use the function, My question is how do i call this function? I've tried to chance the working directory, and tried to load it via; library(Xtabs, lib.loc=//filer/common/technical/surveys/R_test) but neither seem to work? the function inside is called CrossTable. Mant thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading csv-data from variables
Thanks for the hint - with a little adaptation (employing as.character) I could solve my problem: c - read.csv2(textConnection(as.character(dat[7,8]))) Best wishes, Felix Am 17.06.2008 um 12:04 schrieb jim holtman: ?textConnection On Tue, Jun 17, 2008 at 5:08 AM, Felix Schönbrodt [EMAIL PROTECTED] wrote: Dear Listmembers, I'm looking for a convenient way to read csv-data which are stored in variables of data frames. I'm working with nested csv-data: one of the columns of the first table stores a long string containing a second csv-coded table. My problem is to parse that second-order csv-table. As the read.csv command requires a link to a file, I couldn't get it to read the data from a variable. I also tried to copy the content of the variable into the clipboard to use the read.csv(pipe(pbpaste))-function, but didn't come to a solution ... Any suggestions? Thanks! Felix __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Measuring dispersion
S. Nunes wrote: Hi, I'm looking for a function to measure the dispersion of a set of values ranging from 0 to 1. This function should be 0 if all the values are evenly spaced within the interval and it should be 0 if values are clustered. The more clustered the values are, the higher should the function be. An example: [0; 0.2; 0.4; 0.6; 0.8; 1] - function should be ~ 0 [0; 0.1; 0.1; 0.15; 1] - function should be 1 This data comes from time-dependent observations recorded between a start time (0) and an end time (1). I want to find out which series are more clustered, i.e. less evenly distributed. I'm going to test Kurtosis for this but it doesn't seem to be the best tool for the job. As I understand, Kurtosis evaluates the strength of a single central peak. My data can have multiple peaks (clusters). Hi Sergio, It sounds like what you want is the negative of the entropy. I'm not sure if there is a readymade function to calculate this, but someone else on the list might know. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calling functions
Hi, Can't you just do source(Xtabs.R)? That will load in the definition. Alternatively, instead of saving the R program, save the workspace on your network (e.g. Xtabs.RData), which will contain the function definition, and arrange a link so that R always starts with that workspace loaded? Toby Marthews Le Mar 17 juin 2008 13:32, Michael Pearmain a écrit : Another newbie question. I've written a function and saved the file as Xtabs.R, in a central place on a network so others will be able ot use the function, My question is how do i call this function? I've tried to chance the working directory, and tried to load it via; library(Xtabs, lib.loc=//filer/common/technical/surveys/R_test) but neither seem to work? the function inside is called CrossTable. Mant thanks in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reshape or Stack? (To produce output as columns)
On 6/17/2008 6:59 AM, Steve Murray wrote: Dear all, I have used 'read.table' to create a data frame of 720 columns and 360 rows (and assigned this to 'Jan'). The row and column names are numeric: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 720)). rnames - sprintf(%.2f, seq(from = -89.75, to = 89.75, length = 360)) colnames(Jan) - columnnames rownames(Jan) - rnames A sample of the data looks like this: head(Jan) -179.75 -179.25 -178.75 -178.25 -177.75 -177.25 -176.75 -176.25 -175.75 -89.75 -56.9 -64.256.2 -90.056.9 -29.0 -91.0 34.0 -9.1 -89.2537.919.3 -0.4 -12.3 -11.8 -92.1 9.2 -23.5 -0.2 -88.7547.4 3.1 -47.446.434.2 6.1 -41.344.7 -10.3 -88.25 -20.334.5 -67.3 -99.937.9 -9.317.7 -17.263.4 -87.75 -46.447.412.4 -48.3 9.3 -33.838.110.8 -34.1 -87.25 -48.410.3 -89.3 -33.0 -1.1 -33.181.2-8.3 -47.2 I'm hoping to get the whole dataset into the form of columns, so that, for example, the first row (as shown above) would look like this: Latitude Longitude Value -89.75 -179.75 -56.9 -89.75 -179.25 -64.2 -89.75 -178.75 56.2 -89.75 -178.25 -90.0 -89.75 -177.75 56.9 -89.75 -177.25 -29.0 -89.75 -176.75 -91.0 -89.75 -176.25 34.0 -89.75 -175.75 -9.1 As you can see, this would require the repeated printing of the the row and column names (in this case '-89.75') - so it's not just a case of rearranging the data, but creating 'more' data too. I've tried to achieve this using 'reshape' and 'stack' (their help files and after looking through the mailing archives), but I'm obviously doing something wrong. For reshape, I'm getting errors relating to the commands I enter, and for stack, I can only produce two columns from my data (with the additional 3rd column being a row count). In any case, these two columns refer to the wrong values (it's producing output in the form of: row count number, Longitude, Value). I'd be very grateful if anyone could help me out with the commands I need to enter in order to achieve the results I'm hoping for. Here is an approach with reshape() on a much smaller example: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 5)) rnames - sprintf(%.2f, seq(from = - 89.75, to = 89.75, length = 3)) Jan - as.data.frame(matrix(runif(3*5), ncol=5)) colnames(Jan) - columnnames rownames(Jan) - rnames Jan$Latitude - rownames(Jan) Jan.long - reshape(Jan, idvar=Latitude, direction=long, varying = list(columnnames), v.names=Value, timevar=Longitude, times=columnnames) Jan.long[] - sapply(Jan.long, as.numeric) Jan -179.75-89.88 0.00 89.88179.75 Latitude -89.75 0.9264005 0.5442698 0.3894998 0.8961858 0.1340782 -89.75 0.00 0.4719097 0.1961747 0.3108708 0.1663938 0.1316141 0.00 89.75 0.1426153 0.8985805 0.1600287 0.9004246 0.105287589.75 Jan.long Latitude Longitude Value -89.75.-179.75 -89.75 -179.75 0.9264005 0.00.-179.75 0.00 -179.75 0.4719097 89.75.-179.75 89.75 -179.75 0.1426153 -89.75.-89.88-89.75-89.88 0.5442698 0.00.-89.880.00-89.88 0.1961747 89.75.-89.88 89.75-89.88 0.8985805 -89.75.0.00 -89.75 0.00 0.3894998 0.00.0.00 0.00 0.00 0.3108708 89.75.0.0089.75 0.00 0.1600287 -89.75.89.88 -89.75 89.88 0.8961858 0.00.89.88 0.00 89.88 0.1663938 89.75.89.88 89.75 89.88 0.9004246 -89.75.179.75-89.75179.75 0.1340782 0.00.179.750.00179.75 0.1316141 89.75.179.75 89.75179.75 0.1052875 You also might use expand.grid() as follows: Jan.long2 - cbind(expand.grid(rnames, columnnames), unlist(Jan[,1:5])) Jan.long2[] - sapply(Jan.long2, function(x){as.numeric(as.character(x))}) names(Jan.long2) - c(Latitude, Longitude, Value) Jan.long2 Latitude Longitude Value -179.751 -89.75 -179.75 0.9264005 -179.752 0.00 -179.75 0.4719097 -179.75389.75 -179.75 0.1426153 -89.881-89.75-89.88 0.5442698 -89.882 0.00-89.88 0.1961747 -89.883 89.75-89.88 0.8985805 0.001 -89.75 0.00 0.3894998 0.0020.00 0.00 0.3108708 0.003 89.75 0.00 0.1600287 89.881 -89.75 89.88 0.8961858 89.882 0.00 89.88 0.1663938 89.883 89.75 89.88 0.9004246 179.751-89.75179.75 0.1340782 179.752 0.00179.75 0.1316141 179.753 89.75179.75 0.1052875 Many thanks, Steve __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,
[R] longitudinal data analysis
hie i am want to carryout a longitudinal analysis similar to the proc catmod in SAS using The Weighted least squares method.my data is in the following format. Material nbsp; time1nbsp; time2nbsp;nbsp; time3 1nbsp;nbsp; nbsp;nbsp; nbsp;nbsp; 1 1 1 1 1 2 2 2 2 2 3 3 3 . . . . 13 what i want to do is compare if there is a significant difference between the materials. and also if there is any sig difference between the times. any help will be greatly apreciated thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reshape or Stack? (To produce output as columns)
On Jun 17, 2008, at 8:06 AM, Chuck Cleland wrote: On 6/17/2008 6:59 AM, Steve Murray wrote: Dear all, I have used 'read.table' to create a data frame of 720 columns and 360 rows (and assigned this to 'Jan'). The row and column names are numeric: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 720)). rnames - sprintf(%.2f, seq(from = -89.75, to = 89.75, length = 360)) colnames(Jan) - columnnames rownames(Jan) - rnames A sample of the data looks like this: head(Jan) -179.75 -179.25 -178.75 -178.25 -177.75 -177.25 -176.75 -176.25 -175.75 -89.75 -56.9 -64.256.2 -90.056.9 -29.0 -91.0 34.0 -9.1 -89.2537.919.3 -0.4 -12.3 -11.8 -92.1 9.2 -23.5 -0.2 -88.7547.4 3.1 -47.446.434.2 6.1 -41.344.7 -10.3 -88.25 -20.334.5 -67.3 -99.937.9 -9.317.7 -17.263.4 -87.75 -46.447.412.4 -48.3 9.3 -33.838.1 10.8 -34.1 -87.25 -48.410.3 -89.3 -33.0 -1.1 -33.181.2 -8.3 -47.2 I'm hoping to get the whole dataset into the form of columns, so that, for example, the first row (as shown above) would look like this: Latitude Longitude Value -89.75 -179.75 -56.9 -89.75 -179.25 -64.2 -89.75 -178.75 56.2 -89.75 -178.25 -90.0 -89.75 -177.75 56.9 -89.75 -177.25 -29.0 -89.75 -176.75 -91.0 -89.75 -176.25 34.0 -89.75 -175.75 -9.1 As you can see, this would require the repeated printing of the the row and column names (in this case '-89.75') - so it's not just a case of rearranging the data, but creating 'more' data too. I've tried to achieve this using 'reshape' and 'stack' (their help files and after looking through the mailing archives), but I'm obviously doing something wrong. For reshape, I'm getting errors relating to the commands I enter, and for stack, I can only produce two columns from my data (with the additional 3rd column being a row count). In any case, these two columns refer to the wrong values (it's producing output in the form of: row count number, Longitude, Value). I'd be very grateful if anyone could help me out with the commands I need to enter in order to achieve the results I'm hoping for. Here is an approach with reshape() on a much smaller example: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 5)) rnames - sprintf(%.2f, seq(from = - 89.75, to = 89.75, length = 3)) Jan - as.data.frame(matrix(runif(3*5), ncol=5)) colnames(Jan) - columnnames rownames(Jan) - rnames Jan$Latitude - rownames(Jan) Jan.long - reshape(Jan, idvar=Latitude, direction=long, varying = list(columnnames), v.names=Value, timevar=Longitude, times=columnnames) Jan.long[] - sapply(Jan.long, as.numeric) Here's another approach, using Chuck's example. I have two methods, one produces a data frame, the other produces a matrix. It's up to you. In the data frame example the first two columns are actually factors, in the matrix they are numeric vectors. The other key difference is that I start from a matrix, and I simply use the fact that a matrix is just a vector with a dim attribute (and I use as.numeric to drop the dim argument). Jan - matrix(runif(3*5), ncol=5) Jan.long - data.frame(Latitude=rep(rownames(Jan), ncol(Jan)), Longitute=rep(colnames(Jan), each=nrow(Jan)), Value=as.numeric(Jan)) Jan.long - cbind(Latitude=rep(as.numeric(rownames(Jan)), ncol(Jan)), Longitute=rep(as.numeric(colnames(Jan)), each=nrow(Jan)), Value=as.numeric(Jan)) Haris Skiadas Department of Mathematics and Computer Science Hanover College __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fitdistr errors
Hello, I have got the following error message (translated from French to English) using fitdistr : Error in fitdistr(nira, weibull) : optimization failed Furthermore : There are 50 warnings or more (use warnings() to see the first 50) I used fitdistr in a loop and I think the loop stopped after 50 warnings. At that point of the loop, more than 2000 fitdistr had been done. So it seems that sometimes the optimization fails. Is it because of a bad starting point ? The mistakes were the following : In dweibull(x, shape, scale, log) : production of NaN. Thank you very much P.S. : should I use better survreg ? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] invalid arguments RUNIF
Hi all I would be grateful you can help me with my problem. I try to run an optimization code . in one line I have runif in order to sample the PDF. I get this error while i run it. Error in runif(1, f$d[[n.of.u.vars + n.of.o.vars + j]][[2]][1], f$d[[n.of.u.vars + : invalid arguments Here is a part of that code: # initialize random numeber generator if (seed0) set.seed(seed) # set parameters e.abs - e e.rel - e max.value - f$opt eval - 0 last.impr - max.eval; nl - matrix(NA,k,k-1) iteration - 0 # separate unordered and ordered from continuous variables range.u - vector() range.o - vector() n.of.x.vars - 0 n.of.o.vars - 0 n.of.u.vars - 0 for (i in f$d) { if (i[[1]]==u) { range.u - c(range.u, length(i[[2]])) n.of.u.vars - n.of.u.vars + 1 } if (i[[1]]==o) { range.o - c(range.o, length(i[[2]])) n.of.o.vars - n.of.o.vars + 1 } if (i[[1]]==x) { n.of.x.vars - n.of.x.vars + 1 } } # initialize variables max.u - rep(NA,n.of.u.vars) max.o - rep(NA,n.of.o.vars) max.X - rep(NA,n.of.x.vars) max.y - -Inf p.X - vector() p.u - vector() p.o - vector() p - data.frame(v=numeric(),sd=numeric(),gr=numeric()); # randomly choose the starting population # (but based on the data given in the function definition) for (i in 1:k) { if (n.of.u.vars0) { U - vector() for (j in 1:n.of.u.vars) { U - c(U, sample(range.u[j],1)) } U - t(U) } else U - NULL if (n.of.o.vars0) { O - vector() for (j in 1:n.of.o.vars) { O - c(O, sample(range.o[j],1)) } O - t(O) } X - vector() for (j in 1:n.of.x.vars) { X - c(X, runif(1,f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][1], f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][2])) } X - t(X) Many Thanks Yasin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] invalid arguments RUNIF
Just a general comment, I have not looked at your code. You may want to look at the Debugging R portion of the Introduction to R manual on CRAN. There is also a graphical debugger from the 'debug' package on CRAN. Either one of these will become immensely helpful in situations like this. Yasin Hajizadeh wrote: Hi all I would be grateful you can help me with my problem. I try to run an optimization code . in one line I have runif in order to sample the PDF. I get this error while i run it. Error in runif(1, f$d[[n.of.u.vars + n.of.o.vars + j]][[2]][1], f$d[[n.of.u.vars + : invalid arguments Here is a part of that code: # initialize random numeber generator if (seed0) set.seed(seed) # set parameters e.abs - e e.rel - e max.value - f$opt eval - 0 last.impr - max.eval; nl - matrix(NA,k,k-1) iteration - 0 # separate unordered and ordered from continuous variables range.u - vector() range.o - vector() n.of.x.vars - 0 n.of.o.vars - 0 n.of.u.vars - 0 for (i in f$d) { if (i[[1]]==u) { range.u - c(range.u, length(i[[2]])) n.of.u.vars - n.of.u.vars + 1 } if (i[[1]]==o) { range.o - c(range.o, length(i[[2]])) n.of.o.vars - n.of.o.vars + 1 } if (i[[1]]==x) { n.of.x.vars - n.of.x.vars + 1 } } # initialize variables max.u - rep(NA,n.of.u.vars) max.o - rep(NA,n.of.o.vars) max.X - rep(NA,n.of.x.vars) max.y - -Inf p.X - vector() p.u - vector() p.o - vector() p - data.frame(v=numeric(),sd=numeric(),gr=numeric()); # randomly choose the starting population # (but based on the data given in the function definition) for (i in 1:k) { if (n.of.u.vars0) { U - vector() for (j in 1:n.of.u.vars) { U - c(U, sample(range.u[j],1)) } U - t(U) } else U - NULL if (n.of.o.vars0) { O - vector() for (j in 1:n.of.o.vars) { O - c(O, sample(range.o[j],1)) } O - t(O) } X - vector() for (j in 1:n.of.x.vars) { X - c(X, runif(1,f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][1], f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][2])) } X - t(X) Many Thanks Yasin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Replacing values in a zoo object
Dear R Users, I am trying to replace the value of one row in a single column zoo object. I try the following, but it does not seem to work. Could someone explain to me how I can either replace the value for this row or just delete the row entirely ? Many thanks in advance, Tolga is.zoo(curve) [1] TRUE attributes(curve) $index [1] 08/22/07 08/23/07 08/24/07 08/27/07 08/28/07 08/29/07 08/30/07 08/31/07 09/03/07 09/04/07 [11] 09/05/07 09/06/07 09/07/07 09/10/07 09/11/07 09/12/07 09/13/07 09/14/07 09/17/07 09/18/07 [21] 09/19/07 09/20/07 09/21/07 09/24/07 09/25/07 09/26/07 09/27/07 09/28/07 10/01/07 10/02/07 [31] 10/03/07 10/04/07 10/05/07 10/08/07 10/09/07 10/10/07 10/11/07 10/12/07 10/15/07 10/16/07 [41] 10/17/07 10/18/07 10/19/07 10/22/07 10/23/07 10/24/07 10/25/07 10/26/07 10/29/07 10/30/07 [51] 10/31/07 11/01/07 11/02/07 11/05/07 11/06/07 11/07/07 11/08/07 11/09/07 11/12/07 11/13/07 [61] 11/14/07 11/15/07 11/16/07 11/19/07 11/20/07 11/21/07 11/22/07 11/23/07 11/26/07 11/27/07 [71] 11/28/07 11/29/07 11/30/07 12/03/07 12/04/07 12/05/07 12/06/07 12/07/07 12/10/07 12/11/07 [81] 12/12/07 12/13/07 12/14/07 12/17/07 12/18/07 12/19/07 12/20/07 12/21/07 12/24/07 12/25/07 [91] 12/26/07 12/27/07 12/28/07 12/31/07 01/01/08 01/02/08 01/03/08 01/04/08 01/07/08 01/08/08 [101] 01/09/08 01/10/08 01/11/08 01/14/08 01/15/08 01/16/08 01/17/08 01/18/08 01/21/08 01/22/08 [111] 01/23/08 01/24/08 01/25/08 01/28/08 01/29/08 01/30/08 01/31/08 02/01/08 02/04/08 02/05/08 [121] 02/06/08 02/07/08 02/08/08 02/11/08 02/12/08 02/13/08 02/14/08 02/15/08 02/18/08 02/19/08 [131] 02/20/08 02/21/08 02/22/08 02/25/08 02/26/08 02/27/08 02/28/08 02/29/08 03/03/08 03/04/08 [141] 03/05/08 03/06/08 03/07/08 03/10/08 03/11/08 03/12/08 03/13/08 03/14/08 03/17/08 03/18/08 [151] 03/19/08 03/20/08 03/21/08 03/24/08 03/25/08 03/26/08 03/27/08 03/28/08 03/31/08 04/01/08 [161] 04/02/08 04/03/08 04/04/08 04/07/08 04/08/08 04/09/08 04/10/08 04/11/08 04/14/08 04/15/08 [171] 04/16/08 04/17/08 04/18/08 04/21/08 04/22/08 04/23/08 04/24/08 04/25/08 04/28/08 04/29/08 [181] 04/30/08 05/01/08 05/02/08 05/05/08 05/06/08 05/07/08 05/08/08 05/09/08 05/12/08 05/13/08 [191] 05/14/08 05/15/08 05/16/08 05/19/08 05/20/08 05/21/08 05/22/08 05/23/08 05/26/08 05/27/08 [201] 05/28/08 05/29/08 05/30/08 06/02/08 06/03/08 06/04/08 06/05/08 06/06/08 06/09/08 06/10/08 [211] 06/11/08 06/12/08 06/13/08 06/16/08 06/17/08 $class [1] zoo curve[dates(03/19/2008)] 03/19/08 38.032 curve[dates(03/19/2008)]-0 # trying to assign 0 to this curve[dates(03/19/2008)] 03/19/08 38.032 # -- still 38.032 ! Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calling functions
It's not in a library, it is essentially just a little stored program or script Just use source() to load it and it will automatically run. Do a ls() to confirm it's there :) --- On Tue, 6/17/08, Michael Pearmain [EMAIL PROTECTED] wrote: From: Michael Pearmain [EMAIL PROTECTED] Subject: [R] Calling functions To: r-help@r-project.org Received: Tuesday, June 17, 2008, 7:32 AM Another newbie question. I've written a function and saved the file as Xtabs.R, in a central place on a network so others will be able ot use the function, My question is how do i call this function? I've tried to chance the working directory, and tried to load it via; library(Xtabs, lib.loc=//filer/common/technical/surveys/R_test) but neither seem to work? the function inside is called CrossTable. Mant thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Hi, I am trying to train svm with some training data of about 4000 rows and 4000 columns. While running svm function I am ending up with the following error. trainfile - read.csv('train_16435.csv',head=TRUE,na.strings = NULL) datatrain - subset(trainfile,select=c(-Class)) model - svm(datatrain, kernel=radial) Error in FUN(newX[, i], ...) : 'x' is empty I tried substituting NULL strings in the data with some numeric values but still I am ending up with error as: model - svm(datatrain, kernel=radial) Error in FUN(newX[, i], ...) : missing observations in cov/cor In addition: Warning message: In FUN(newX[, i], ...) : NAs introduced by coercion Could you please help me in finding out where I am going wrong. Thanking you in advance. Meet people who discuss and share your passions. Go to http://in.promos.yahoo.com/groups/bestofyahoo/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] invalid arguments RUNIF
Erik Iverson wrote: Just a general comment, I have not looked at your code. You may want to look at the Debugging R portion of the Introduction to R manual on CRAN. There is also a graphical debugger from the 'debug' package on CRAN. Either one of these will become immensely helpful in situations like this. Also, in this particular case, the offending call is in your own code, so how about print()ing the arguments to runif() before running it? Yasin Hajizadeh wrote: Hi all I would be grateful you can help me with my problem. I try to run an optimization code . in one line I have runif in order to sample the PDF. I get this error while i run it. Error in runif(1, f$d[[n.of.u.vars + n.of.o.vars + j]][[2]][1], f$d[[n.of.u.vars + : invalid arguments I.e, insert print(f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][1:2]) at the beginning of the for loop below for (j in 1:n.of.x.vars) { X - c(X, runif(1,f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][1], f$d[[n.of.u.vars+n.of.o.vars+j]][[2]][2])) } X - t(X) (You likely don't really want to grow X on every call to runif(), but that is a different matter) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Trouble with FUN(newX[, i], ...)
Hi, I am trying to train svm with some training data of about 4000 rows and 4000 columns. While running svm function I am ending up with the following error. trainfile - read.csv('0_train_0016435.csv',head=TRUE,na.strings = NULL) datatrain - subset(trainfile,select=c(-Class)) model - svm(datatrain, kernel=radial) Error in FUN(newX[, i], ...) : 'x' is empty I tried substituting NULL strings in the data with some numeric values but still I am ending up with error as: model - svm(datatrain, kernel=radial) Error in FUN(newX[, i], ...) : missing observations in cov/cor In addition: Warning message: In FUN(newX[, i], ...) : NAs introduced by coercion Could you please help me in finding out where I am going wrong. Thanking you in advance. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Replacing values in a zoo object
See ?window.zoo library(chron) z - zoo(1:3, chron(11:13)) z 01/12/70 01/13/70 01/14/70 123 window(z, chron(01/13/70)) - 20 z 01/12/70 01/13/70 01/14/70 1 203 z[3] - 30 z 01/12/70 01/13/70 01/14/70 1 20 30 On Tue, Jun 17, 2008 at 9:02 AM, [EMAIL PROTECTED] wrote: Dear R Users, I am trying to replace the value of one row in a single column zoo object. I try the following, but it does not seem to work. Could someone explain to me how I can either replace the value for this row or just delete the row entirely ? Many thanks in advance, Tolga is.zoo(curve) [1] TRUE attributes(curve) $index [1] 08/22/07 08/23/07 08/24/07 08/27/07 08/28/07 08/29/07 08/30/07 08/31/07 09/03/07 09/04/07 [11] 09/05/07 09/06/07 09/07/07 09/10/07 09/11/07 09/12/07 09/13/07 09/14/07 09/17/07 09/18/07 [21] 09/19/07 09/20/07 09/21/07 09/24/07 09/25/07 09/26/07 09/27/07 09/28/07 10/01/07 10/02/07 [31] 10/03/07 10/04/07 10/05/07 10/08/07 10/09/07 10/10/07 10/11/07 10/12/07 10/15/07 10/16/07 [41] 10/17/07 10/18/07 10/19/07 10/22/07 10/23/07 10/24/07 10/25/07 10/26/07 10/29/07 10/30/07 [51] 10/31/07 11/01/07 11/02/07 11/05/07 11/06/07 11/07/07 11/08/07 11/09/07 11/12/07 11/13/07 [61] 11/14/07 11/15/07 11/16/07 11/19/07 11/20/07 11/21/07 11/22/07 11/23/07 11/26/07 11/27/07 [71] 11/28/07 11/29/07 11/30/07 12/03/07 12/04/07 12/05/07 12/06/07 12/07/07 12/10/07 12/11/07 [81] 12/12/07 12/13/07 12/14/07 12/17/07 12/18/07 12/19/07 12/20/07 12/21/07 12/24/07 12/25/07 [91] 12/26/07 12/27/07 12/28/07 12/31/07 01/01/08 01/02/08 01/03/08 01/04/08 01/07/08 01/08/08 [101] 01/09/08 01/10/08 01/11/08 01/14/08 01/15/08 01/16/08 01/17/08 01/18/08 01/21/08 01/22/08 [111] 01/23/08 01/24/08 01/25/08 01/28/08 01/29/08 01/30/08 01/31/08 02/01/08 02/04/08 02/05/08 [121] 02/06/08 02/07/08 02/08/08 02/11/08 02/12/08 02/13/08 02/14/08 02/15/08 02/18/08 02/19/08 [131] 02/20/08 02/21/08 02/22/08 02/25/08 02/26/08 02/27/08 02/28/08 02/29/08 03/03/08 03/04/08 [141] 03/05/08 03/06/08 03/07/08 03/10/08 03/11/08 03/12/08 03/13/08 03/14/08 03/17/08 03/18/08 [151] 03/19/08 03/20/08 03/21/08 03/24/08 03/25/08 03/26/08 03/27/08 03/28/08 03/31/08 04/01/08 [161] 04/02/08 04/03/08 04/04/08 04/07/08 04/08/08 04/09/08 04/10/08 04/11/08 04/14/08 04/15/08 [171] 04/16/08 04/17/08 04/18/08 04/21/08 04/22/08 04/23/08 04/24/08 04/25/08 04/28/08 04/29/08 [181] 04/30/08 05/01/08 05/02/08 05/05/08 05/06/08 05/07/08 05/08/08 05/09/08 05/12/08 05/13/08 [191] 05/14/08 05/15/08 05/16/08 05/19/08 05/20/08 05/21/08 05/22/08 05/23/08 05/26/08 05/27/08 [201] 05/28/08 05/29/08 05/30/08 06/02/08 06/03/08 06/04/08 06/05/08 06/06/08 06/09/08 06/10/08 [211] 06/11/08 06/12/08 06/13/08 06/16/08 06/17/08 $class [1] zoo curve[dates(03/19/2008)] 03/19/08 38.032 curve[dates(03/19/2008)]-0 # trying to assign 0 to this curve[dates(03/19/2008)] 03/19/08 38.032 # -- still 38.032 ! Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] heatmap.2 dendogram algorithm
RobertsLRRI wrote: Hello does anyone know what algorithm is used to produce the hierarchical clustering in the gplots package using the function heatmap.2? I think it may be the complete linkage clustering algorithm, but I can't find a source that seems reliable. Did you look at the help page? I get Usage: heatmap.2 (x, # dendrogram control Rowv = TRUE, Colv=if(symm)Rowv else TRUE, distfun = dist, hclustfun = hclust, Then ?hclust gives me Usage: hclust(d, method = complete, members=NULL) Thank you and sorry if I posted this in the wrong place. If I have, please let me know and I will move it to the appropriate list. -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] interp() function output not continue
Dear List, I'm using interp() to prepare 3d data for plotting with the contour() function. If have x,y and z data. All are arrays. X and Y are sampled in an orderly fashion on a grid (a circular sub-area of a grid - see plot). I'm trying to use interp() to get x and y arrays and a z matrix that can be fed to contour(). This is the command: interp(x,y,z,extrap=F,linear=FALSE,duplicate='mean') In the result there are, consistently, some discontinuities. This happens always in the 'middle' of the data. I've uploaded a plot that might clarify the problem: http://examples.attic.sent.com/example.png As you can see the middle of the plot is discontinue. When I look at the data, there is no particular reason why this should happen. The problem seems to be a single row in the z matrix returned by interp() right in the middle of the matrix (line 30 of 60). Replacing this line with the mean of row 29 and 31 seems to solve the problem. This results in this plot: http://examples.attic.sent.com/example_fix.png. This works, but it is not nice of course. Is this something that looks familiar to someone? Can I replace the interp() function with something else? Could this be due to the particular way my data is sampled? Regards, Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] interp() function output not continue
On 6/17/2008 9:52 AM, Dieter Vanderelst wrote: Dear List, I'm using interp() to prepare 3d data for plotting with the contour() function. If have x,y and z data. All are arrays. X and Y are sampled in an orderly fashion on a grid (a circular sub-area of a grid - see plot). I'm trying to use interp() to get x and y arrays and a z matrix that can be fed to contour(). This is the command: interp(x,y,z,extrap=F,linear=FALSE,duplicate='mean') In the result there are, consistently, some discontinuities. This happens always in the 'middle' of the data. I've uploaded a plot that might clarify the problem: http://examples.attic.sent.com/example.png As you can see the middle of the plot is discontinue. When I look at the data, there is no particular reason why this should happen. The problem seems to be a single row in the z matrix returned by interp() right in the middle of the matrix (line 30 of 60). Replacing this line with the mean of row 29 and 31 seems to solve the problem. This results in this plot: http://examples.attic.sent.com/example_fix.png. This works, but it is not nice of course. Is this something that looks familiar to someone? Can I replace the interp() function with something else? Could this be due to the particular way my data is sampled? I don't know what's going wrong in inter(), but if your original x and y values are already on a grid, you might be better off just massaging the data directly to the form that contour wants. That is, something like this: xvals - sort(unique(x)) yvals - sort(unique(y)) xindex - match(x, xvals) yindex - match(y, yvals) zarray - matrix(NA, length(xvals), length(yvals)) zarray[cbind(xindex, yindex)] - z contour(xvals, yvals, zarray) (I haven't tested this code; you didn't give any data to test it on.) Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Replacing values in a zoo object
Cool many thanks, Tolga Gabor Grothendieck [EMAIL PROTECTED] 17/06/2008 14:30 To [EMAIL PROTECTED] cc r-help@r-project.org Subject Re: [R] Replacing values in a zoo object See ?window.zoo library(chron) z - zoo(1:3, chron(11:13)) z 01/12/70 01/13/70 01/14/70 123 window(z, chron(01/13/70)) - 20 z 01/12/70 01/13/70 01/14/70 1 203 z[3] - 30 z 01/12/70 01/13/70 01/14/70 1 20 30 On Tue, Jun 17, 2008 at 9:02 AM, [EMAIL PROTECTED] wrote: Dear R Users, I am trying to replace the value of one row in a single column zoo object. I try the following, but it does not seem to work. Could someone explain to me how I can either replace the value for this row or just delete the row entirely ? Many thanks in advance, Tolga is.zoo(curve) [1] TRUE attributes(curve) $index [1] 08/22/07 08/23/07 08/24/07 08/27/07 08/28/07 08/29/07 08/30/07 08/31/07 09/03/07 09/04/07 [11] 09/05/07 09/06/07 09/07/07 09/10/07 09/11/07 09/12/07 09/13/07 09/14/07 09/17/07 09/18/07 [21] 09/19/07 09/20/07 09/21/07 09/24/07 09/25/07 09/26/07 09/27/07 09/28/07 10/01/07 10/02/07 [31] 10/03/07 10/04/07 10/05/07 10/08/07 10/09/07 10/10/07 10/11/07 10/12/07 10/15/07 10/16/07 [41] 10/17/07 10/18/07 10/19/07 10/22/07 10/23/07 10/24/07 10/25/07 10/26/07 10/29/07 10/30/07 [51] 10/31/07 11/01/07 11/02/07 11/05/07 11/06/07 11/07/07 11/08/07 11/09/07 11/12/07 11/13/07 [61] 11/14/07 11/15/07 11/16/07 11/19/07 11/20/07 11/21/07 11/22/07 11/23/07 11/26/07 11/27/07 [71] 11/28/07 11/29/07 11/30/07 12/03/07 12/04/07 12/05/07 12/06/07 12/07/07 12/10/07 12/11/07 [81] 12/12/07 12/13/07 12/14/07 12/17/07 12/18/07 12/19/07 12/20/07 12/21/07 12/24/07 12/25/07 [91] 12/26/07 12/27/07 12/28/07 12/31/07 01/01/08 01/02/08 01/03/08 01/04/08 01/07/08 01/08/08 [101] 01/09/08 01/10/08 01/11/08 01/14/08 01/15/08 01/16/08 01/17/08 01/18/08 01/21/08 01/22/08 [111] 01/23/08 01/24/08 01/25/08 01/28/08 01/29/08 01/30/08 01/31/08 02/01/08 02/04/08 02/05/08 [121] 02/06/08 02/07/08 02/08/08 02/11/08 02/12/08 02/13/08 02/14/08 02/15/08 02/18/08 02/19/08 [131] 02/20/08 02/21/08 02/22/08 02/25/08 02/26/08 02/27/08 02/28/08 02/29/08 03/03/08 03/04/08 [141] 03/05/08 03/06/08 03/07/08 03/10/08 03/11/08 03/12/08 03/13/08 03/14/08 03/17/08 03/18/08 [151] 03/19/08 03/20/08 03/21/08 03/24/08 03/25/08 03/26/08 03/27/08 03/28/08 03/31/08 04/01/08 [161] 04/02/08 04/03/08 04/04/08 04/07/08 04/08/08 04/09/08 04/10/08 04/11/08 04/14/08 04/15/08 [171] 04/16/08 04/17/08 04/18/08 04/21/08 04/22/08 04/23/08 04/24/08 04/25/08 04/28/08 04/29/08 [181] 04/30/08 05/01/08 05/02/08 05/05/08 05/06/08 05/07/08 05/08/08 05/09/08 05/12/08 05/13/08 [191] 05/14/08 05/15/08 05/16/08 05/19/08 05/20/08 05/21/08 05/22/08 05/23/08 05/26/08 05/27/08 [201] 05/28/08 05/29/08 05/30/08 06/02/08 06/03/08 06/04/08 06/05/08 06/06/08 06/09/08 06/10/08 [211] 06/11/08 06/12/08 06/13/08 06/16/08 06/17/08 $class [1] zoo curve[dates(03/19/2008)] 03/19/08 38.032 curve[dates(03/19/2008)]-0 # trying to assign 0 to this curve[dates(03/19/2008)] 03/19/08 38.032 # -- still 38.032 ! Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. [[alternative HTML
Re: [R] ggplot facet spacing, wrapping
On Tue, Jun 17, 2008 at 5:54 AM, mfrumin [EMAIL PROTECTED] wrote: I'm running into some problems with the spacing of some faceted ggplot plots. I have a number of time series faceted to be one above another, but the scale labels of the y axes all clobber each other at the bottom/top of each. for example, try: qplot(x, y, data = data.frame(x = 1:10, y = 1:10, size = 1:10), facets = size ~ ., size = size) + scale_x_continuous(breaks = 1:10) + scale_y_continuous(limits = c(0,10)) and notice the 10's and the 0's on the respective Y axes are mushing each other. Is there a way to adjust the spacing of facets in a faceted plot? Not at the moment, but it's on my to do list to be completed this summer. Likewise, what about wrapping, so that if I had say 20 or 30 facets it would make a grid of facets rather than 30 in a column (or in a row). Again, on the to do list. You can kind of do it yourself though, if you really really want it. The basic idea is as follows: df - data.frame(x = 1:10, y = 1:10, size = 1:10) df - transform(df, xgrid = x %% 4, ygrid = y %/% 4 ) qplot(x, y, data=df, facets = xgrid ~ ygrid) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reshape or Stack? (To produce output as columns)
On Tue, Jun 17, 2008 at 5:59 AM, Steve Murray [EMAIL PROTECTED] wrote: Dear all, I have used 'read.table' to create a data frame of 720 columns and 360 rows (and assigned this to 'Jan'). The row and column names are numeric: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 720)). rnames - sprintf(%.2f, seq(from = -89.75, to = 89.75, length = 360)) colnames(Jan) - columnnames rownames(Jan) - rnames A sample of the data looks like this: head(Jan) -179.75 -179.25 -178.75 -178.25 -177.75 -177.25 -176.75 -176.25 -175.75 -89.75 -56.9 -64.256.2 -90.056.9 -29.0 -91.0 34.0 -9.1 -89.2537.919.3 -0.4 -12.3 -11.8 -92.1 9.2 -23.5 -0.2 -88.7547.4 3.1 -47.446.434.2 6.1 -41.344.7 -10.3 -88.25 -20.334.5 -67.3 -99.937.9 -9.317.7 -17.2 63.4 -87.75 -46.447.412.4 -48.3 9.3 -33.838.110.8 -34.1 -87.25 -48.410.3 -89.3 -33.0 -1.1 -33.181.2-8.3 -47.2 I'm hoping to get the whole dataset into the form of columns, so that, for example, the first row (as shown above) would look like this: Latitude Longitude Value -89.75 -179.75 -56.9 -89.75 -179.25 -64.2 -89.75 -178.75 56.2 -89.75 -178.25 -90.0 -89.75 -177.75 56.9 -89.75 -177.25 -29.0 -89.75 -176.75 -91.0 -89.75 -176.25 34.0 -89.75 -175.75 -9.1 As you can see, this would require the repeated printing of the the row and column names (in this case '-89.75') - so it's not just a case of rearranging the data, but creating 'more' data too. I've tried to achieve this using 'reshape' and 'stack' (their help files and after looking through the mailing archives), but I'm obviously doing something wrong. For reshape, I'm getting errors relating to the commands I enter, and for stack, I can only produce two columns from my data (with the additional 3rd column being a row count). In any case, these two columns refer to the wrong values (it's producing output in the form of: row count number, Longitude, Value). This is pretty easy with the reshape package: install.packages(reshape) library(reshape) jan_long - melt(Jan) You can find out more at http://had.co.nz/reshape Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using the shape () function
In a research project we are using a web-based tools for collecting data from questionnaire. The system generates files that are simple to read as a data frame in the long format, which are simple to convert to the wide format. Something that might happen are: (a) there are two (multiple) references to the same cell, and (b) if there are missing values? So, the data set has two references to S2/T2 and none to the S2/T1 combination: d values person time 1 1 S1 T1 2 2 S1 T2 3 3 S1 T3 4 4 S1 T4 5 22 S2 T2 6 6 S2 T2 7 7 S2 T3 8 8 S2 T4 9 9 S3 T1 10 10 S3 T2 11 11 S3 T3 12 12 S3 T4 reshape (d, idvar=person, v.names=c(values), timevar=time, direction=wide) person values.T1 values.T2 values.T3 values.T4 1 S1 1 2 3 4 5 S2NA22 7 8 9 S3 9101112 The missing cell gets an NA as expected. But the surprise is in the case where there are two references to the same cell. The the *first* is used (22 rather than 6). Is there some way of forcing reshape () to use the *last* value? Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] re sultant column names from reshape::cast, with a fun.aggregate vector
try this: scores.melt = data.frame(grade = floor(runif(100, 1,10)), variable = 'score', value = rnorm(100)); cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, length)) it has the nice column names of: grade score_mean score_length 1 1 0.087885358 2 2 0.16720313 15 3 3 0.410462997 4 4 0.13928356 13 ... but now try this: cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, function(x) sum(x 0))) and you get a huge mess: grade score_mean score_function.x..sum.x...0. 1 1 0.087885354 2 2 0.167203136 3 3 0.410462992 4 4 0.139283565 I would think that something like this would fix it up, but no dice: cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, num.neg = function(x) sum(x 0))) that is, why not look at names(fun.aggregate)? or am I missing something? thanks, Mike I would think that -- View this message in context: http://www.nabble.com/resultant-column-names-from-reshape%3A%3Acast%2C-with-a-fun.aggregate-vector-tp17910885p17910885.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Insert raster image into an R graphic
Look at the subplot function in the TeachingDemos package. One of the examples shows a scatterplot using the R logo as the points. You may also want to look at the my.symbols function in the same package. -Original Message- From: Tudor Bodea [EMAIL PROTECTED] To: [EMAIL PROTECTED] [EMAIL PROTECTED] Cc: Tudor Bodea [EMAIL PROTECTED] Sent: 6/16/08 9:11 PM Subject: [R] Insert raster image into an R graphic Dear useRs: Is there a way to include a raster image (e.g., .gif, .jpg, .bmp) representing a company logo, a school logo, etc. into an R graphic? For example, it would be nice to be able to include the logo of the school into the charts that a student produces for her dissertation. Similarly, while working on a competitive analysis, it would be nice to be able to replace the names of the competitors with their brand logos. My searches so far led to inconclusive results and, therefore, any suggestions are welcome. Thank you so much. Tudor -- Tudor Dan Bodea Georgia Institute of Technology School of Civil and Environmental Engineering Web: http://www.prism.gatech.edu/~gtg757i __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 回复: cch() and coxph() for case-c ohort
On Mon, 16 Jun 2008, Peter Dalgaard wrote: Jin Wang wrote: I tried to compare if cch() and coxph() can generate same result for same case cohort data Use the standard data in cch(): nwtco Since in cch contains the cohort size=4028, while ccoh.data size =1154 after selection, but coxph does not contain info of cohort size=4028. The rough estimate between coxph() and cch() is same, but the lower and upper CI and P-value are a little different. Can we exactly use coxph() to repeat cch() using with appropriate configuration in coxph()? Is SAS a better way(PHREG,CASECOH.SAS) to implement time-dependent case-cohort? I think you need to read the literature, in particular the paper by Therneau (!) and Li, which among other things details the implementation of the Self-Prentice estimator. With that in mind, it should not be surprising that it is non-trivial how to get correct SE's out of coxph. What _is_ surprising (at least somewhat) is how close the robust SE are to those of the Self-Prentice method -- if I understand correctly, the connection is that Self-Prentice uses jackknifing for the contribution from subcohort sampling plus the standard Cox asymptotic variance and the robust method effectively uses jackknifing for both. Yes. The cch() methods all do a model-based analysis of the full cohort and a finite-sampling analysis of the second-phase sampling. For Cox models the model-based and jackknife variances are usually very close. The nwtco data is actually an unusually bad fit to the Cox model and the differences are larger than usual. (I'm a bit puzzled about why cch() insists on having unique id's, though. Doesn't _look_ like it would be too hard to get rid of that restriction, at least for S-P, which admittedly is the only method I spent enough time studying. And that was a some years ago.) If you have only one event per person the only problem is that the code isn't written that way. On the other hand, if you do have additional time-varying covariates there will be a (possibly useful) efficiency gain from using more efficient methods than cch() provides, with calibration of weights based on covariates inside and outside the subcohort. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Trouble with FUN(newX[, i], ...)
Hi, I found the error. In my dataset there was some missing values those were blank. I have replaced the values with very small numeric values and it seems to be working. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Capturing coxph warnings and errors
Hi, I have a script that takes a subset of genes on a microarray and tries to fit a coxph model to the expression values for each gene. This seems to work fine but in some cases it produces warnings and/or errors. For example: Error in fitter(X, Y, strats, offset, init, control, weights = weights, : NA/NaN/Inf in foreign function call (arg 6) In addition: Warning message: In fitter(X, Y, strats, offset, init, control, weights = weights, : Ran out of iterations and did not converge In this situation I would like to: 1) Deal with it so that it the scripts result data.frame the p value etc are set to NA. 2) Suppress the Error and Warning messages What is the best way to do this? Thanks -- ** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis Email: [EMAIL PROTECTED] ** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the a...{{dropped:2}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Dual axis labeling of a single quantity
give use a dummy (or the whole thing if it is not too large) and the code you are using for the boxplot in copy and paste into R format (dput() the data), and it may be easier. Stephen On Mon, Jun 16, 2008 at 2:51 PM, Thomas Adams [EMAIL PROTECTED] wrote: I have a problem where I need to label the vertical axes of a Boxplot with related, but different quantities (flow height), which have a known relationship. Primarily I want to plot the variable as a flow on the left axis and on the opposing right axis, show the corresponding height. Is it possible to get the flow range (max min) of the left axis and then supply the right axis with that range (corresponding max/min) which will be plotted automatically by R? It does not matter if the opposing tick marks exactly correspond to the tick mark values on the left side as long as the scale is correct (that is the correct corresponding range). I'm not even sure where to start searching for this Regards, Tom -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: [EMAIL PROTECTED] VOICE: 937-383-0528 FAX:937-383-0033 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] re sultant column names from reshape::cast, with a fun.aggregate vector
I would think that something like this would fix it up, but no dice: cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, num.neg = function(x) sum(x 0))) that is, why not look at names(fun.aggregate)? or am I missing something? Yes, that's a bug in each (the function which turns a vector of functions into a function that returns a named vector of outputs). I've added a note to my to do. In the meantime, you can do: num.neg - function(x) sum(x 0) cast(scores.melt, grade ~ variable, fun.aggregate = c(mean, num.neg)) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using the shape () function
On Tue, Jun 17, 2008 at 9:28 AM, Tom Backer Johnsen [EMAIL PROTECTED] wrote: In a research project we are using a web-based tools for collecting data from questionnaire. The system generates files that are simple to read as a data frame in the long format, which are simple to convert to the wide format. Something that might happen are: (a) there are two (multiple) references to the same cell, and (b) if there are missing values? So, the data set has two references to S2/T2 and none to the S2/T1 combination: d values person time 1 1 S1 T1 2 2 S1 T2 3 3 S1 T3 4 4 S1 T4 5 22 S2 T2 6 6 S2 T2 7 7 S2 T3 8 8 S2 T4 9 9 S3 T1 10 10 S3 T2 11 11 S3 T3 12 12 S3 T4 reshape (d, idvar=person, v.names=c(values), timevar=time, direction=wide) person values.T1 values.T2 values.T3 values.T4 1 S1 1 2 3 4 5 S2NA22 7 8 9 S3 9101112 The missing cell gets an NA as expected. But the surprise is in the case where there are two references to the same cell. The the *first* is used (22 rather than 6). You might try using the reshape package instead: last - function(x) x[length(x)] names(d) - c(value, person, time) cast(d, person ~ time, last) You can find out more at http://had.co.nz/reshape Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems with Cochrane-Orcutt procedures
Hi John, Hi Folks/Prof. Fox, I found some code John Fox had written sometime back on the Cochrane-Orcutt and Prais procedures here: https://stat.ethz.ch/pipermail/r-help/2002-January/017774.html I thought I would try it out and get the following errors below. Was wondering if anyone had any immediate opinions why this might be ? The linear model is the object regrCMSlm . Thanks, Tolga regrCMSlm Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Coefficients: (Intercept) regrCMS[, 2] 25.7067 -0.3409 summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 11/28/07 02/01/08 04/09/08 06/16/08 10.0593 0.3588 -1.1459 0.1340 -9.8520 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 25.706730.85300 30.14 2e-16 *** regrCMS[, 2] -0.340920.02205 -15.46 2e-16 *** --- Signif. codes: 0 â***â 0.001 â**â 0.01 â*â 0.05 â.â 0.1 â â 1 Residual standard error: 2.746 on 187 degrees of freedom Multiple R-squared: 0.561, Adjusted R-squared: 0.5587 F-statistic: 239 on 1 and 187 DF, p-value: 2.2e-16 cochrane.orcutt(regrCMSlm) Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') prais.winsten(regrCMSlm) Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to http://www.jpmorgan.com/pages/disclosures for disclosures relating to UK legal entities. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Rpart description of tree groups
I'm making a few functions to generate latex files describing rpart objects that are then \input-ed into a larger document. So far, the functions I have generate paragraphs containing enumerations of the predictors in pruned trees and the number of formed groups. Its easy enough to recover these. For instance, R print ( tree ) n= 878 node), split, n, loss, yval, (yprob) * denotes terminal node 1) root 878 110 Absent (0.8747153 0.1252847) 2) P3XMAR2=No 845 96 Absent (0.8863905 0.1136095) * 3) P3XMAR2=Yes 33 14 Absent (0.5757576 0.4242424) 6) PADV=Yes 7 0 Absent (1.000 0.000) * 7) PADV=No 26 12 Present (0.4615385 0.5384615) 14) ACPS=No 12 5 Absent (0.583 0.417) * 15) ACPS=Yes 14 5 Present (0.3571429 0.6428571) * R varsInTree - as.vector ( + tree $ frame $ var [ tree $ frame $ var %nin% leaf] # %nin% from Hmisc + ) R varsInTree [1] P3XMAR2 PADVACPS R nGroupsInTree - sum ( tree $ frame $ var == leaf ) R nGroupsInTree [1] 4 R What i havent been successful at so far is generating an enumerated list of the groups formed. I wanted to do something similar to the print.rpart but instead of enumerating nested lists I wanted a description of the terminal nodes. For instance, from the tree shown above i wanted to generate something like The resultant model separated sampled respondents into 4 groups. These groups (and predicted values) included respondents having \begin{inparaenum}[(a)] \item P3XMAR2=No (Absent); \item P3XMAR2=Yes and PADV=Yes (Absent); \item P3XMAR2=Yes and PADV=No and ACPS=No (Absent); and \item P3XMAR2=Yes and PADV=No and ACPS=Yes (Present); \end{inparaenum} So far, I've just generated placeholders for the \items and then i edit them by hand. Does anyone have advice on recovering the formed groups? -- David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to fit a curve of form Y = X^Z
Hello, I have a question about R, and will be very grateful for any help. I have two variables X and Y, and think that Y is related to X by a function of the form : Y = X^Z, where Z is 1. However, I'm not sure how to find the best-fit equation to fit my data to a curve of this form using R. Have you any ideas? regards Avril Coghlan Wellcome Trust Sanger Institute, Cambridge, UK -- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Defining a function in R namespace
I have written a function evalLogOptimal(). I need to define it in R namespace so that I can call it from a Java program. How do I define an R function in the namespace? Thanks, Madhura __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] modifying INSTALL to make html but not build package
Jonathan Baron wrote: I have found the problem. I don't understand it, but the script works now. I've removed it from where it was but will send it to anyone who wants it. Jon I'm interested in seeing it. I maintain a private mirror of cran which is modified so that it provides the most appropriate view into the repository for all prior versions of R. -- Nathan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using spec.pgram
Even if the signal given by the histogram is not really a signal, it seems that spec.pgram can give an interesting evaluation of how the genes are spaced in the chromosome, like in the article. So now, when I study a chromosome with 200 interesting genes, I would like to compare the amplitude of the spectrum of the periodogram given by spec.pgram (applied on the histogram of the distances between genes) with another periodogram for a chromosome with 350 interesting genes. As the spectrum seems to be calculated approximately like fft(x)^2/N (according to the computation of pgram[] in spec.pgram but perhaps I am wrong) where x stands for the signal and N for the number of observations in the signal, I suppose I can compare to periodogram (and the values of the peaks) by dividing the value of the spectrum by N. I apply this kind of technique with a cosine signal like this: x= 1:1000 cox = cos (x) spec.pgram (cox, log=no, taper=0.5) x= 1:100 cox = cos (x) spec.pgram (cox, log=no, taper=0.5) and the two periodograms have an amplitude of the peak equals when we divide it by the corresponding Ns. Am I wrong if I use this technique to compare my periodograms? Thanks in advance. Best regards, Anthony On Mon, Jun 16, 2008 at 8:37 PM, stephen sefick [EMAIL PROTECTED] wrote: OK so this is what I think- The gaussian smoothing window is just like the smooth curve that i suggested that you draw on top of the histogram (try looking at ?density and on the R site search page). They take this and then make the density = 1. I am not sure how this is done, but i am sure that you could figure it out. I believe that what they are doing is still taking the area under the curve at discrete periodicities (I would not call these periodicities because there is not really a periodic part of this signal- there is re-occurance, but not really periodicity) and that is what the power spectrum is revealing. This is not a typical use of the fourier transform, but may be valid. this signal is not stationary So I would suggest using wavelet analysis, but it still does not seem be a classical signal analysis problem- I would look at Price et al. in the reference section to see if there is presidence for this type of analysis. But from my experience in time domain to frequency domain problems this does not fit the model of data that I have worked with, and therefore it may be a bias on my part, but I would use the histogram as my justification for the distances being significant. Good Luck Stephen On Mon, Jun 16, 2008 at 2:04 PM, stephen sefick [EMAIL PROTECTED] wrote: i am reading the paper and trying to figure out what they are doing. At this point in time it looks like what they are doing is using the value at the top of the histogram bar as the value at the distance on the x-axis. they then use the equivalent of spec.pgram. My nearest approximation of what this does is that this analysis is integrating the area under the curve at a particular time. It doesn't seem that there is any periodicity in this data because of the fact that there isn't a real signal here- it is binned by distance between the genes. Not to say that spectral density is not valid, but is is not a periodicity that this analysis is look at rather an amount of power (area under the curve). I am not entirely sure that this is any more information than what is contained in the historgrams. Take a pen and draw from the top of each box starting on the left- This is the signal that is being analyzed. I need to read the rest of the paper and think about it a little bit more. If you have any ideas- pass them along. Stephen On Mon, Jun 16, 2008 at 12:14 PM, Anthony Mathelier [EMAIL PROTECTED] wrote: OK, it seems like I do not succeed in expressing what I do, or want to do. So, I give you the example that bring me to this kind of analysis. I wrote the paper Chromosomal periodicity of evolutionary conserved gene pairs (which you can download at http://www.pnas.org/cgi/reprint/104/25/10559). In figure 2, they have a histogram of distances between genes on a chromosome and they make a discrete fourier transform analysis to exhibit a period of 117kb. They explain how they did in the first paragraph of Distributions of distances and positions and fourier transform (last page). I thought that this kind of analysis was made by spec.pgram with a histogram. But perhaps I am wrong because I really do not understand what they mean by the histogram was tranformed into a continuous probability density by using a Gaussian smoothing window and normalizing the total density over the entire genome to 1. A discrete Fourier transform of the data were computed from 0 to 1,000kb by using a Tukey window to taper the end (ratio of 0.5 for tapered to untapered length.. I hope it explains better what I want to obtain from my distances. Best regards, Anthony On Mon, Jun 16, 2008 at 5:25 PM, stephen sefick
[R] Fitting Multiple Univariate Distributions to Data
I am looking for procedure that allow one to fit multiple distributions to a variable. For example, based on analysis of the data we suppose that the data can be represented by 3-5 normal distributions added together. I would like to be able to determine the mean, sd, and weight associated with each distribution and examine the improvement of the fit when 3,4 or 5 normal distributions are used as components of the observed data. The goal is to be able to separate out the background observations from impacted observations and be able to develop summary stats that describe background/baseline. I have been experimenting with mclust package but I am not convinced this is the best/simplest way to proceed. I am hoping to add this sort of analysis to some of the other ways were are able to characterized background and compare them all. This is for the evaluation of chemicals in the environment. Michael J. Bock, PhD | Manager ENVIRON | www.environcorp.com http://www.environcorp.com/ 136 Commercial Street, Suite 402 Portland, ME 04101 V: 207.347.4413 x223| F: 207.347.4384 |[EMAIL PROTECTED] This message contains information that may be confidenti...{{dropped:11}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help fCalendar holidayNYSE for Regressors
I am working with weekly time series data as in: tsData=ts(data,start=c(2004,1),freq=52) I have a table of regression variables that matchs called cReg (loaded from an xls sheet). I would like to append to the cReg table dummy variables for all the holidays as calculated from the fCalendar package for instance, Easter, Christmas, Memorial Day, etc.) The problem I am running into is how to get the data that I can get from the fCalendar package into something useful for time series analysis such that my sampled data tsData is weekly but the holiday functions are giving me raw dates. In short I need to be able to answer Does this week have a christmas in it? Does this week contain Memorial day, etc. Any ideas? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Decision Trees RWeka
Hello, I have a question concerning decision trees coming from RWeka : library(RWeka) m =J48(Species~.,data=iris) How could such a decision tree be transferred into a matrix, pretty much in the same fashion, as it is done by getTree() in library(ofw) library(ofw) data(srbct) attach(srbct) ##ofwCART learn.cart.keep - ofw(srbct, as.factor(class),type=CART, ntree=50, nforest=10, mtry=5) getTree(learn.cart.keep, k=3) detach(srbct) It would be very convenient to have a Weka Decision Tree object represented in matrix form or in y common binary tree format thanks a lot __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Z test and proportions
Hi All, I have a table based on ordial data and i want to compare proportions and i've seen in the pwr package i can use power.prop.test however i want to find out what the sig. value is based on n1,n2,p1,p2 and this package doesn't contain this.. Does anyone know of a package that does or is it a case of writting a function specifically for this? Many thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] constrOptim with method = L-BFGS-B
Hi, i need to minimize a quadratic function with boundary condidtions and one equality condition. In order to do that i converted the equality constraint into 2 inequality constaints and passed everything cia constrOptim, as the manual said: everything included in the ... will be passed to Optim that will pass it back to fn in case it does not need it. My code is the following: mat - array( c(0.0001088799073581, 0.136029502036, 0.060430384243, 0.847097879033, 0.115053365822, 0.216245975292, 0.483253391811, 0.787580901352, 0.186474817658, 0.312260571354, 0.217594093734, 0.536298150897, 0.166202592455, 0.451975061637, -0.120364862228, 0.497117714376, 0.136029502036, 0.0001537319301276, 0.226518408080, 0.591480002102, 0.797128619950, 0.091332643423, 0.693354260457, 0.825217915015, 0.22917269, 0.297662414650, 0.334443258658, 0.273254534933, 0.202062301763, 0.026260702295, 0.558975248740, 0.953647537111, 0.060430384243, 0.226518408080, 0.0005971325756834, -0.762583321100,-0.246005202071,-0.300982253054, 0.299178429478, 0.135672602503, 0.0001735431064391, -0.133347388414,0.0001387582890571, 0.964898243724, -0.149571346672,0.104437939143, 0.0001246900353191, -0.171884354549, 0.847097879033, 0.591480002102, -0.762583321100, 0.0004968467836203, 0.0002303499425964, 0.992731601466, 0.0002685466918035, 0.0002580180069951, 0.725833959653, 0.525639940758, 0.0001785049461665, 0.0001781339191317, 0.597631329497, 0.201160486244, 0.0002582267884874, 0.0002473268250781, 0.115053365822, 0.797128619950, -0.246005202071, 0.0002303499425964, 0.0002945009393242, -0.426583313588, 0.0002067711081561, 0.0002695894499975, 0.0001312519434236, -0.079156628396,0.0001423655606105, 0.044733483182, 0.303832556655, 0.577624190434, 0.0001193435284164, 0.0002422477575812, 0.216245975292, 0.091332643423, -0.300982253054, 0.992731601466, -0.426583313588,0.0001641146317929, 0.311621614693, -0.147821020927,-0.767394607354, 0.619936562782, -0.306228761064,0.0001495752154579, 0.389317919640, -0.714551280935,-0.564616194935, 0.384367900903, 0.483253391811, 0.693354260457, 0.299178429478, 0.0002685466918035, 0.0002067711081561, 0.311621614693, 0.0003176493360736, 0.0002575792630182, 0.0001371966488704, 0.436833885846, 0.0001442516276721, 0.0001075447728937, 0.371155448252, 0.475873370276, 0.0002162409964174, 0.0002870514043081, 0.787580901352, 0.825217915015, 0.135672602503, 0.0002580180069951, 0.0002695894499975, -0.147821020927, 0.0002575792630182, 0.0006217963583393, 0.0002368375072233, 0.078625467985, 0.0002054774387807, -0.066572248626, 0.485854317294, 0.0002802199677114, 0.0001676465030622, 0.0003028775764026, 0.186474817658, 0.22917269, 0.0001735431064391, 0.725833959653, 0.0001312519434236, -0.767394607354, 0.0001371966488704, 0.0002368375072233, 0.0004475645060339, -0.030389778729,0.0001706183643212, -0.017789896670, 0.722657436668, 0.0001664088523103, 0.0001220193496918, 0.0001641280878243, 0.312260571354, 0.297662414650, -0.133347388414, 0.525639940758, -0.079156628396,0.619936562782, 0.436833885846, 0.078625467985, -0.030389778729, 0.822356406019, -0.226786278360,0.752056105897, 0.399801889185, -0.441549693477,0.047887593401, 0.352165734549, 0.217594093734, 0.334443258658, 0.0001387582890571, 0.0001785049461665, 0.0001423655606105, -0.306228761064, 0.0001442516276721, 0.0002054774387807, 0.0001706183643212, -0.226786278360,0.0004304869804941, 0.0001566983136020, 0.332770114864, 0.012432094922, 0.0002491186667930, 0.0001285479414542, 0.536298150897, 0.273254534933, 0.964898243724, 0.0001781339191317, 0.044733483182, 0.0001495752154579, 0.0001075447728937, -0.066572248626,-0.017789896670, 0.752056105897, 0.0001566983136020, 0.0005292416268831, 0.893358436932, -0.0001009559617338,0.888461032129, 0.714719761291, 0.166202592455, 0.202062301763, -0.149571346672, 0.597631329497, 0.303832556655, 0.389317919640, 0.371155448252, 0.485854317294, 0.722657436668, 0.399801889185, 0.332770114864,
Re: [R] Z test and proportions
Michael Pearmain wrote: Hi All, I have a table based on ordial data and i want to compare proportions and i've seen in the pwr package i can use power.prop.test however i want to find out what the sig. value is based on n1,n2,p1,p2 and this package doesn't contain this.. Does anyone know of a package that does or is it a case of writting a function specifically for this? I think your wired got crossed somewhere: power.prop.test is not from the pwr package; however, pwr does contain pwr.2p2n.test, which looks like it does exactly what you want! Many thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stop unwanted boxes/dialogs in tcl/tk
Hello, I have a question about tcl/tk: is there a way to stop more messagers/listchoice/etc. that are set up earlier, but are unwanted later? for example, require(tcltk) ttMain - tktoplevel() tkwm.title(ttMain,Question) f.fcn - function(){ t1 - modalDialogOK(Elicitation,What's the LOWER bound of A1,entryInit=) t2 - modalDialogOK(Elicitation,What's the LOWER bound of A2,entryInit=) t3 - modalDialogOK(Elicitation,What's the LOWER bound of A3,entryInit=) } f.fcn() When run the function, three dialog box would pop up in sequence. If in the middle, say, after t2 pop up, I don't want to answer t3, is there a way to block t3? Close the t1,t2 boxes(even the question main frame) doesn't stop t3 coming up, though it gives a lot of error messages. Thanks! Hua __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R error using Survr function with gcmrec
Would someone be able to help with this question? I'm using the Gcmrec, Survrec, and Design packages to do a power analysis on simulated data. I'm receiving an error after using the Survr function that all data must have a censoring time even after using the gcmrec function: newdata-addCenTime(olddata). My program is below. I'd greatly appreciate any help! id-c(seq(1,288,by=1),seq(1,79,by=1),seq(1,11,by=1)) x-c(rep(0,5),rep(1,6),rep(0,45),rep(1,23),rep(0,124),rep(1,85), +rep(0,4),rep(1,1),rep(0,1),rep(1,5),rep(0,31),rep(1,14),rep(0,5), +rep(1,18),rep(0,8),rep(1,3)) myrates-((1-x)*0.0639 + (x)*0.0320) y-c(rexp(378,rate=myrates)) cen-c(rexp(378,0.0385)) time-pmin(y,cen) event-as.numeric(y=cen) x2-(x-1)*(-1) bvdata-data.frame(id,event,time,x2) bvdata2-addCenTime(bvdata) fit-cph(Survr(id,event,time)~x2,data=bvdata2) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Z test and proportions
Yes my mistake, I looked at the pwr.2p2n.test but i cannot place both n's and both p values to determine the sig value e,g *pwr.2p2n.test(h = , n1 = , n2 = , sig.level = , power = ) or am i missing someting obvious? i did the sam ein SPSS using a macro and the following code: COMPUTE n1 = Control_MAX . COMPUTE n2 = Exposed_max. COMPUTE x1 = Control. COMPUTE x2 = Exposed. COMPUTE p1 = x1/n1. COMPUTE p2 = x2/n2. COMPUTE phat = (x1 + x2) / (n1 + n2). COMPUTE SE_phat = SQRT(phat * (1 - phat) * ((1/n1) + (1/n2))). COMPUTE z = (p1 - p2) /SE_phat. COMPUTE SIGz_2TL = 2 * (1 - CDFNORM(ABS(z))). COMPUTE SIGz_LTL = CDFNORM(Z). COMPUTE SIGz_UTL = 1 - CDFNORM(Z). COMPUTE SIG_Level = ABS(1-(1-CDFNORM(z))*2). Compute p1p = p1*100. Compute p2p = p2*100. compute diff = p2p-p1p. EXE. Var lab p1p Control Group %. Var lab p2p Exposed Group %. * On Tue, Jun 17, 2008 at 5:13 PM, Peter Dalgaard [EMAIL PROTECTED] wrote: Michael Pearmain wrote: Hi All, I have a table based on ordial data and i want to compare proportions and i've seen in the pwr package i can use power.prop.test however i want to find out what the sig. value is based on n1,n2,p1,p2 and this package doesn't contain this.. Does anyone know of a package that does or is it a case of writting a function specifically for this? I think your wired got crossed somewhere: power.prop.test is not from the pwr package; however, pwr does contain pwr.2p2n.test, which looks like it does exactly what you want! Many thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 -- Michael Pearmain Senior Statistical Analyst 1st Floor, 180 Great Portland St. London W1W 5QZ t +44 (0) 2032191684 [EMAIL PROTECTED] [EMAIL PROTECTED] Doubleclick is a part of the Google group of companies [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Decision Trees RWeka
On Tue, 17 Jun 2008, [EMAIL PROTECTED] wrote: Hello, I have a question concerning decision trees coming from RWeka : library(RWeka) m =J48(Species~.,data=iris) How could such a decision tree be transferred into a matrix, pretty much in the same fashion, as it is done by getTree() in library(ofw) library(ofw) data(srbct) attach(srbct) ##ofwCART learn.cart.keep - ofw(srbct, as.factor(class),type=CART, ntree=50, nforest=10, mtry=5) getTree(learn.cart.keep, k=3) detach(srbct) It would be very convenient to have a Weka Decision Tree object represented in matrix form or in y common binary tree format Sure, that would be nice. However, we do not have a full R-representation of Weka_tree objects as we rely for almost all computations on the corresponding methods from Weka. For plotting we do some parsing of the representation (based on the DOT graph representation). Have a look at the output of RWeka:::make_Weka_classifier_tree(m) hth, Z Weka_tree objects is that RWeka relies for almost all computations on the corresponding Weka methods and thus doesn't thanks a lot __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] RWeka handlers
Dear RWeka users, I was wondering how I can set Weka classifier options in make_Weka_classifier(). What I tried to do is classifiers[[1]] - make_Weka_classifier(weka/classifiers/lazy/IBk, handlers = Weka_control(K = 2)) but this seems to have no effect - IBk still uses K=1 (default setting). Does anybody know what's wrong here? Thanks! Nils -- Nils B. Weidmann International Conflict Research ETH Zurich http://www.icr.ethz.ch/people/weidmann __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The assign function in R
Hello, I want to convert assign(a, b, where =1 ) from SPLUS to R. Is it safe to assume that the equivalent of where=1 is pos=1 in R? Thanks for help! -- View this message in context: http://www.nabble.com/The-assign-function-in-R-tp17918416p17918416.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] alternative to matching/merge?
Jim, I understand that that do.call will combine all the lists into a matrix. But I have a list,x, which is a list of a list as in x[[1]] and x[[2]] which are themselves lists. Then using do.call(rbind, x) would combine both x[[1]] and x[[2]] into a matrix. I want to keep x[[1]] and x[[2]] separately into their own matrix, and so I am putting do.call into a loop ie. do.call(rbind,x[[i]]) to keep them separate. More elegantly I would want to put do.call into lapply but have not been successful to do this. Lana -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Monday, June 16, 2008 5:24 PM To: Lana Schaffer Cc: hadley wickham; r-help@r-project.org Subject: Re: [R] alternative to matching/merge? Is this what you tried: x - data.frame(a=1:10, b=1:10) x - data.frame(a=1:3, b=1:3) do.call(rbind, list(x,x,x,x,x)) a b 1 1 1 2 2 2 3 3 3 4 1 1 5 2 2 6 3 3 7 1 1 8 2 2 9 3 3 10 1 1 11 2 2 12 3 3 13 1 1 14 2 2 15 3 3 On Mon, Jun 16, 2008 at 7:36 PM, Lana Schaffer [EMAIL PROTECTED] wrote: Jim, Is it possible to do a do.call(rbind,d.frame) with a list like using lapply(data,func,args)? I have not successfully executed this. Lana -Original Message- From: hadley wickham [mailto:[EMAIL PROTECTED] Sent: Friday, June 13, 2008 2:54 PM To: jim holtman Cc: Lana Schaffer; r-help@r-project.org Subject: Re: [R] alternative to matching/merge? On Fri, Jun 13, 2008 at 11:45 AM, jim holtman [EMAIL PROTECTED] wrote: What is the structure of 'd.frame' and 'segFile'? Run Rprof so that we can see which of the functions it is spending its time in. What happens if x$index is not in seqFile$index? Are the values in the 'index' unique in both structures? Subsetting a data frame can be expensive when compared to using a matrix. Could you use a matrix instead of a data frame; are all the columns the same mode? Again either a subset of data would be helpful or an 'str' on the data objects being used so that we can understand what they are. A few other ideas to try: * try merging do.call(rbind, d.frame) and seqFile, and then spliting the results back up * try turning giving seqFile rownames (rownames(seqFile) - seqFile$index) and then use character matching: cbind(x, seqFile[ as.character(x$index)] * if there is a one to one corresponding between index in seqFile and all data.frames in d.frame, merge all of the d.frames together, order both by index then just cbind Hadley -- http://had.co.nz/ -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to fit a curve of form Y = X^Z
I have two variables X and Y, and think that Y is related to X by a function of the form : Y = X^Z, where Z is 1. However, I'm not sure how to find the best-fit equation to fit my data to a curve of this form using R. Have you any ideas? You can use nlm() to fit a non-linear model. Another option would be to fit a linear model to log-log transformed data. However, if you are actually trying to fit to a power-law distribution you may want to have a look at these references: Goldstein, M.; Morris, S. Yen, G. Problems with Fitting to the Power-Law Distribution European Physical Journal B, 2004, 41, 255-258 Newman, M. E. J. Power laws, Pareto distributions and Zipf's law Contemporary Physics, 2005, 46, 323 cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://mips.gsf.de/staff/pagel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] useR! 2008: program online
Dear useRs, we have finally put together the program for the useR! 2008 conference, it is available online at http://www.R-project.org/useR-2008/program.html We think the contributions provide an exciting program with a rich variety in the kaleidoscope sessions and many classical as well as hot topics in the focus sessions. We look forward to the conference and seeing many participants for interesting discussion in Dortmund! For more details see the conference web page at http://www.R-project.org/useR-2008/ For the organizing committee, Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with Cochrane-Orcutt procedures
Dear Tolga, I'm afraid that I don't see an error. (I expect in any event that the Cochrane-Orcott and Prais estimators are now only of historical interest.) Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: June-17-08 11:13 AM To: r-help@r-project.org Subject: [R] Problems with Cochrane-Orcutt procedures Hi John, Hi Folks/Prof. Fox, I found some code John Fox had written sometime back on the Cochrane-Orcutt and Prais procedures here: https://stat.ethz.ch/pipermail/r-help/2002-January/017774.html I thought I would try it out and get the following errors below. Was wondering if anyone had any immediate opinions why this might be ? The linear model is the object regrCMSlm . Thanks, Tolga regrCMSlm Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Coefficients: (Intercept) regrCMS[, 2] 25.7067 -0.3409 summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 11/28/07 02/01/08 04/09/08 06/16/08 10.0593 0.3588 -1.1459 0.1340 -9.8520 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 25.706730.85300 30.14 2e-16 *** regrCMS[, 2] -0.340920.02205 -15.46 2e-16 *** --- Signif. codes: 0 b __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Z test and proportions
Michael Pearmain wrote: Yes my mistake, I looked at the pwr.2p2n.test but i cannot place both n's and both p values to determine the sig value e,g *pwr.2p2n.test(h = , n1 = , n2 = , sig.level = , power = ) or am i missing someting obvious? * Not quite obvious, but h is the effect size and is a function of p1 p2, after arcsine transformation. The documentation for the pwr package is a bit short on information on _which_ arcsine transformation that is, though. As far as I can see, it is 2*asin(sqrt(p)), since pwr.2p2n.test(2*(asin(sqrt(.5))-asin(sqrt(.7))),n1=200,n2=200) difference of proportion power calculation for binomial distribution (arcsine transformation) h = 0.4115168 n1 = 200 n2 = 200 sig.level = 0.05 power = 0.984427 alternative = two.sided NOTE: different sample sizes power.prop.test(p1=.5,p2=.7,n=200) Two-sample comparison of proportions power calculation n = 200 p1 = 0.5 p2 = 0.7 sig.level = 0.05 power = 0.9849271 alternative = two.sided NOTE: n is number in *each* group *i did the sam ein SPSS using a macro and the following code: COMPUTE n1 = Control_MAX . COMPUTE n2 = Exposed_max. COMPUTE x1 = Control. COMPUTE x2 = Exposed. COMPUTE p1 = x1/n1. COMPUTE p2 = x2/n2. COMPUTE phat = (x1 + x2) / (n1 + n2). COMPUTE SE_phat = SQRT(phat * (1 - phat) * ((1/n1) + (1/n2))). COMPUTE z = (p1 - p2) /SE_phat. COMPUTE SIGz_2TL = 2 * (1 - CDFNORM(ABS(z))). COMPUTE SIGz_LTL = CDFNORM(Z). COMPUTE SIGz_UTL = 1 - CDFNORM(Z). COMPUTE SIG_Level = ABS(1-(1-CDFNORM(z))*2). Compute p1p = p1*100. Compute p2p = p2*100. compute diff = p2p-p1p. EXE. Var lab p1p Control Group %. Var lab p2p Exposed Group %. * On Tue, Jun 17, 2008 at 5:13 PM, Peter Dalgaard [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Michael Pearmain wrote: Hi All, I have a table based on ordial data and i want to compare proportions and i've seen in the pwr package i can use power.prop.test however i want to find out what the sig. value is based on n1,n2,p1,p2 and this package doesn't contain this.. Does anyone know of a package that does or is it a case of writting a function specifically for this? I think your wired got crossed somewhere: power.prop.test is not from the pwr package; however, pwr does contain pwr.2p2n.test, which looks like it does exactly what you want! Many thanks in advance [[alternative HTML version deleted]] __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED] mailto:[EMAIL PROTECTED]) FAX: (+45) 35327907 -- Michael Pearmain Senior Statistical Analyst 1st Floor, 180 Great Portland St. London W1W 5QZ t +44 (0) 2032191684 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Doubleclick is a part of the Google group of companies -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Scan document including \n
How do you read in a whole file while preserving end of line \n characters? Basically, read in a whole file as one string. Ex: XML TAG /TAG /XML After this file is read into a variable, it should really look like XML\nTAG\n/TAG\n/XML\n -- View this message in context: http://www.nabble.com/Scan-document-including-%22%5Cn%22-tp17920810p17920810.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Scan document including \n
Hi there, Try this: your.file=read.table(textConnection(XML TAG /TAG /XML),header=FALSE) paste(your.file$V1,\n,collapse=,sep=) [1] XML\nTAG\n/TAG\n/XML\n HTH, Jorge On Tue, Jun 17, 2008 at 1:01 PM, ppatel3026 [EMAIL PROTECTED] wrote: How do you read in a whole file while preserving end of line \n characters? Basically, read in a whole file as one string. Ex: XML TAG /TAG /XML After this file is read into a variable, it should really look like XML\nTAG\n/TAG\n/XML\n -- View this message in context: http://www.nabble.com/Scan-document-including-%22%5Cn%22-tp17920810p17920810.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with Cochrane-Orcutt procedures
Sure, I can imagine GLS is a much better way to deal with this. I guess I was looking at this because I did try GLS but got exactly the same results as LM and I just wanted to be sure. I did debug the code in https://stat.ethz.ch/pipermail/r-help/2002-January/017774.html and the offending line is: ... mod - lm(y ~ X - 1) ... in the Orcutt procedure. Essentially, X is twice the length of y, as below: cochrane.orcutt(regrCMSlm) debugging in: cochrane.orcutt(regrCMSlm) debug: { UseMethod(cochrane.orcutt) } Browse[1] debug: UseMethod(cochrane.orcutt) Browse[1] debugging in: cochrane.orcutt.lm(regrCMSlm) debug: { X - model.matrix(mod) y - model.response(model.frame(mod)) e - residuals(mod) n - length(e) names - colnames(X) rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) y - y[2:n] - rho * y[1:(n - 1)] X - X[2:n, ] - rho * X[1:(n - 1), ] mod - lm(y ~ X - 1) result - list() result$coefficients - coef(mod) names(result$coefficients) - names summary - summary(mod, corr = F) result$cov - (summary$sigma^2) * summary$cov.unscaled dimnames(result$cov) - list(names, names) result$sigma - summary$sigma result$rho - rho class(result) - cochrane.orcutt result } Browse[1] debug: X - model.matrix(mod) Browse[1] debug: y - model.response(model.frame(mod)) Browse[1] length(X) [1] 378 #-- Browse[1] debug: e - residuals(mod) Browse[1] length(y) [1] 189 #-- Browse[1] debug: n - length(e) Browse[1] debug: names - colnames(X) Browse[1] debug: rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) Browse[1] debug: y - y[2:n] - rho * y[1:(n - 1)] Browse[1] debug: X - X[2:n, ] - rho * X[1:(n - 1), ] Browse[1] debug: mod - lm(y ~ X - 1) Browse[1] Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') Tolga John Fox [EMAIL PROTECTED] 17/06/2008 17:51 To [EMAIL PROTECTED] cc r-help@r-project.org Subject RE: [R] Problems with Cochrane-Orcutt procedures Dear Tolga, I'm afraid that I don't see an error. (I expect in any event that the Cochrane-Orcott and Prais estimators are now only of historical interest.) Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: June-17-08 11:13 AM To: r-help@r-project.org Subject: [R] Problems with Cochrane-Orcutt procedures Hi John, Hi Folks/Prof. Fox, I found some code John Fox had written sometime back on the Cochrane-Orcutt and Prais procedures here: https://stat.ethz.ch/pipermail/r-help/2002-January/017774.html I thought I would try it out and get the following errors below. Was wondering if anyone had any immediate opinions why this might be ? The linear model is the object regrCMSlm . Thanks, Tolga regrCMSlm Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Coefficients: (Intercept) regrCMS[, 2] 25.7067 -0.3409 summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 11/28/07 02/01/08 04/09/08 06/16/08 10.0593 0.3588 -1.1459 0.1340 -9.8520 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 25.706730.85300 30.14 2e-16 *** regrCMS[, 2] -0.340920.02205 -15.46 2e-16 *** --- Signif. codes: 0 b Generally, this communication is for informational purposes only and it is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. In the event you are receiving the offering materials attached below related to your interest in hedge funds or private equity, this communication may be intended as an offer or solicitation for the purchase or sale of such fund(s). All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase Co., its subsidiaries and affiliates, as applicable, for any
[R] A new task view on survival analysis
Dear all, A new task view on survival analysis is now online. It attempts to deal with all the R-packages that permit to analyze time-to-event data. Any comments or suggestions to improve the task view are very welcome. Best regards, Arthur Allignol Freiburg Center for Data Analysis and Modeling, Freiburg University, Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] OpenGL and Linux
Anyone know how to get OpenGL for redhat fedora 8/9? thanks [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A new task view on survival analysis
And here's the link: http://cran.r-project.org/web/views/Survival.html Hadley On Tue, Jun 17, 2008 at 12:33 PM, Arthur Allignol [EMAIL PROTECTED] wrote: Dear all, A new task view on survival analysis is now online. It attempts to deal with all the R-packages that permit to analyze time-to-event data. Any comments or suggestions to improve the task view are very welcome. Best regards, Arthur Allignol Freiburg Center for Data Analysis and Modeling, Freiburg University, Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with Cochrane-Orcutt procedures
Dear Tolga, That's a little more information, but because the code seems to work for me on other data (though no longer the message dispatch), I can't say what produces the error. I guess that if you can't debug this yourself, you'll have to share the data (generally a good idea in any event). mod - lm(Hartnagel[,5] ~ Hartnagel[,7]) mod Call: lm(formula = Hartnagel[, 5] ~ Hartnagel[, 7]) Coefficients: (Intercept) Hartnagel[, 7] -85.1117 0.2126 cochrane.orcutt.lm(mod) $coefficients (Intercept) Hartnagel[, 7] 57.05592426 0.04015223 $cov (Intercept) Hartnagel[, 7] (Intercept)1226.739528 -1.381235045 Hartnagel[, 7] -1.3812350.001713204 $sigma [1] 14.00277 $rho [1] 0.7835837 attr(,class) [1] cochrane.orcutt Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: June-17-08 1:17 PM To: John Fox Cc: r-help@r-project.org; [EMAIL PROTECTED] Subject: RE: [R] Problems with Cochrane-Orcutt procedures Sure, I can imagine GLS is a much better way to deal with this. I guess I was looking at this because I did try GLS but got exactly the same results as LM and I just wanted to be sure. I did debug the code in https://stat.ethz.ch/pipermail/r-help/2002- January/017774.html and the offending line is: ... mod - lm(y ~ X - 1) ... in the Orcutt procedure. Essentially, X is twice the length of y, as below: cochrane.orcutt(regrCMSlm) debugging in: cochrane.orcutt(regrCMSlm) debug: { UseMethod(cochrane.orcutt) } Browse[1] debug: UseMethod(cochrane.orcutt) Browse[1] debugging in: cochrane.orcutt.lm(regrCMSlm) debug: { X - model.matrix(mod) y - model.response(model.frame(mod)) e - residuals(mod) n - length(e) names - colnames(X) rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) y - y[2:n] - rho * y[1:(n - 1)] X - X[2:n, ] - rho * X[1:(n - 1), ] mod - lm(y ~ X - 1) result - list() result$coefficients - coef(mod) names(result$coefficients) - names summary - summary(mod, corr = F) result$cov - (summary$sigma^2) * summary$cov.unscaled dimnames(result$cov) - list(names, names) result$sigma - summary$sigma result$rho - rho class(result) - cochrane.orcutt result } Browse[1] debug: X - model.matrix(mod) Browse[1] debug: y - model.response(model.frame(mod)) Browse[1] length(X) [1] 378 #-- Browse[1] debug: e - residuals(mod) Browse[1] length(y) [1] 189 #-- Browse[1] debug: n - length(e) Browse[1] debug: names - colnames(X) Browse[1] debug: rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) Browse[1] debug: y - y[2:n] - rho * y[1:(n - 1)] Browse[1] debug: X - X[2:n, ] - rho * X[1:(n - 1), ] Browse[1] debug: mod - lm(y ~ X - 1) Browse[1] Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') Tolga John Fox [EMAIL PROTECTED] 17/06/2008 17:51 To [EMAIL PROTECTED] cc r-help@r-project.org Subject RE: [R] Problems with Cochrane-Orcutt procedures Dear Tolga, I'm afraid that I don't see an error. (I expect in any event that the Cochrane-Orcott and Prais estimators are now only of historical interest.) Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: June-17-08 11:13 AM To: r-help@r-project.org Subject: [R] Problems with Cochrane-Orcutt procedures Hi John, Hi Folks/Prof. Fox, I found some code John Fox had written sometime back on the Cochrane-Orcutt and Prais procedures here: https://stat.ethz.ch/pipermail/r-help/2002-January/017774.html I thought I would try it out and get the following errors below. Was wondering if anyone had any immediate opinions why this might be ? The linear model is the object regrCMSlm . Thanks, Tolga regrCMSlm Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Coefficients: (Intercept) regrCMS[, 2] 25.7067 -0.3409 summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 11/28/07 02/01/08 04/09/08 06/16/08 10.0593 0.3588 -1.1459 0.1340 -9.8520 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 25.706730.85300 30.14 2e-16 *** regrCMS[, 2] -0.340920.02205 -15.46 2e-16 *** --- Signif. codes: 0 b Generally, this communication is for informational purposes only and it is not intended as
Re: [R] OpenGL and Linux
Floyd poole wrote: Anyone know how to get OpenGL for redhat fedora 8/9? Just install these: [EMAIL PROTECTED] R]$ rpm -qa | grep mesa mesa-libGLU-7.1-0.31.fc9.i386 mesa-libGL-7.1-0.31.fc9.i386 mesa-libGL-devel-7.1-0.31.fc9.i386 mesa-libGLU-devel-7.1-0.31.fc9.i386 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with Cochrane-Orcutt procedures
Sure, of course. And thanks for looking John. Here is the entire data: regrCMS a b 09/20/07 26.084 28.40 09/21/07 22.458 28.90 09/24/07 21.297 29.25 09/25/07 21.733 29.40 09/26/07 21.319 28.75 09/27/07 22.507 28.85 09/28/07 19.571 28.90 10/01/07 21.961 29.00 10/02/07 21.729 28.45 10/03/07 21.241 28.00 10/04/07 21.253 28.55 10/05/07 21.401 27.25 10/10/07 20.923 25.70 10/11/07 20.401 25.25 10/12/07 20.122 24.35 10/15/07 19.225 26.35 10/16/07 18.759 27.15 10/17/07 18.413 26.85 10/18/07 18.960 27.75 10/19/07 18.643 28.65 10/22/07 17.829 28.35 10/23/07 17.835 28.60 10/24/07 17.335 29.15 10/25/07 17.971 29.05 10/26/07 16.205 28.60 10/29/07 16.722 28.40 10/30/07 16.772 28.40 10/31/07 17.127 27.05 11/01/07 15.328 27.85 11/02/07 17.088 28.15 regrCMSlm-lm(regrCMS[,1]~regrCMS[,2]) summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 10/01/07 10/12/07 10/23/07 11/02/07 6.4365 2.2112 0.3183 -2.2462 -2.5355 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 16.92553 10.21538 1.6570.109 regrCMS[, 2] 0.095840.36477 0.2630.795 Residual standard error: 2.436 on 28 degrees of freedom Multiple R-squared: 0.00246,Adjusted R-squared: -0.03317 F-statistic: 0.06904 on 1 and 28 DF, p-value: 0.7947 cochrane.orcutt(regrCMSlm) debugging in: cochrane.orcutt.lm(regrCMSlm) debug: { X - model.matrix(mod) y - model.response(model.frame(mod)) e - residuals(mod) n - length(e) names - colnames(X) rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) y - y[2:n] - rho * y[1:(n - 1)] X - X[2:n, ] - rho * X[1:(n - 1), ] mod - lm(y ~ X - 1) result - list() result$coefficients - coef(mod) names(result$coefficients) - names summary - summary(mod, corr = F) result$cov - (summary$sigma^2) * summary$cov.unscaled dimnames(result$cov) - list(names, names) result$sigma - summary$sigma result$rho - rho class(result) - cochrane.orcutt result } Browse[1] debug: X - model.matrix(mod) Browse[1] debug: y - model.response(model.frame(mod)) Browse[1] debug: e - residuals(mod) Browse[1] debug: n - length(e) Browse[1] debug: names - colnames(X) Browse[1] debug: rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) Browse[1] debug: y - y[2:n] - rho * y[1:(n - 1)] Browse[1] debug: X - X[2:n, ] - rho * X[1:(n - 1), ] Browse[1] debug: mod - lm(y ~ X - 1) Browse[1] Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') John Fox [EMAIL PROTECTED] 17/06/2008 18:49 To [EMAIL PROTECTED] cc r-help@r-project.org Subject RE: [R] Problems with Cochrane-Orcutt procedures Dear Tolga, That's a little more information, but because the code seems to work for me on other data (though no longer the message dispatch), I can't say what produces the error. I guess that if you can't debug this yourself, you'll have to share the data (generally a good idea in any event). mod - lm(Hartnagel[,5] ~ Hartnagel[,7]) mod Call: lm(formula = Hartnagel[, 5] ~ Hartnagel[, 7]) Coefficients: (Intercept) Hartnagel[, 7] -85.1117 0.2126 cochrane.orcutt.lm(mod) $coefficients (Intercept) Hartnagel[, 7] 57.05592426 0.04015223 $cov (Intercept) Hartnagel[, 7] (Intercept)1226.739528 -1.381235045 Hartnagel[, 7] -1.3812350.001713204 $sigma [1] 14.00277 $rho [1] 0.7835837 attr(,class) [1] cochrane.orcutt Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: June-17-08 1:17 PM To: John Fox Cc: r-help@r-project.org; [EMAIL PROTECTED] Subject: RE: [R] Problems with Cochrane-Orcutt procedures Sure, I can imagine GLS is a much better way to deal with this. I guess I was looking at this because I did try GLS but got exactly the same results as LM and I just wanted to be sure. I did debug the code in https://stat.ethz.ch/pipermail/r-help/2002- January/017774.html and the offending line is: ... mod - lm(y ~ X - 1) ... in the Orcutt procedure. Essentially, X is twice the length of y, as below: cochrane.orcutt(regrCMSlm) debugging in: cochrane.orcutt(regrCMSlm) debug: { UseMethod(cochrane.orcutt) } Browse[1] debug: UseMethod(cochrane.orcutt) Browse[1] debugging in: cochrane.orcutt.lm(regrCMSlm) debug: { X - model.matrix(mod) y - model.response(model.frame(mod)) e - residuals(mod) n - length(e) names - colnames(X) rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) y - y[2:n] - rho * y[1:(n - 1)] X - X[2:n, ] - rho * X[1:(n - 1), ] mod - lm(y ~ X - 1) result - list() result$coefficients - coef(mod) names(result$coefficients) - names summary - summary(mod, corr = F) result$cov -
Re: [R] Using the shape () function
hadley wickham wrote: On Tue, Jun 17, 2008 at 9:28 AM, Tom Backer Johnsen [EMAIL PROTECTED] wrote: In a research project we are using a web-based tools for collecting data from questionnaire. The system generates files that are simple to read as a data frame in the long format, which are simple to convert to the wide format. Something that might happen are: (a) there are two (multiple) references to the same cell, and (b) if there are missing values? So, the data set has two references to S2/T2 and none to the S2/T1 combination: d values person time 1 1 S1 T1 2 2 S1 T2 3 3 S1 T3 4 4 S1 T4 5 22 S2 T2 6 6 S2 T2 7 7 S2 T3 8 8 S2 T4 9 9 S3 T1 10 10 S3 T2 11 11 S3 T3 12 12 S3 T4 reshape (d, idvar=person, v.names=c(values), timevar=time, direction=wide) person values.T1 values.T2 values.T3 values.T4 1 S1 1 2 3 4 5 S2NA22 7 8 9 S3 9101112 The missing cell gets an NA as expected. But the surprise is in the case where there are two references to the same cell. The the *first* is used (22 rather than 6). You might try using the reshape package instead: last - function(x) x[length(x)] names(d) - c(value, person, time) cast(d, person ~ time, last) The first and the last line I think is clear, although I will have to experiment more to understand the call on cast () better. However, what I do not understand is the purpose of the second line. I can print out names(d) right after the reading the frame with the read.table function. If I print names (d) right after that statement has been executed, then I see no difference. Even so, it seems to be necessary for the call on cast to work. It seems that names is not the same as names. Something along the lines of a with () or attach () perhaps? Tom You can find out more at http://had.co.nz/reshape Hadley __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems with Cochrane-Orcutt procedures
Dear Tolga, I'm afraid that your data work fine for me: regrCMSlm - lm(regrCMS[,1] ~ regrCMS[,2]) cochrane.orcutt.lm(regrCMSlm) $coefficients (Intercept) regrCMS[, 2] 23.5679065 -0.1784187 $cov (Intercept) regrCMS[, 2] (Intercept)60.449366 -2.14491371 regrCMS[, 2] -2.144914 0.07676436 $sigma [1] 1.081036 $rho [1] 0.7208652 attr(,class) [1] cochrane.orcutt I'm using R 2.7.0 on Windows Vista; I put your data in a standard data frame; and, as I said, the method dispatch no longer works, so I called Cochrane.orcutt.lm() directly. John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: June-17-08 2:13 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] Problems with Cochrane-Orcutt procedures Sure, of course. And thanks for looking John. Here is the entire data: regrCMS a b 09/20/07 26.084 28.40 09/21/07 22.458 28.90 09/24/07 21.297 29.25 09/25/07 21.733 29.40 09/26/07 21.319 28.75 09/27/07 22.507 28.85 09/28/07 19.571 28.90 10/01/07 21.961 29.00 10/02/07 21.729 28.45 10/03/07 21.241 28.00 10/04/07 21.253 28.55 10/05/07 21.401 27.25 10/10/07 20.923 25.70 10/11/07 20.401 25.25 10/12/07 20.122 24.35 10/15/07 19.225 26.35 10/16/07 18.759 27.15 10/17/07 18.413 26.85 10/18/07 18.960 27.75 10/19/07 18.643 28.65 10/22/07 17.829 28.35 10/23/07 17.835 28.60 10/24/07 17.335 29.15 10/25/07 17.971 29.05 10/26/07 16.205 28.60 10/29/07 16.722 28.40 10/30/07 16.772 28.40 10/31/07 17.127 27.05 11/01/07 15.328 27.85 11/02/07 17.088 28.15 regrCMSlm-lm(regrCMS[,1]~regrCMS[,2]) summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 10/01/07 10/12/07 10/23/07 11/02/07 6.4365 2.2112 0.3183 -2.2462 -2.5355 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 16.92553 10.21538 1.6570.109 regrCMS[, 2] 0.095840.36477 0.2630.795 Residual standard error: 2.436 on 28 degrees of freedom Multiple R-squared: 0.00246,Adjusted R-squared: -0.03317 F-statistic: 0.06904 on 1 and 28 DF, p-value: 0.7947 cochrane.orcutt(regrCMSlm) debugging in: cochrane.orcutt.lm(regrCMSlm) debug: { X - model.matrix(mod) y - model.response(model.frame(mod)) e - residuals(mod) n - length(e) names - colnames(X) rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) y - y[2:n] - rho * y[1:(n - 1)] X - X[2:n, ] - rho * X[1:(n - 1), ] mod - lm(y ~ X - 1) result - list() result$coefficients - coef(mod) names(result$coefficients) - names summary - summary(mod, corr = F) result$cov - (summary$sigma^2) * summary$cov.unscaled dimnames(result$cov) - list(names, names) result$sigma - summary$sigma result$rho - rho class(result) - cochrane.orcutt result } Browse[1] debug: X - model.matrix(mod) Browse[1] debug: y - model.response(model.frame(mod)) Browse[1] debug: e - residuals(mod) Browse[1] debug: n - length(e) Browse[1] debug: names - colnames(X) Browse[1] debug: rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) Browse[1] debug: y - y[2:n] - rho * y[1:(n - 1)] Browse[1] debug: X - X[2:n, ] - rho * X[1:(n - 1), ] Browse[1] debug: mod - lm(y ~ X - 1) Browse[1] Error in model.frame.default(formula = y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') John Fox [EMAIL PROTECTED] 17/06/2008 18:49 To [EMAIL PROTECTED] cc r-help@r-project.org Subject RE: [R] Problems with Cochrane-Orcutt procedures Dear Tolga, That's a little more information, but because the code seems to work for me on other data (though no longer the message dispatch), I can't say what produces the error. I guess that if you can't debug this yourself, you'll have to share the data (generally a good idea in any event). mod - lm(Hartnagel[,5] ~ Hartnagel[,7]) mod Call: lm(formula = Hartnagel[, 5] ~ Hartnagel[, 7]) Coefficients: (Intercept) Hartnagel[, 7] -85.1117 0.2126 cochrane.orcutt.lm(mod) $coefficients (Intercept) Hartnagel[, 7] 57.05592426 0.04015223 $cov (Intercept) Hartnagel[, 7] (Intercept)1226.739528 -1.381235045 Hartnagel[, 7] -1.3812350.001713204 $sigma [1] 14.00277 $rho [1] 0.7835837 attr(,class) [1] cochrane.orcutt Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: June-17-08 1:17 PM To: John Fox Cc: r-help@r-project.org; [EMAIL PROTECTED] Subject: RE: [R] Problems with
Re: [R] Problems with Cochrane-Orcutt procedures
Aha ! I think this is it. You are using a data frame, and I was using zoo for the regrCMS object. When I cast it into a data frame, it then works ! I guess it would be cool to understand why it doesn't work as a zoo object, but no matter. Thanks John, Tolga regrCMS-as.data.frame(regrCMS) regrCMS a b 09/20/07 26.084 28.40 09/21/07 22.458 28.90 09/24/07 21.297 29.25 09/25/07 21.733 29.40 09/26/07 21.319 28.75 09/27/07 22.507 28.85 09/28/07 19.571 28.90 10/01/07 21.961 29.00 10/02/07 21.729 28.45 10/03/07 21.241 28.00 10/04/07 21.253 28.55 10/05/07 21.401 27.25 10/10/07 20.923 25.70 10/11/07 20.401 25.25 10/12/07 20.122 24.35 10/15/07 19.225 26.35 10/16/07 18.759 27.15 10/17/07 18.413 26.85 10/18/07 18.960 27.75 10/19/07 18.643 28.65 10/22/07 17.829 28.35 10/23/07 17.835 28.60 10/24/07 17.335 29.15 10/25/07 17.971 29.05 10/26/07 16.205 28.60 10/29/07 16.722 28.40 10/30/07 16.772 28.40 10/31/07 17.127 27.05 11/01/07 15.328 27.85 11/02/07 17.088 28.15 regrCMSlm-lm(regrCMS[,1]~regrCMS[,2]) summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: Min 1Q Median 3Q Max -4.2668 -1.8272 -0.1752 1.6364 6.4365 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 16.92553 10.21538 1.6570.109 regrCMS[, 2] 0.095840.36477 0.2630.795 Residual standard error: 2.436 on 28 degrees of freedom Multiple R-squared: 0.00246,Adjusted R-squared: -0.03317 F-statistic: 0.06904 on 1 and 28 DF, p-value: 0.7947 cochrane.orcutt.lm(regrCMSlm) $coefficients (Intercept) regrCMS[, 2] 23.5679065 -0.1784187 $cov (Intercept) regrCMS[, 2] (Intercept)60.449366 -2.14491371 regrCMS[, 2] -2.144914 0.07676436 $sigma [1] 1.081036 $rho [1] 0.7208652 attr(,class) [1] cochrane.orcutt John Fox [EMAIL PROTECTED] 17/06/2008 19:30 To [EMAIL PROTECTED] cc r-help@r-project.org Subject RE: [R] Problems with Cochrane-Orcutt procedures Dear Tolga, I'm afraid that your data work fine for me: regrCMSlm - lm(regrCMS[,1] ~ regrCMS[,2]) cochrane.orcutt.lm(regrCMSlm) $coefficients (Intercept) regrCMS[, 2] 23.5679065 -0.1784187 $cov (Intercept) regrCMS[, 2] (Intercept)60.449366 -2.14491371 regrCMS[, 2] -2.144914 0.07676436 $sigma [1] 1.081036 $rho [1] 0.7208652 attr(,class) [1] cochrane.orcutt I'm using R 2.7.0 on Windows Vista; I put your data in a standard data frame; and, as I said, the method dispatch no longer works, so I called Cochrane.orcutt.lm() directly. John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: June-17-08 2:13 PM To: John Fox Cc: r-help@r-project.org Subject: Re: [R] Problems with Cochrane-Orcutt procedures Sure, of course. And thanks for looking John. Here is the entire data: regrCMS a b 09/20/07 26.084 28.40 09/21/07 22.458 28.90 09/24/07 21.297 29.25 09/25/07 21.733 29.40 09/26/07 21.319 28.75 09/27/07 22.507 28.85 09/28/07 19.571 28.90 10/01/07 21.961 29.00 10/02/07 21.729 28.45 10/03/07 21.241 28.00 10/04/07 21.253 28.55 10/05/07 21.401 27.25 10/10/07 20.923 25.70 10/11/07 20.401 25.25 10/12/07 20.122 24.35 10/15/07 19.225 26.35 10/16/07 18.759 27.15 10/17/07 18.413 26.85 10/18/07 18.960 27.75 10/19/07 18.643 28.65 10/22/07 17.829 28.35 10/23/07 17.835 28.60 10/24/07 17.335 29.15 10/25/07 17.971 29.05 10/26/07 16.205 28.60 10/29/07 16.722 28.40 10/30/07 16.772 28.40 10/31/07 17.127 27.05 11/01/07 15.328 27.85 11/02/07 17.088 28.15 regrCMSlm-lm(regrCMS[,1]~regrCMS[,2]) summary(regrCMSlm) Call: lm(formula = regrCMS[, 1] ~ regrCMS[, 2]) Residuals: 09/20/07 10/01/07 10/12/07 10/23/07 11/02/07 6.4365 2.2112 0.3183 -2.2462 -2.5355 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 16.92553 10.21538 1.6570.109 regrCMS[, 2] 0.095840.36477 0.2630.795 Residual standard error: 2.436 on 28 degrees of freedom Multiple R-squared: 0.00246,Adjusted R-squared: -0.03317 F-statistic: 0.06904 on 1 and 28 DF, p-value: 0.7947 cochrane.orcutt(regrCMSlm) debugging in: cochrane.orcutt.lm(regrCMSlm) debug: { X - model.matrix(mod) y - model.response(model.frame(mod)) e - residuals(mod) n - length(e) names - colnames(X) rho - sum(e[1:(n - 1)] * e[2:n])/sum(e^2) y - y[2:n] - rho * y[1:(n - 1)] X - X[2:n, ] - rho * X[1:(n - 1), ] mod - lm(y ~ X - 1) result - list() result$coefficients - coef(mod) names(result$coefficients) - names summary - summary(mod, corr = F) result$cov - (summary$sigma^2) * summary$cov.unscaled dimnames(result$cov) - list(names, names) result$sigma - summary$sigma result$rho - rho
Re: [R] Reshape or Stack? (To produce output as columns)
Dear all, Many thanks for the suggestions put forward. I've decided to go with the 'melt' command from the 'reshape' library, as this seems to run the quickest. I do have a couple of questions however, regarding the use of the 'melt' command. Below are the last few lines of the 'melted' data. The first column shows the latitude values (the row names of the former data frame), the second column are the longitude values (the column names of the former data frame) and the third column shows the actual values (-99.9 is correct in this case). 85.25719179.75 -99.9 85.75719179.75 -99.9 86.25719179.75 -99.9 86.75719179.75 -99.9 87.25719179.75 -99.9 87.75719179.75 -99.9 88.25719179.75 -99.9 88.75719179.75 -99.9 89.25719179.75 -99.9 89.75719179.75 -99.9 As you can see, each value in the 'latitude' column is followed by '719'. As far as I can tell, this value seems to represent the number of times the value is repeated in this column (I could be wrong though). Remember that this is the end of a fairly sizeable dataset - these 'surplus' figures range from '1' further up the column to '719' as shown here. How do I go about removing these values? Also, I hope to add headings to these columns (Latitude, Longitude, Value). The best I've been able to manage so far is by using the 'names' command, however this only allows me to add headings to the second and third columns. Below is what happens when I've tried to add headings to all three: names(melted) - c(Latitude, Longitude, Value) Error in names-.default(`*tmp*`, value = c(Latitude, Longitude, : 'names' attribute [3] must be the same length as the vector [2] If anyone is able to offer any advice and suggestions as to how I might overcome these issues, then I'd be very grateful. Many thanks again, Steve Date: Tue, 17 Jun 2008 09:09:06 -0500 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [R] Reshape or Stack? (To produce output as columns) CC: r-help@r-project.org On Tue, Jun 17, 2008 at 5:59 AM, Steve Murray wrote: Dear all, I have used 'read.table' to create a data frame of 720 columns and 360 rows (and assigned this to 'Jan'). The row and column names are numeric: columnnames - sprintf(%.2f, seq(from = -179.75, to = 179.75, length = 720)). rnames - sprintf(%.2f, seq(from = -89.75, to = 89.75, length = 360)) colnames(Jan) - columnnames rownames(Jan) - rnames A sample of the data looks like this: head(Jan) -179.75 -179.25 -178.75 -178.25 -177.75 -177.25 -176.75 -176.25 -175.75 -89.75 -56.9 -64.256.2 -90.056.9 -29.0 -91.0 34.0 -9.1 -89.2537.919.3 -0.4 -12.3 -11.8 -92.1 9.2 -23.5 -0.2 -88.7547.4 3.1 -47.446.434.2 6.1 -41.344.7 -10.3 -88.25 -20.334.5 -67.3 -99.937.9 -9.317.7 -17.2 63.4 -87.75 -46.447.412.4 -48.3 9.3 -33.838.110.8 -34.1 -87.25 -48.410.3 -89.3 -33.0 -1.1 -33.181.2-8.3 -47.2 I'm hoping to get the whole dataset into the form of columns, so that, for example, the first row (as shown above) would look like this: Latitude Longitude Value -89.75 -179.75 -56.9 -89.75 -179.25 -64.2 -89.75 -178.75 56.2 -89.75 -178.25 -90.0 -89.75 -177.75 56.9 -89.75 -177.25 -29.0 -89.75 -176.75 -91.0 -89.75 -176.25 34.0 -89.75 -175.75 -9.1 As you can see, this would require the repeated printing of the the row and column names (in this case '-89.75') - so it's not just a case of rearranging the data, but creating 'more' data too. I've tried to achieve this using 'reshape' and 'stack' (their help files and after looking through the mailing archives), but I'm obviously doing something wrong. For reshape, I'm getting errors relating to the commands I enter, and for stack, I can only produce two columns from my data (with the additional 3rd column being a row count). In any case, these two columns refer to the wrong values (it's producing output in the form of: row count number, Longitude, Value). This is pretty easy with the reshape package: install.packages(reshape) library(reshape) jan_long - melt(Jan) You can find out more at http://had.co.nz/reshape Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] read.spss {foreign} doesn't work over network?
I'm unable to open an SPSS file over my network. If I copy it to my local C:/ drive I can read it. I saved the command (in a crib sheet text file) in order to avoid all the typing, so I'm pretty sure I've done it before. I verified that the file I'm trying to read is OK. This is what happens: SurveyData - read.spss(P:/Jobs/6015.Orange.Rapid.Survey/SurveyData/4.ProcessedData/D elivery4/mrb_delivery.sav, use.value.labels=TRUE, max.value.labels=Inf, to.data.frame=TRUE) Error in read.spss(P:/Jobs/6015.Orange.Rapid.Survey/SurveyData/4.ProcessedData/D elivery4/mrb_delivery.sav, : unable to open file SurveyData - read.spss(C:/Data/R/mrb_delivery.sav, use.value.labels=TRUE, max.value.labels=Inf, to.data.frame=TRUE) dimnames(SurveyData) [[2]] #Variable (column) names [1] LANG SAMPNROUTE_NU BLOCK_NU ROUTETOD [7] DIRECTIO ASSIGN TRIPID_N HNAMEHPHONE HADDRESS [13] HCITYHSTATE HZIP HAV_STAT H_XCORD H_YCORD [19] H_TAZOPURPO_OPURP OCODEONAMEOGAVEHOM [25] OADDRESS OXSTRT1 OXSTRT2 OCITYOZIP OAV_STAT [31] O_XCORD O_YCORD O_TAZGETTOO_GETTO BUS1 [37] BUS2 BUS3 BUS4 BOARD1 BOARD2 DEPART1 [43] DEPART2 DPURPO_DPURP DCODEDNAMEDGAVEHOM [49] DADDRESS DXSTRT1 DXSTRT2 DCITYDZIP DAV_STAT [55] D_XCORD D_YCORD D_TAZGETOFF O_GETOFF FARE [61] DISCOUNT EMPDISC EMPPAY FREQ DISABLE HHVEH [67] VEHAVAIL HHSIZINCOME AGE KIDCORED BLOCK [73] DIRECT_A BUS_ON BUS_ONS BUS_ONG BAV_STAT BAV_ADD [79] B_TAZB_XCORD B_YCORD BUS_OFF BUS_OFFS BUS_OFFG [85] FAV_STAT FAV_ADD F_TAZF_XCORD F_YCORD BUS_OF_A [91] LTFACTOR BUSREPFA ADDWEIGH RESPONSE VEHFACT FINWGT [97] EXPFACTO EXPWGT Am I just loopy in thinking I've ever read this directly from the network drive? Did I do something stupid that broke read.spss? version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 7.0 year 2008 month 04 day22 svn rev45424 language R version.string R version 2.7.0 (2008-04-22) installed.packages() Package LibPath Version abind abind C:/PROGRA~1/R/R-27~1.0/library 1.1-0 acepack acepack C:/PROGRA~1/R/R-27~1.0/library 1.3-2.2 akima akima C:/PROGRA~1/R/R-27~1.0/library 0.5-1 ape ape C:/PROGRA~1/R/R-27~1.0/library 2.2 base base C:/PROGRA~1/R/R-27~1.0/library 2.7.0 boot boot C:/PROGRA~1/R/R-27~1.0/library 1.2-33 car car C:/PROGRA~1/R/R-27~1.0/library 1.2-8 chron chron C:/PROGRA~1/R/R-27~1.0/library 2.3-23 class class C:/PROGRA~1/R/R-27~1.0/library 7.2-42 cluster cluster C:/PROGRA~1/R/R-27~1.0/library 1.11.10 coda coda C:/PROGRA~1/R/R-27~1.0/library 0.13-2 codetools codetools C:/PROGRA~1/R/R-27~1.0/library 0.2-1 coin coin C:/PROGRA~1/R/R-27~1.0/library 0.6-9 colorspacecolorspaceC:/PROGRA~1/R/R-27~1.0/library 0.95 DAAG DAAG C:/PROGRA~1/R/R-27~1.0/library 0.97 datasets datasets C:/PROGRA~1/R/R-27~1.0/library 2.7.0 DesignDesignC:/PROGRA~1/R/R-27~1.0/library 2.1-1 dynlm dynlm C:/PROGRA~1/R/R-27~1.0/library 0.2-0 e1071 e1071 C:/PROGRA~1/R/R-27~1.0/library 1.5-18 Ecdat Ecdat C:/PROGRA~1/R/R-27~1.0/library 0.1-5 effects effects C:/PROGRA~1/R/R-27~1.0/library 1.0-12 ellipse ellipse C:/PROGRA~1/R/R-27~1.0/library 0.3-5 fCalendar fCalendar C:/PROGRA~1/R/R-27~1.0/library 270.75 fEcofin fEcofin C:/PROGRA~1/R/R-27~1.0/library 270.73 flexmix flexmix C:/PROGRA~1/R/R-27~1.0/library 2.1-0 foreign foreign C:/PROGRA~1/R/R-27~1.0/library 0.8-25 fortunes fortunes C:/PROGRA~1/R/R-27~1.0/library 1.3-4 fSeries fSeries C:/PROGRA~1/R/R-27~1.0/library 260.72 fUtilitiesfUtilitiesC:/PROGRA~1/R/R-27~1.0/library 270.73 gee gee C:/PROGRA~1/R/R-27~1.0/library 4.13-13 graphics graphics C:/PROGRA~1/R/R-27~1.0/library 2.7.0 grDevices grDevices C:/PROGRA~1/R/R-27~1.0/library 2.7.0 grid grid C:/PROGRA~1/R/R-27~1.0/library 2.7.0 Hmisc Hmisc C:/PROGRA~1/R/R-27~1.0/library 3.4-3 ipred ipred
Re: [R] How to control height of abline
check this: x - rnorm(200) dd - density(x) plot(dd) ind - seq(100, 400, len = 6) arrows(dd$x[ind], 0, dd$x[ind], dd$y[ind] - 0.015, length = 0.2) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm Quoting mogra [EMAIL PROTECTED]: I use plot to get the density curve and then I use abline(v=g$V2, col = 3 ) to get the vertical line for specific point on x axis. Goal : I want very small lines at the bottom on the x axis , if possible in the arrow forms instead of vertical lines on the whole graph. Thanks a lot. -- View this message in context: http://www.nabble.com/How-to-control-height-of-abline-tp17932528p17932528.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sweave: problem with usepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave}
R users, I'm at a loss with a problem considering running .tex files produced by Sweave. When I run (R 2.7.0): --- #Taken from ?Sweave testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils) ## enforce par(ask=FALSE) options(device.ask.default=FALSE) ## create a LaTeX file Sweave(testfile) --- I get a .tex file: % -*- mode: noweb; noweb-default-code-mode: R-mode; -*- \documentclass[a4paper]{article} \title{A Test File} \author{Friedrich Leisch} \usepackage{a4wide} \usepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave} \begin{document} \maketitle A simple example that will run in any S engine: The integers from 1 to 10 are \begin{Schunk} \begin{Soutput} [1] 1 2 3 4 5 6 7 8 9 10 \end{Soutput} \end{Schunk} We can also emulate a simple calculator: …etc. -- When I run this file Latex Pdf using MikTeX 2.7 and TeXnicCenter I get an error message. I know that it has something to do with \usepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave} and '~' sign. How can I get pass this error? Best Lauri __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to control height of abline
I use matplot to get the density curve and then I use abline(v=g$V2, col = 3 ) to get the vertical line. Goal : I want very small lines at the bottom on the x axis , if possible in the arrow forms instead of vertical lines on the whole graph. Thanks a lot. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to control height of abline
Dear Satam Just take a look at Dimitris Rizopoulos' suggestion at http://www.nabble.com/How-to-control-height-of-abline-tp17932528p17932528.html HTH, Jorge On Tue, Jun 17, 2008 at 2:15 PM, sata pinal [EMAIL PROTECTED] wrote: I use matplot to get the density curve and then I use abline(v=g$V2, col = 3 ) to get the vertical line. Goal : I want very small lines at the bottom on the x axis , if possible in the arrow forms instead of vertical lines on the whole graph. Thanks a lot. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to control height of abline
I'm sorry Sata, I typed your name wrongly in the my previous email. My apologizes. Thanks, Jorge On Tue, Jun 17, 2008 at 3:19 PM, Jorge Ivan Velez [EMAIL PROTECTED] wrote: Dear Satam Just take a look at Dimitris Rizopoulos' suggestion at http://www.nabble.com/How-to-control-height-of-abline-tp17932528p17932528.html HTH, Jorge On Tue, Jun 17, 2008 at 2:15 PM, sata pinal [EMAIL PROTECTED] wrote: I use matplot to get the density curve and then I use abline(v=g$V2, col = 3 ) to get the vertical line. Goal : I want very small lines at the bottom on the x axis , if possible in the arrow forms instead of vertical lines on the whole graph. Thanks a lot. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sweave: problem withusepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave}
Thank you for your answer. Unfortunately I don't have administrator rights to my computer (company's PC), so I'm looking for some other solution. Cheers, Lauri 2008/6/17 Scillieri, John [EMAIL PROTECTED]: Try moving your R directory out of the C:\Program Files directory. I ended up setting up a C:\programs\ and putting all my unix-happy programs (R, latex, etc) there to ensure path spaces don't screw me up when running under windows. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lauri Nikkinen Sent: Tuesday, June 17, 2008 3:08 PM To: r-help@r-project.org Subject: [R] Sweave: problem withusepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave} R users, I'm at a loss with a problem considering running .tex files produced by Sweave. When I run (R 2.7.0): --- #Taken from ?Sweave testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils) ## enforce par(ask=FALSE) options(device.ask.default=FALSE) ## create a LaTeX file Sweave(testfile) --- I get a .tex file: % -*- mode: noweb; noweb-default-code-mode: R-mode; -*- \documentclass[a4paper]{article} \title{A Test File} \author{Friedrich Leisch} \usepackage{a4wide} \usepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave} \begin{document} \maketitle A simple example that will run in any S engine: The integers from 1 to 10 are \begin{Schunk} \begin{Soutput} [1] 1 2 3 4 5 6 7 8 9 10 \end{Soutput} \end{Schunk} We can also emulate a simple calculator: ..etc. -- When I run this file Latex à Pdf using MikTeX 2.7 and TeXnicCenter I get an error message. I know that it has something to do with \usepackage{C:/PROGRA~1/R/R-27~1.0/share/texmf/Sweave} and '~' sign. How can I get pass this error? Best Lauri __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail and any attachments are confidential, may contain legal, professional or other privileged information, and are intended solely for the addressee. If you are not the intended recipient, do not use the information in this e-mail in any way, delete this e-mail and notify the sender. CEG-IP1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x labels out of Quartz canvas
Thanks a lot! I looked at the document. It shows how to set the size of the canvas, but not how to change it *after* plotting. Now I start with a bigger canvas, but the plot is scaled into it, so I am having the same problem again :( I keep on reading tough. Thanks a lot for your help! -Memo Prof Brian Ripley wrote: You do this by adjusting the margin sizes. Can I suggest you read 'An Introduction to R', which has a section on the layout of graphics (perhaps the only area in which it is comprehensive). On Mon, 16 Jun 2008, MeMooMeM wrote: Hi R world, I am such a newbie, with only 4-5 days of R experience. I did a search in forum history but couldn't find a solution to my problem... Sorry if it's obvious: I managed to draw a barplot (yey!) with xlabels of 'long' names (filenames, to be particular). To make them readable, I place them perpendicular to the axis (las=2). When I do that, however, these names don't fit inside the Quartz window and they are truncated. Is there a way to change the Quartz window size after plotting (or, as an alternative, to scale the plot down so it fits in there) ? Thanks a lot! -Memo PS: This is the very first of my zillion of questions! -- View this message in context: http://www.nabble.com/x-labels-out-of-Quartz-canvas-tp17872830p17872830.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/x-labels-out-of-Quartz-canvas-tp17872830p17935598.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] constrOptim with method = L-BFGS-B
I believe that 'optim' will not accept equality constraints. However, you do not need the generality of 'optim' to minimize a quadratic function with boundary conditions and one equality condition. This type of problem is called quadratic programming, and RSiteSearch(quadratic programming, fun) just returned 29 hits for me. The first 3 cite functions in the LowRankQP, kernlab, and quadprog packages. I don't know if any of these will solve your problem, but I suspect that at least one might. If not, can you recast the problem to remove the equality constraint? If the above does not work for you, I suggest you try a much simpler version, e.g., with 'mat' = a 3 x 3 array with one inequality and one equality, as suggested in the famous book by Polya on How to Solve It (http://en.wikipedia.org/wiki/How_to_Solve_It). This has the added advantage of giving you a simpler example to send to this list if you can't make it work. You are to be commended for providing a self-contained example. Unfortunately, your example is so large that it is slightly intimidating. A simpler example might elicit more (and more useful) replies -- if it doesn't lead you to the solution, as Polya suggested that it might. Hope this helps, Spencer lhaba wrote: Hi, i need to minimize a quadratic function with boundary condidtions and one equality condition. In order to do that i converted the equality constraint into 2 inequality constaints and passed everything cia constrOptim, as the manual said: everything included in the ... will be passed to Optim that will pass it back to fn in case it does not need it. My code is the following: mat - array( c(0.0001088799073581, 0.136029502036, 0.060430384243, 0.847097879033, 0.115053365822, 0.216245975292, 0.483253391811, 0.787580901352, 0.186474817658, 0.312260571354, 0.217594093734, 0.536298150897, 0.166202592455, 0.451975061637, -0.120364862228, 0.497117714376, 0.136029502036, 0.0001537319301276, 0.226518408080, 0.591480002102, 0.797128619950, 0.091332643423, 0.693354260457, 0.825217915015, 0.22917269, 0.297662414650, 0.334443258658, 0.273254534933, 0.202062301763, 0.026260702295, 0.558975248740, 0.953647537111, 0.060430384243, 0.226518408080, 0.0005971325756834, -0.762583321100,-0.246005202071,-0.300982253054, 0.299178429478, 0.135672602503, 0.0001735431064391, -0.133347388414,0.0001387582890571, 0.964898243724, -0.149571346672,0.104437939143, 0.0001246900353191, -0.171884354549, 0.847097879033, 0.591480002102, -0.762583321100, 0.0004968467836203, 0.0002303499425964, 0.992731601466, 0.0002685466918035, 0.0002580180069951, 0.725833959653, 0.525639940758, 0.0001785049461665, 0.0001781339191317, 0.597631329497, 0.201160486244, 0.0002582267884874, 0.0002473268250781, 0.115053365822, 0.797128619950, -0.246005202071, 0.0002303499425964, 0.0002945009393242, -0.426583313588, 0.0002067711081561, 0.0002695894499975, 0.0001312519434236, -0.079156628396,0.0001423655606105, 0.044733483182, 0.303832556655, 0.577624190434, 0.0001193435284164, 0.0002422477575812, 0.216245975292, 0.091332643423, -0.300982253054, 0.992731601466, -0.426583313588,0.0001641146317929, 0.311621614693, -0.147821020927,-0.767394607354, 0.619936562782, -0.306228761064,0.0001495752154579, 0.389317919640, -0.714551280935,-0.564616194935, 0.384367900903, 0.483253391811, 0.693354260457, 0.299178429478, 0.0002685466918035, 0.0002067711081561, 0.311621614693, 0.0003176493360736, 0.0002575792630182, 0.0001371966488704, 0.436833885846, 0.0001442516276721, 0.0001075447728937, 0.371155448252, 0.475873370276, 0.0002162409964174, 0.0002870514043081, 0.787580901352, 0.825217915015, 0.135672602503, 0.0002580180069951, 0.0002695894499975, -0.147821020927, 0.0002575792630182, 0.0006217963583393, 0.0002368375072233, 0.078625467985, 0.0002054774387807, -0.066572248626, 0.485854317294, 0.0002802199677114, 0.0001676465030622, 0.0003028775764026, 0.186474817658, 0.22917269, 0.0001735431064391, 0.725833959653, 0.0001312519434236, -0.767394607354, 0.0001371966488704, 0.0002368375072233, 0.0004475645060339, -0.030389778729,0.0001706183643212, -0.017789896670, 0.722657436668, 0.0001664088523103, 0.0001220193496918, 0.0001641280878243, 0.312260571354,
[R] some R code of linear mixed model
Hello everyone: I have some quesions about the R code for linear mixed model,hope some one can give me some hints,thanks a lot~ Say: we have A B C three factors (i)A is fixed ,B and C are random,and B is nested in C,so the R code for this case would be: case1-lme(y~A+B+C+..,random=~B|C) where B|C actually mean B is nested in C, is it correct? (ii)and if I update the case as: updatedcase1-update(case1,random=~1|C), did I just remove the random effect of B, and only random effect of C left in the model? is it correct? (iii)A ,B,is fixed ,but C is random,no nested case,how am I gonna write the R code,since lme(y~A+B+C+.,random=~C) lead to error, (iv)for the case1,if I wirte this updatedcase2-update(case1,random=B-1|C) where,B-1|C,what this syntax stand for in R? thank you guys very much~ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reshape or Stack? (To produce output as columns)
On Tue, Jun 17, 2008 at 1:47 PM, Steve Murray [EMAIL PROTECTED] wrote: Dear all, Many thanks for the suggestions put forward. I've decided to go with the 'melt' command from the 'reshape' library, as this seems to run the quickest. I do have a couple of questions however, regarding the use of the 'melt' command. Below are the last few lines of the 'melted' data. The first column shows the latitude values (the row names of the former data frame), the second column are the longitude values (the column names of the former data frame) and the third column shows the actual values (-99.9 is correct in this case). 85.25719179.75 -99.9 85.75719179.75 -99.9 86.25719179.75 -99.9 86.75719179.75 -99.9 87.25719179.75 -99.9 87.75719179.75 -99.9 88.25719179.75 -99.9 88.75719179.75 -99.9 89.25719179.75 -99.9 89.75719179.75 -99.9 As you can see, each value in the 'latitude' column is followed by '719'. As far as I can tell, this value seems to represent the number of times the value is repeated in this column (I could be wrong though). Remember that this is the end of a fairly sizeable dataset - these 'surplus' figures range from '1' further up the column to '719' as shown here. How do I go about removing these values? Also, I hope to add headings to these columns (Latitude, Longitude, Value). The best I've been able to manage so far is by using the 'names' command, however this only allows me to add headings to the second and third columns. Below is what happens when I've tried to add headings to all three: names(melted) - c(Latitude, Longitude, Value) Error in names-.default(`*tmp*`, value = c(Latitude, Longitude, : 'names' attribute [3] must be the same length as the vector [2] If anyone is able to offer any advice and suggestions as to how I might overcome these issues, then I'd be very grateful. It sounds like something is going wrong with the melting. Could you please include the output of str(original data frame), and str(melted)? (Or even better a small version of your data created with dput) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error
My code seems to break out with error below for every 1000 files it processes. Then I re-run from the last file where it errored out and it runs without any bugs. Any ideas what might cause error below? Error in match(x, table, nomatch = 0) : formal argument nomatch matched by multiple actual arguments -- View this message in context: http://www.nabble.com/Error-tp17936173p17936173.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Build a R into a single static library on windows?
Hi R users, I've been developing a C++ library that depends on R through R.dll. The current way is to have R directories somewhere and have R_HOME pointing to it. This works. But it's inconvenient when deploying this library since the whole R distribution has to be deployed with it. It would be very nice if there is some way to build R into a single static library that any C/C++ program can just link to it. I searched on Google and read on some R Internals manual, and it looks to me like a hard task since most of R functions are not written in C and hence cannot be statically linked. Just wonder if anyone has such experience? Any suggestion is greatly appreciated. Thanks! Best Regards, Zehao - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.