Re: [R] Algorythmic Question on Array Filtration
This will determine where the overlaps are and delete them. You can add some more code to determine which ones you want to delete. > # add the 5ppm to the dataframe > x$lower <- x$Mass * (1 - 5e-6) > x$upper <- x$Mass * (1 + 5e-6) > # create a matrix for determining overlap by adding 1 at the lower value of a > row > # and substracting 1 at the upper value. > overlap <- rbind( + cbind(index=seq(nrow(x)), value=x$lower, oper=1), + cbind(index=seq(nrow(x)), value=x$upper, oper=-1)) > # sort in 'value' order to determine overlap > overlap[] <- overlap[order(overlap[,'value'], overlap[, 'oper']),] > # 'qsize should be 0/1 if no overlap > overlap <- cbind(overlap, qsize=cumsum(overlap[, 'oper'])) > # find the qsize > 1 indicating overlap and use the index of that one and the > one > # after as the ones to delete. You could add code to determine which one to > keep > o.index <- which(overlap[,'qsize'] > 1) > # determine the indices to delete > i.delete <- unique(c(overlap[o.index,'index'], overlap[o.index+1, 'index'])) > # create the new matrix with overlaps deleted > new.x <- x[-i.delete,] > > > > head(new.x,10) Mass Intensitylowerupper 1 304.9117 35595.780 304.9102 304.9132 2 305.1726 18760.413 305.1711 305.1741 3 311.0636 24047.307 311.0620 311.0652 4 312.9303 12886.216 312.9287 312.9319 9 316.9118 5908.166 316.9102 316.9134 13 318.0114 37929.855 318.0098 318.0130 14 318.9274 27883.295 318.9258 318.9290 15 318.9889 4496.716 318.9873 318.9905 16 321.2784 3893.165 321.2768 321.2800 17 326.1166 23745.851 326.1150 326.1182 On 7/14/07, Johannes Graumann <[EMAIL PROTECTED]> wrote: > John Kane wrote: > Thanks for your time. > > Please find a small example below - the real data is MUCH bigger. > If you look at rows 5 and 6 of this and calculate the mass precision window > I have to deal with (5 ppm), you'll find the following: > > Row Lower 5ppm MassHigher 5ppm Intensity > 5 312.9419312.9435312.945120236.181 > 6 312.9422312.9438312.945414404.502 > > The precision windows here obviously overlap and I need to get rid of one of > them, which in this case should be row6, since it has the lower intensity > associated with it. > > For now I resort to doing an intensity sort and descending into the list > populate a fresh data.frame with entries that do not have any overlap, > skipping those that do. If somebody has any more sound ideas, I'd > appreciate to hear about them. > > Thanks, Joh > > MassIntensity > 304.9117 35595.780 > 305.1726 18760.413 > 311.0636 24047.307 > 312.9303 12886.216 > 312.9435 20236.181 > 312.9438 14404.502 > 313.1763 61033.830 > 313.1766 50788.418 > 316.9118 5908.166 > 317.2805 14084.841 > 317.2833 25603.689 > 317.2837 22866.578 > 318.0114 37929.855 > 318.9274 27883.295 > 318.9889 4496.716 > 321.2784 3893.165 > 326.1166 23745.851 > 327.2894 5318.226 > 328.8852 60934.030 > 329.1517 31985.486 > 331.0426 14883.231 > 332.0268 55126.078 > 332.2798 47364.519 > 333.2813 11423.807 > 337.1990 5330.360 > 339.2144 38450.804 > 339.2867 4065.709 > 340.9561 54101.844 > 340.9770 28172.160 > 345.0583 17945.025 > 345.0583 17877.900 > 347.1742 7359.428 > 347.2407 204792.999 > 353.2302 87864.153 > 353.2302 129691.696 > 363.0161 20453.771 > 363.0943 19481.234 > 363.2142 9238.244 > 363.2315 23323.527 > 363.2533 20039.607 > 363.2534 22068.718 > 364.8918 16857.488 > 364.9368 9527.642 > 366.9029 18174.233 > 373.2197 7730.009 > 385.1147 27907.070 > 385.1148 19383.655 > 393.2913 11860.719 > 396.9074 10793.823 > 400.8792 10750.249 > 402.8729 12411.966 > 407.2771 11270.566 > 442.8689 18101.972 > 442.8697 10671.199 > 447.3470 35927.046 > 449.2347 6959.247 > 456.9339 50402.820 > 461.1670 8636.998 > 461.1670 8151.706 > 473.2985 13782.291 > 490.9224 18510.760 > > > I think we need a bit more information and perhaps a > > small example data set to see what you want. > > > > I am not familiar with term mass window. Is this a > > confidence interval around the mass value? > > > > > > --- Johannes Graumann <[EMAIL PROTECTED]> > > wrote: > > > >> Dear All, > >> > >> I have a data frame with the columns "Mass" and > >> "Intensity" (this is mass > >> spectrometry stuff). Each of the mass values gives > >> rise to a mass window of > >> 5 ppm around the individual mass (from mass - > >> mass/1E6*5 to mass + > >> mass/1E5*5). I need to filter the array such that in > >> case these mass > >> windows overlap I retain the mass/intensity pair > >> with the highest > >> intensity. > >> I apologize for this question, but I have no formal > >> IT education and would > >> value any nudges toward favorable algorithmic > >> solutions highly. > >> > >> Thanks for any help, > >> > >> Joh > >> > >> __ > >> R-help@stat.math.ethz.ch mailing list > >> https://stat.ethz.ch/mailman/listinfo/r-help > >> PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> a
Re: [R] Drawing rectangles in multiple panels
Suppose ri were already defined as in the example below. Then panel.qrect is a bit harder to define although with work its possible as shown below: rectInfo <- list(matrix(runif(4), 2, 2), matrix(runif(4), 2, 2), matrix(runif(4), 2, 2)) ri <- function(x, y, ..., rect.info) { ri <- rect.info[[packet.number()]] panel.rect(ri[1, 1], ri[1, 2], ri[2, 1], ri[2, 2], col = "grey86", border = NA) panel.xyplot(x, y, ...) } panel.qrect <- function(rect.info) { function(x, y, ...) { environment(ri) <- environment() ### ri(x, y, ..., rect.info = rect.info) } } xyplot(runif(30) ~ runif(30) | gl(3, 10), panel = panel.qrect(rectInfo)) On 7/14/07, Stephen Tucker <[EMAIL PROTECTED]> wrote: > This is very interesting - but I'm not entirely clear on your last statement > though about how existing functions can cause problems with the scoping that > createWrapper() avoids... (but thanks for the tip). > > > --- Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > > Your approach of using closures is cleaner than that > > given below but just for comparison in: > > > > http://tolstoy.newcastle.edu.au/R/devel/06/03/4476.html > > > > there is a createWrapper function which creates a new function based > > on the function passed as its first argument by using the components > > of the list passed as its second argument to overwrite its formal > > arguments. For example, > > > > createWrapper <- function(FUN, Params) { > >as.function(c(replace(formals(FUN), names(Params), Params), body(FUN))) > > } > > > > library(lattice) > > > > rectInfo <- > >list(matrix(runif(4), 2, 2), > > matrix(runif(4), 2, 2), > > matrix(runif(4), 2, 2)) > > > > > > panel.qrect <- function(x, y, ..., rect.info) { > >ri <- rect.info[[packet.number()]] > >panel.rect(ri[1, 1], ri[1, 2], ri[2, 1], ri[2, 2], > > col = "grey86", border = NA) > >panel.xyplot(x, y, ...) > > } > > > > xyplot(runif(30) ~ runif(30) | gl(3, 10), > > panel = createWrapper(panel.qrect, list(rect.info = rectInfo))) > > > > The createWrapper approach does have an advantage in the situation > > where the function analogous to panel.qrect is existing since using > > scoping then involves manipulation of environments in the closure > > approach. > > > > On 7/11/07, Stephen Tucker <[EMAIL PROTECTED]> wrote: > > > In the Trellis approach, another way (I like) to deal with multiple > > pieces of > > > external data sources is to 'attach' them to panel functions through > > lexical > > > closures. For instance... > > > > > > rectInfo <- > > >list(matrix(runif(4), 2, 2), > > > matrix(runif(4), 2, 2), > > > matrix(runif(4), 2, 2)) > > > > > > panel.qrect <- function(rect.info) { > > > function(x, y, ...) { > > >ri <- rect.info[[packet.number()]] > > >panel.rect(ri[1, 1], ri[1, 2], ri[2, 1], ri[2, 2], > > > col = "grey86", border = NA) > > >panel.xyplot(x, y, ...) > > > } > > > } > > > > > > xyplot(runif(30) ~ runif(30) | gl(3, 10), > > > panel = panel.qrect(rectInfo)) > > > > > > ...which may or may not be more convenient than passing rectInfo (and > > perhaps > > > other objects if desired) explicitly as an argument to xyplot(). > > > > > > > > > --- Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > > > > > > > On 7/11/07, hadley wickham <[EMAIL PROTECTED]> wrote: > > > > > > A question/comment: I have usually found that the subscripts > > argument > > > > is > > > > > > what I need when passing *external* information into the panel > > > > function, for > > > > > > example, when I wish to add results from a fit done external to the > > > > trellis > > > > > > call. Fits[subscripts] gives me the fits (or whatever) I want to > > plot > > > > for > > > > > > each panel. It is not clear to me how the panel layout information > > from > > > > > > panel.number(), etc. would be helpful here instead. Am I correct? > > -- or > > > > is > > > > > > there a smarter way to do this that I've missed? > > > > > > > > > > This is one of things that I think ggplot does better - it's much > > > > > easier to plot multiple data sources. I don't have many examples of > > > > > this yet, but the final example on > > > > > http://had.co.nz/ggplot2/geom_abline.html illustrates the basic idea. > > > > > > > > That's probably true. The Trellis approach is to define a plot by > > > > "data source" + "type of plot", whereas the ggplot approach (if I > > > > understand correctly) is to create a specification for the display > > > > (incrementally?) and then render it. Since the specification can be > > > > very general, the approach is very flexible. The downside is that you > > > > need to learn the language. > > > > > > > > On a philosophical note, I think the apparent limitations of Trellis > > > > in some (not all) cases is just due to the artificial importance given > > > > to data frames as the one true container for data.
Re: [R] Drawing rectangles in multiple panels
On 7/14/07, Stephen Tucker <[EMAIL PROTECTED]> wrote: > > I wonder what kind of objects? Are there large advantages for allowing > lattice functions to operate on objects other than data frames - I > couldn't find any screenshots of flowViz but I imagine those objects > would probably be list of arrays and such? I tend to think of mapply() > [and more recently melt()], etc. could always be applied beforehand, > but I suppose that would undermine the case for having generic > functions to support the rich collection of object classes in R... There's a copy of a presentation at http://www.ficcs.org/meetings/ficcs3/presentations/DeepayanSarkar-flowviz.pdf and a (largish - 37M) vignette linked from http://bioconductor.org/packages/2.1/bioc/html/flowViz.html Neither of these really talk about the challenge posed by the size of the data. The data structure, as with most microarray-type experiments, is like a data frame, except that the response for every experimental unit is itself a large matrix. If we represented the GvHD data set (the one used in the examples) as a "long format" data frame that lattice would understand, it would have 585644 rows and 12 columns (8 measurements that are different for each row, and 4 phenotypic variables that are the same for all rows coming from a single sample). And this is for a smallish subset of the actual experiment. In practice, the data are stored in an environment to prevent unnecessary copying, and panel functions only access one data matrix at a time. -Deepayan > --- Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > > > On 7/11/07, hadley wickham <[EMAIL PROTECTED]> wrote: > > > > A question/comment: I have usually found that the subscripts argument > > is > > > > what I need when passing *external* information into the panel > > function, for > > > > example, when I wish to add results from a fit done external to the > > trellis > > > > call. Fits[subscripts] gives me the fits (or whatever) I want to plot > > for > > > > each panel. It is not clear to me how the panel layout information from > > > > panel.number(), etc. would be helpful here instead. Am I correct? -- or > > is > > > > there a smarter way to do this that I've missed? > > > > > > This is one of things that I think ggplot does better - it's much > > > easier to plot multiple data sources. I don't have many examples of > > > this yet, but the final example on > > > http://had.co.nz/ggplot2/geom_abline.html illustrates the basic idea. > > > > That's probably true. The Trellis approach is to define a plot by > > "data source" + "type of plot", whereas the ggplot approach (if I > > understand correctly) is to create a specification for the display > > (incrementally?) and then render it. Since the specification can be > > very general, the approach is very flexible. The downside is that you > > need to learn the language. > > > > On a philosophical note, I think the apparent limitations of Trellis > > in some (not all) cases is just due to the artificial importance given > > to data frames as the one true container for data. Now that we have > > proper multiple dispatch in S4, we can write methods that behave like > > traditional Trellis calls but work with more complex data structures. > > We have tried this in one bioconductor package (flowViz) with > > encouraging results. > > > > -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Send SMS out of R?
On 14 July 2007 at 21:37, Thomas Schwander wrote: | I use Windows XP Professional, R 2.5.1 and I have Blat to send eMails out of | R. Works perfect! Thank you for your help! | | | | Now I want to send an SMS out of R! Any idea how it could work? Could I send | an eMail to a mobile phone number? Obviously the same way: find a windows program that does the actual sending, and uses system() from R to talk to it. Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to remove effects (distance as a covariate) in linear model
Hello, I am struggling to remove the effect of distance in the similarities of species composition between sites with the similarities of temperature between sites. Example: i have 4 columns (a column : sites name, b: species similarities between the two sites, c: environmental similarities between the two sites, and d: distance between the two sites Site A & site B, 0.34, 0.12, 2meter site A & site C, 0.56,0.45, 0.5meter Sites B &C, 0.76, 0.21, 0.98meter Sites D &A, 0.56, 0.76, 1.5meter Sites D & B, 0.01, 0.34, 7meter Sites A & D, 0.98, 0.78, 2 meter (note: , represents column) Here i want to fit the data to a general linear model in which the similarities values of the temperature variables calculated for each sites pair will be the independent observations and the respective correlation coefficients of species similarities will be the dependent observation. But I could not figure out how to control the effects of distance between each sites pair. How can I calculate it in R? Could you please help me? Syan _ Missed the show? Watch videos of the Live Earth Concert on MSN. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Send SMS out of R?
Hi everyone, Now I read the posting guidelines again; COMPLETELY! ;-) I use Windows XP Professional, R 2.5.1 and I have Blat to send eMails out of R. Works perfect! Thank you for your help! Now I want to send an SMS out of R! Any idea how it could work? Could I send an eMail to a mobile phone number? Thank you Thomas [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Drawing rectangles in multiple panels
This is very interesting - but I'm not entirely clear on your last statement though about how existing functions can cause problems with the scoping that createWrapper() avoids... (but thanks for the tip). --- Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Your approach of using closures is cleaner than that > given below but just for comparison in: > > http://tolstoy.newcastle.edu.au/R/devel/06/03/4476.html > > there is a createWrapper function which creates a new function based > on the function passed as its first argument by using the components > of the list passed as its second argument to overwrite its formal > arguments. For example, > > createWrapper <- function(FUN, Params) { >as.function(c(replace(formals(FUN), names(Params), Params), body(FUN))) > } > > library(lattice) > > rectInfo <- >list(matrix(runif(4), 2, 2), > matrix(runif(4), 2, 2), > matrix(runif(4), 2, 2)) > > > panel.qrect <- function(x, y, ..., rect.info) { >ri <- rect.info[[packet.number()]] >panel.rect(ri[1, 1], ri[1, 2], ri[2, 1], ri[2, 2], > col = "grey86", border = NA) >panel.xyplot(x, y, ...) > } > > xyplot(runif(30) ~ runif(30) | gl(3, 10), > panel = createWrapper(panel.qrect, list(rect.info = rectInfo))) > > The createWrapper approach does have an advantage in the situation > where the function analogous to panel.qrect is existing since using > scoping then involves manipulation of environments in the closure > approach. > > On 7/11/07, Stephen Tucker <[EMAIL PROTECTED]> wrote: > > In the Trellis approach, another way (I like) to deal with multiple > pieces of > > external data sources is to 'attach' them to panel functions through > lexical > > closures. For instance... > > > > rectInfo <- > >list(matrix(runif(4), 2, 2), > > matrix(runif(4), 2, 2), > > matrix(runif(4), 2, 2)) > > > > panel.qrect <- function(rect.info) { > > function(x, y, ...) { > >ri <- rect.info[[packet.number()]] > >panel.rect(ri[1, 1], ri[1, 2], ri[2, 1], ri[2, 2], > > col = "grey86", border = NA) > >panel.xyplot(x, y, ...) > > } > > } > > > > xyplot(runif(30) ~ runif(30) | gl(3, 10), > > panel = panel.qrect(rectInfo)) > > > > ...which may or may not be more convenient than passing rectInfo (and > perhaps > > other objects if desired) explicitly as an argument to xyplot(). > > > > > > --- Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > > > > > On 7/11/07, hadley wickham <[EMAIL PROTECTED]> wrote: > > > > > A question/comment: I have usually found that the subscripts > argument > > > is > > > > > what I need when passing *external* information into the panel > > > function, for > > > > > example, when I wish to add results from a fit done external to the > > > trellis > > > > > call. Fits[subscripts] gives me the fits (or whatever) I want to > plot > > > for > > > > > each panel. It is not clear to me how the panel layout information > from > > > > > panel.number(), etc. would be helpful here instead. Am I correct? > -- or > > > is > > > > > there a smarter way to do this that I've missed? > > > > > > > > This is one of things that I think ggplot does better - it's much > > > > easier to plot multiple data sources. I don't have many examples of > > > > this yet, but the final example on > > > > http://had.co.nz/ggplot2/geom_abline.html illustrates the basic idea. > > > > > > That's probably true. The Trellis approach is to define a plot by > > > "data source" + "type of plot", whereas the ggplot approach (if I > > > understand correctly) is to create a specification for the display > > > (incrementally?) and then render it. Since the specification can be > > > very general, the approach is very flexible. The downside is that you > > > need to learn the language. > > > > > > On a philosophical note, I think the apparent limitations of Trellis > > > in some (not all) cases is just due to the artificial importance given > > > to data frames as the one true container for data. Now that we have > > > proper multiple dispatch in S4, we can write methods that behave like > > > traditional Trellis calls but work with more complex data structures. > > > We have tried this in one bioconductor package (flowViz) with > > > encouraging results. > > > > > > -Deepayan > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > _
Re: [R] Drawing rectangles in multiple panels
I wonder what kind of objects? Are there large advantages for allowing lattice functions to operate on objects other than data frames - I couldn't find any screenshots of flowViz but I imagine those objects would probably be list of arrays and such? I tend to think of mapply() [and more recently melt()], etc. could always be applied beforehand, but I suppose that would undermine the case for having generic functions to support the rich collection of object classes in R... --- Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > On 7/11/07, hadley wickham <[EMAIL PROTECTED]> wrote: > > > A question/comment: I have usually found that the subscripts argument > is > > > what I need when passing *external* information into the panel > function, for > > > example, when I wish to add results from a fit done external to the > trellis > > > call. Fits[subscripts] gives me the fits (or whatever) I want to plot > for > > > each panel. It is not clear to me how the panel layout information from > > > panel.number(), etc. would be helpful here instead. Am I correct? -- or > is > > > there a smarter way to do this that I've missed? > > > > This is one of things that I think ggplot does better - it's much > > easier to plot multiple data sources. I don't have many examples of > > this yet, but the final example on > > http://had.co.nz/ggplot2/geom_abline.html illustrates the basic idea. > > That's probably true. The Trellis approach is to define a plot by > "data source" + "type of plot", whereas the ggplot approach (if I > understand correctly) is to create a specification for the display > (incrementally?) and then render it. Since the specification can be > very general, the approach is very flexible. The downside is that you > need to learn the language. > > On a philosophical note, I think the apparent limitations of Trellis > in some (not all) cases is just due to the artificial importance given > to data frames as the one true container for data. Now that we have > proper multiple dispatch in S4, we can write methods that behave like > traditional Trellis calls but work with more complex data structures. > We have tried this in one bioconductor package (flowViz) with > encouraging results. > > -Deepayan > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to read many files at one time?
This should do it: allData <- sapply(paste("Sim",1:20,sep=""), function(.x) read.table(paste(.x,"txt",sep=".")), simplify=FALSE) see ?read.table for specification of delimiters, etc. allData will be a list, and you can access the contents of each file by any of the following commands: allData[[2]] allData[["Sim2"]] allData$Sim2 --- Zhang Jian <[EMAIL PROTECTED]> wrote: > I want to load many files in the R. The names of the files are "Sim1.txt", > " > Sim2.txt", "Sim3.txt", "Sim4.txt", "Sim5.txt" and so on. > Can I read them at one time? What should I do? I can give the same names in > R. > Thanks. > > For example: > > tst=paste("Sim",1:20,".txt",sep="") # the file names > > tst > [1] "Sim1.txt" "Sim2.txt" "Sim3.txt" "Sim4.txt" "Sim5.txt" "Sim6.txt" > [7] "Sim7.txt" "Sim8.txt" "Sim9.txt" "Sim10.txt" "Sim11.txt" > "Sim12.txt" > [13] "Sim13.txt" "Sim14.txt" "Sim15.txt" "Sim16.txt" "Sim17.txt" > "Sim18.txt" > [19] "Sim19.txt" "Sim20.txt" > > > data.name=paste("Sim",1:20,sep="") # the file names in R > > data.name > [1] "Sim1" "Sim2" "Sim3" "Sim4" "Sim5" "Sim6" "Sim7" "Sim8" "Sim9" > [10] "Sim10" "Sim11" "Sim12" "Sim13" "Sim14" "Sim15" "Sim16" "Sim17" > "Sim18" > [19] "Sim19" "Sim20" > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to read many files at one time?
On 14-Jul-07, at 6:16 PM, Zhang Jian wrote: > I want to load many files in the R. The names of the files are > "Sim1.txt", " > Sim2.txt", "Sim3.txt", "Sim4.txt", "Sim5.txt" and so on. > Can I read them at one time? What should I do? I can give the same > names in > R. > Thanks. > > For example: >> tst=paste("Sim",1:20,".txt",sep="") # the file names >> tst > [1] "Sim1.txt" "Sim2.txt" "Sim3.txt" "Sim4.txt" "Sim5.txt" > "Sim6.txt" > [7] "Sim7.txt" "Sim8.txt" "Sim9.txt" "Sim10.txt" "Sim11.txt" > "Sim12.txt" > [13] "Sim13.txt" "Sim14.txt" "Sim15.txt" "Sim16.txt" "Sim17.txt" > "Sim18.txt" > [19] "Sim19.txt" "Sim20.txt" > >> data.name=paste("Sim",1:20,sep="") # the file names in R >> data.name > [1] "Sim1" "Sim2" "Sim3" "Sim4" "Sim5" "Sim6" "Sim7" > "Sim8" "Sim9" > [10] "Sim10" "Sim11" "Sim12" "Sim13" "Sim14" "Sim15" "Sim16" > "Sim17" "Sim18" > [19] "Sim19" "Sim20" you could read each data file as a named element into a single list data=list(NULL) for(i in 1:length(tst)){ data[[i]]=read.table(tst[i]) names(data)[i]=data.name[i] } if you want to refer to Sim1, type data$"Sim1" __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] scaling of different data sets in ggplot
Dear list (but probably mostly Hadley): In ggplot, operations to modify 'guides' are accessed through grid objects, but I did not find mention of creating new guides or possibly removing them altogether using ggplot functions. I wonder if this is something I need to learn grid to learn more about (which I hope to do eventually). Also, ggplot()+geom_object() [where 'object' can be point, line, etc.] or layer() contains specification for the data, mappings and geoms/stats - but the geoms/stats can be scale-dependent [for instance, log]. so I wonder how different scalings can be applied to different data sets. Below is an example that requires both: x <- runif(100) y <- exp(x^2) z <- x^2+rnorm(100,0,0.02) par(mar=c(5,4,2,4)+0.1) plot(x,y,log="y") lines(lowess(x,y,f=1/3)) par(new=TRUE) plot(x,z,col=2,pch=3,yaxt="n",ylab="") lines(lowess(x,z,f=1/3),col=2) axis(4,col=2,col.axis=2) mtext("z",4,line=3,col=2) In ggplot: ## data specification ggplot(data=data.frame(x,y,z)) + ## first set of points geom_point(mapping=aes(x=x,y=y)) + ## scale_y_log() + ## second set of points geom_point(mapping=aes(x=x,y=z),pch=3) + ## layer(mapping=aes(x=x,y=z),stat="smooth",method="loess") + ## scale_y_continuous() scale_y_log() and scale_y_continuous() appear to apply to both mappings at once, and I can't figure out how to associate them with the intended ones (I expect this will be a desire for size and color scales as well). Of course, I can always try to fool the system by (1) applying the scaling a priori to create a new variable, (2) plotting points from the new variable, and (3) creating a new axis with custom labels. Which then brings me back to ...how to add new guides? :) Thanks, Stephen __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] polymorphic functions in ggplot? (WAS Re: Drawing rectangles in multiple panels)
Regarding your earlier statement, "I tend to think in very data centric approach, where you first generate the data (in a data frame) and then you plot it. There is very little data creation/modification during the plotting itself..." Is the data generation and plotting truly separate and sequential? I'm not entirely clear on this point - as statistical transformations/operations return objects that require new variables to be created - and this may be rooted in semantics (the verbal one, not the computational) of the grammar of graphics - in the online book draft of 'ggplot' it says (p. 37) "The explicit transformation stage was dropped because variable transformations are already so easy in R: they do not need to be part of the grammar." In my understanding of what transformations are defined to be, they involve statistical ones - which perhaps I'm not truly getting because tranformations are defined (by L. Wilkinson) as a mapping of elements of one set to elements of the same set, and yet a function like median() will accept a list (of values) and return a single value... in any case maybe there is a distinction between a statistical 'transformation' and a statistical 'operation' that I've missed, but statistical 'transformations' are included in ggplot's "stat" functions. L. Wilkinson also seems to include an explicit TRANS specification at times (for example, in the case of the boxplot on p.60) and at other times nest it into the ELEMENT specification (for example, the histogram on p. 47). In any case, I interpret that the following progression is achieved through 'data operations' and 'application of algebra' in the language of L. Wilkinson and through I/O, merge, reshape, and other functions in R: source object -> variables -> varset A statistic might then computed on the varset, which will return another source object (true in R as well: e.g., class 'histogram' or 'lm') from which variables can again be extracted, varsets constructed, etc. to yield a list of tuples to be associated with geometrical and aesthetic attributes. Indeed, in the bootstrap example, L. Wilkinson begins by extracting variables from a bootstrap function on another variable that has not explicitly been created from source (dataset). So it's not clear to me that the the data creation step is necessarily distinct from the plotting, as it is more (but not completely) so in the traditional graphics system: ## DATA specification variable <- rnorm(100) ## TRANS specification statsObj <- hist(variable,nclass=20,plot=FALSE) ## Transformed data is plotted (variables extracted implicity and ## associated with default geometry/aesthetic mappings) plot(statsObj) Below is an analogous plot in ggplot, where the creation of the summary object occurs as part of the grammar: ggplot(data=data.frame(variable),mapping=aes(x=variable)) + stat_bin(breaks=statsObj$breaks) Since all statistical transformations/operations aren't handled by ggplot, it seems that working with non-data-frame objects (for example, of class 'nls' or 'rlm') require data operations (p.7) (to extract fitted values, etc.). Of course, R provides these facilities, but the plotting functions in the traditional graphics system accommodate a number of object classes through polymorphic functions. I wonder if in a similar way for ggplot, stat_bin could accept objects of 'histogram' class [hist() allows the user to specify 'nclass', which will then compute the breaks], or stat_smooth could accept 'rlm' objects. Of course, in the case of an 'lm' object, plot() additionally gives diagnostic (residual and Q-Q) plots but that type of response does not seem to fit in with the expected behavior of ggplot functions... --- hadley wickham <[EMAIL PROTECTED]> wrote: > On 7/12/07, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > > On 7/11/07, hadley wickham <[EMAIL PROTECTED]> wrote: > > > > A question/comment: I have usually found that the subscripts argument > is > > > > what I need when passing *external* information into the panel > function, for > > > > example, when I wish to add results from a fit done external to the > trellis > > > > call. Fits[subscripts] gives me the fits (or whatever) I want to plot > for > > > > each panel. It is not clear to me how the panel layout information > from > > > > panel.number(), etc. would be helpful here instead. Am I correct? -- > or is > > > > there a smarter way to do this that I've missed? > > > > > > This is one of things that I think ggplot does better - it's much > > > easier to plot multiple data sources. I don't have many examples of > > > this yet, but the final example on > > > http://had.co.nz/ggplot2/geom_abline.html illustrates the basic idea. > > > > That's probably true. The Trellis approach is to define a plot by > > "data source" + "type of plot", whereas the ggplot approach (if I > > understand correctly) is to create a specification for the display > > (incrementally?) and then render it. Since the specification can be
[R] How to read many files at one time?
I want to load many files in the R. The names of the files are "Sim1.txt", " Sim2.txt", "Sim3.txt", "Sim4.txt", "Sim5.txt" and so on. Can I read them at one time? What should I do? I can give the same names in R. Thanks. For example: > tst=paste("Sim",1:20,".txt",sep="") # the file names > tst [1] "Sim1.txt" "Sim2.txt" "Sim3.txt" "Sim4.txt" "Sim5.txt" "Sim6.txt" [7] "Sim7.txt" "Sim8.txt" "Sim9.txt" "Sim10.txt" "Sim11.txt" "Sim12.txt" [13] "Sim13.txt" "Sim14.txt" "Sim15.txt" "Sim16.txt" "Sim17.txt" "Sim18.txt" [19] "Sim19.txt" "Sim20.txt" > data.name=paste("Sim",1:20,sep="") # the file names in R > data.name [1] "Sim1" "Sim2" "Sim3" "Sim4" "Sim5" "Sim6" "Sim7" "Sim8" "Sim9" [10] "Sim10" "Sim11" "Sim12" "Sim13" "Sim14" "Sim15" "Sim16" "Sim17" "Sim18" [19] "Sim19" "Sim20" [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] memory problem
Hi, My computer has 2GB of ram and I also request 2GB of virtual ram from c drive, therefore totally I have 4GB of ram. Before I open R workshop, I also add "C:\Program Files\R\R-2.5.0\bin\Rgui.exe" --max-mem-size=3000Mb--max-vsize=3000Mb" into the target of R by right clicking the R icon-properties. I am running a program (DPglmm), which is built in DPpackage. The program is running, but at the final stage, R generates an error message 'Error: cannot allocate vector of size 309.9 Mb' My code and output is as follows. > memory.limit(size=4000) NULL > fit0 <- DPglmm(fixed=Bpov~1,random=~1|cluster,data=MyData, + family=binomial(logit),n=Total,prior=prior,mcmc=mcmc,state=NULL, + status=TRUE) Error: cannot allocate vector of size 309.9 Mb It is very interesting that If i don't request 2GB of virtual memory from hard drive, the DPglmm doesn't run at all. After 2 minutes, R generates an error message 'Error: cannot allocate vector of size 309.9 Mb'. When i increased the ram, the DPglmm is running and it takes about 1 hr to finish running. Then it generates an error message 'Error: cannot allocate vector of size 309.9 Mb'. When I click fit0, i get nothing. I am very frustrated with this. It is very wired that my computer does have enough ram, however a vetor of size 309.9 Mb can't be stored. Thanks very much. xue __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: THANK YOU: Updating R version
Everyone using R in Windows should look at these batch files. Some of them are pure genius and will speed the process. Thanks John On 14/07/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Note that the batchfiles distribution on CRAN has two batch > programs: > > copydir.bat > movedir.bat > > that simplify the copying portion of the procedure you > discuss below. They can copy or move (copying > preserves the old directory but moving is much faster) > each package but will not overwrite existing packages > so the new versions of packages are preserved while the > old ones are added. Here is an example using copydir. > Replace copydir with movedir below to move rather than copy: > > cd \Program Files\R > copydir R-2.4.1\library R-2.5.0\library > > See the batchfiles' home page at: > > http://code.google.com/p/batchfiles/ > > The README file contains the instructions given above (and more) and > also a number of alternative procedures that do not involve the use of > the batchfiles. > > On 7/13/07, John C Frain <[EMAIL PROTECTED]> wrote: > > -- Forwarded message -- > > From: John C Frain <[EMAIL PROTECTED]> > > Date: 13-Jul-2007 22:30 > > Subject: Re: [R] THANK YOU: Updating R version > > To: "Christopher W. Ryan" <[EMAIL PROTECTED]> > > > > > > When I update R the following has worked for me (Windows XP) > > > > 1. Install the new version to a new directory (say C:\Program > > Files\R\R-2.5.1). > > > > 2 Rename the new library subdirectory to library2. > > > > 3 Copy the entire contents of the old library subdirectory (say > > C:\Program Files\R\R-2.4.0\library\ to the new R root to create > > C:\Program Files\R\R-2.5.1\library\ . > > > > 4 Copy the contents of library2 to library to update your basic library. > > > > 5 Now start your new version of R and update packages from the GUI or > > from the R console. (You may need to firs check Rprofile .site to > > ensure that no packages have been loaded) > > > > 6. On occasion I have got warning messages when I tried to load > > packages after this procedure. This has been cleared by running > > > > update.packages(checkBuilt = TRUE) > > > > This checks that your packages have been built with the latest > > version. When I do this I agree to install all available updates. > > > > 7 You may wish to copy various autoloads etc from your old > > Rprofile.site to your new Rprofile.site. I understand that there are > > some compatibility problems with 2.5.1 and SciViews so be careful. > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot usage question
On 7/14/07, Pete Kazmier <[EMAIL PROTECTED]> wrote: > Could someone show me how to get a blue line in this plot? > > > ggplot(movies, aes(x=rating)) + stat_qq(geom="line", > quantiles=seq(0,1,0.005), distribution=qunif) It's a bug in ggplot, sorry. It will be fixed in the next version. Hadley __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] HELP FOR BUGS
Ali raza wrote: > Hi Sir > > I am very new user of R for the research project on multilevel > logistic regression. There is confusion about bugs() function in R Do you mean bugs() from package "R2WinBUGS"? Yes, it is related to the software WinBUGS 1.4.x (and OpenBUGS 2.x with package "BRugs"). Uwe Ligges > and BUGS software. Is there any relation between these two? Is there > any comprehensive package for Multilevel Logistic modelling in R? > > Please guide in this regard. > > Thank You > > RAZA > > > - Boardwalk for $500? In 2007? Ha! > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the > posting guide http://www.R-project.org/posting-guide.html and provide > commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fwd: THANK YOU: Updating R version
Note that the batchfiles distribution on CRAN has two batch programs: copydir.bat movedir.bat that simplify the copying portion of the procedure you discuss below. They can copy or move (copying preserves the old directory but moving is much faster) each package but will not overwrite existing packages so the new versions of packages are preserved while the old ones are added. Here is an example using copydir. Replace copydir with movedir below to move rather than copy: cd \Program Files\R copydir R-2.4.1\library R-2.5.0\library See the batchfiles' home page at: http://code.google.com/p/batchfiles/ The README file contains the instructions given above (and more) and also a number of alternative procedures that do not involve the use of the batchfiles. On 7/13/07, John C Frain <[EMAIL PROTECTED]> wrote: > -- Forwarded message -- > From: John C Frain <[EMAIL PROTECTED]> > Date: 13-Jul-2007 22:30 > Subject: Re: [R] THANK YOU: Updating R version > To: "Christopher W. Ryan" <[EMAIL PROTECTED]> > > > When I update R the following has worked for me (Windows XP) > > 1. Install the new version to a new directory (say C:\Program > Files\R\R-2.5.1). > > 2 Rename the new library subdirectory to library2. > > 3 Copy the entire contents of the old library subdirectory (say > C:\Program Files\R\R-2.4.0\library\ to the new R root to create > C:\Program Files\R\R-2.5.1\library\ . > > 4 Copy the contents of library2 to library to update your basic library. > > 5 Now start your new version of R and update packages from the GUI or > from the R console. (You may need to firs check Rprofile .site to > ensure that no packages have been loaded) > > 6. On occasion I have got warning messages when I tried to load > packages after this procedure. This has been cleared by running > > update.packages(checkBuilt = TRUE) > > This checks that your packages have been built with the latest > version. When I do this I agree to install all available updates. > > 7 You may wish to copy various autoloads etc from your old > Rprofile.site to your new Rprofile.site. I understand that there are > some compatibility problems with 2.5.1 and SciViews so be careful. > > Best Regards > > John > > > > On 13/07/07, Christopher W. Ryan <[EMAIL PROTECTED]> wrote: > > This sounds like a solution I've been looking for. With this setup now > > in place, when you download and install some new packages, where will > > they be put? Into C:\myRlib ? > > > > Thanks. > > > > --Chris > > Christopher W. Ryan, MD > > SUNY Upstate Medical University Clinical Campus at Binghamton > > 40 Arch Street, Johnson City, NY 13790 > > cryanatbinghamtondotedu > > PGP public keys available at http://home.stny.rr.com/ryancw/ > > > > "If you want to build a ship, don't drum up the men to gather wood, > > divide the work and give orders. Instead, teach them to yearn for the > > vast and endless sea." [Antoine de St. Exupery] > > > > Raghu Naik wrote: > > > Based on the feedback received, I did the following: > > > > > > a) moved my lib sub-directory from the existing installed R version to > > > c:\myRLib > > > b) installed the updated R version > > > c) created .Renviron file in the home directory (C:\R-2.5.1) with the line > > > R_LIBS=c:/myRLib > > > d) used .libPaths() command to confirm that the new R installation was > > > recognizing the myRLib sub-directory > > > e) deleted my old R installation > > > > > > Things worked fine. > > > > > > Thanks you. > > > > > > > > > > > > -- Forwarded message -- > > > From: Raghu Naik <[EMAIL PROTECTED]> > > > Date: Jun 2, 2007 5:13 PM > > > Subject: Updating R version > > > To: r-help@stat.math.ethz.ch > > > > > > A quick question. I am trying to understand how I could move the > > > installed > > > packages in my R 2.3 version to the newly installed R 2.5 version, without > > > having to install all the packages again. I copied the files under the old > > > library subdirectory to the new library subdirectory. But still the newer > > > version is not recognizing the packages that were copied over. > > > > > > Thanks. > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > -- > John C Frain > Trinity College Dublin > Dublin 2 > Ireland > www.tcd.ie/Economics/staff/frainj/home.html > mailto:[EMAIL PROTECTED] > mailto:[EMAIL PROTECTED] > > > -- > John C Frain > Tr
Re: [R] Extracting elements from a list
The golden rule is that [[ ]] only returns one element: sapply(Lst, "[", 1, 1) is probably what you want. On Sat, 14 Jul 2007, 'Forest Floor' aka 'rhago' aka 'Jeff' aka 'R User confused about his identity' wrote: > Hi, > > I would love an easy way to extract elements from a list. > > For example, if I want the first element from each of 10 arrays stored > in a list, > > Lst[[1:10]][1,1] seems like a logical approach, but gives this error: > "Error: recursive indexing failed at level 3" It doesn't if you really have a list of 2D arrays. > The following workaround is functional but can get annoying/confusing. > > first.element=vector() > for (i in 1:10){ first.element=c(first.element, Lst[[i]][1,1]) } > > Is there a better way to do this? Thanks for any help! > > Jeff > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. PLEASE DO! -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] THANK YOU: Updating R version
Chris: In my installation, the new packages automatically get installed to the c:\myRlib directory. Raghu > Message: 63 > Date: Fri, 13 Jul 2007 15:44:48 -0500 > From: "Christopher W. Ryan" <[EMAIL PROTECTED]> > Subject: Re: [R] THANK YOU: Updating R version > To: r-help@stat.math.ethz.ch > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > This sounds like a solution I've been looking for. With this setup now > in place, when you download and install some new packages, where will > they be put? Into C:\myRlib ? > > Thanks. > > --Chris > Christopher W. Ryan, MD > SUNY Upstate Medical University Clinical Campus at Binghamton > 40 Arch Street, Johnson City, NY 13790 > cryanatbinghamtondotedu > PGP public keys available at http://home.stny.rr.com/ryancw/ > > "If you want to build a ship, don't drum up the men to gather wood, > divide the work and give orders. Instead, teach them to yearn for the > vast and endless sea." [Antoine de St. Exupery] > Raghu Naik wrote: > Based on the feedback received, I did the following: > > a) moved my lib sub-directory from the existing installed R version to > c:\myRLib > b) installed the updated R version > c) created .Renviron file in the home directory (C:\R-2.5.1) with the line > R_LIBS=c:/myRLib > d) used .libPaths() command to confirm that the new R installation was > recognizing the myRLib sub-directory > e) deleted my old R installation > > Things worked fine. > > Thanks you. > > > > -- Forwarded message -- > From: Raghu Naik <[EMAIL PROTECTED]> > Date: Jun 2, 2007 5:13 PM > Subject: Updating R version > To: r-help@stat.math.ethz.ch > > A quick question. I am trying to understand how I could move the installed > packages in my R 2.3 version to the newly installed R 2.5 version, without > having to install all the packages again. I copied the files under the old > library subdirectory to the new library subdirectory. But still the newer > version is not recognizing the packages that were copied over. > > Thanks. > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting elements from a list
Use lapply or sapply: > L <- list(a = 1:4, b = 11:15) > lapply(L, "[[", 1) $a [1] 1 $b [1] 11 > sapply(L, "[[", 1) a b 1 11 Also please see last line on every r-help message regarding providing reproducible code. Lst was not defined in your post. On 7/14/07, Forest Floor <[EMAIL PROTECTED]> wrote: > Hi, > > I would love an easy way to extract elements from a list. > > For example, if I want the first element from each of 10 arrays stored > in a list, > > Lst[[1:10]][1,1] seems like a logical approach, but gives this error: > "Error: recursive indexing failed at level 3" > > The following workaround is functional but can get annoying/confusing. > > first.element=vector() > for (i in 1:10){ first.element=c(first.element, Lst[[i]][1,1]) } > > Is there a better way to do this? Thanks for any help! > > Jeff > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to remove the quote "" in the data frame?
You can achieve this by cbind.data.frame() Christophe Pallier wrote: > Beware: you are not working with data.frames but with a vector and a > matrice. > (see ?cbind) > > Solution: convert 'res' to data.frame. > > Christophe > > On 7/14/07, Zhang Jian <[EMAIL PROTECTED]> wrote: >> If I do not add "ress" into the data frame "res", there is no quote in the >> data frame. However, I add "ress", all column were found the quote. >> How to remove it? >> If you can delete the quote in the file "ress", that is better. >> Thanks. >> >>> ress[1:10] >> [1] "ABHO.ABNE" "ABHO.ACBA" "ABHO.ACGI" "ABHO.ACKO" "ABHO.ACMA" "ABHO.ACMO >> " >> [7] "ABHO.ACPS" "ABHO.ACSE" "ABHO.ACTE" "ABHO.ACTR" >>> res=cbind(obv.value,p.value,mean.sim) >>> res[1:10,] >> obv.value p.value mean.sim >> [1,] 2 1.0 6.0 >> [2,] 0 1.0 0.0 >> [3,]66 0.5 49.6 >> [4,] 3 1.0 3.0 >> [5,] 0 1.0 64.7 >> [6,] 0 1.0 0.0 >> [7,] 0 1.0 0.0 >> [8,]51 0.5 39.8 >> [9,] 0 1.0 47.4 >> [10,]59 0.7 72.0 >> >>> ress=cbind(res,ress) >>> ress[1:10,] >> obv.value p.value mean.sim ress >> [1,] "2" "1" "6" "ABHO.ABNE" >> [2,] "0" "1" "0" "ABHO.ACBA" >> [3,] "66" "0.5" "49.6" "ABHO.ACGI" >> [4,] "3" "1" "3" "ABHO.ACKO" >> [5,] "0" "1" "64.7" "ABHO.ACMA" >> [6,] "0" "1" "0" "ABHO.ACMO" >> [7,] "0" "1" "0" "ABHO.ACPS" >> [8,] "51" "0.5" "39.8" "ABHO.ACSE" >> [9,] "0" "1" "47.4" "ABHO.ACTE" >> [10,] "59" "0.7" "72" "ABHO.ACTR" >> >> [[alternative HTML version deleted]] >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting elements from a list
Try sapply( Lst, function(m) m[1,1] ) Also note that to subset a list, you just need Lst[ 1:10 ] and not Lst[[ 1:10 ]] (note the double square brackets). Regards, Adai Forest Floor wrote: > Hi, > > I would love an easy way to extract elements from a list. > > For example, if I want the first element from each of 10 arrays stored > in a list, > > Lst[[1:10]][1,1] seems like a logical approach, but gives this error: > "Error: recursive indexing failed at level 3" > > The following workaround is functional but can get annoying/confusing. > > first.element=vector() > for (i in 1:10){ first.element=c(first.element, Lst[[i]][1,1]) } > > Is there a better way to do this? Thanks for any help! > > Jeff > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Extracting elements from a list
Hi, I would love an easy way to extract elements from a list. For example, if I want the first element from each of 10 arrays stored in a list, Lst[[1:10]][1,1] seems like a logical approach, but gives this error: "Error: recursive indexing failed at level 3" The following workaround is functional but can get annoying/confusing. first.element=vector() for (i in 1:10){ first.element=c(first.element, Lst[[i]][1,1]) } Is there a better way to do this? Thanks for any help! Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] return() in nested functions
On 14/07/2007 7:16 AM, Mark Hempelmann wrote: > Dear WizaRds, > > After consulting different sources I am still unable to understand the > correct use of return() in nested functions. To illustrate the problem: return() knows nothing about nested functions. It just returns from the current function. In most respects, nested functions are just like any other functions in R. The only important difference is the attached environment, which affects what is visible from within the function, and where <<- stores results. > > f <- function(x,y,type){ > > est1<-function(x,y){ > z=x+y > out(x,y,z)} > > est2<-function(x,y){ > z=x*y > out(x,y,z)} > > out<-function(x,y,z) > return(x,y,z) Don't ignore the warning you saw from this! Deprecated things eventually become defunct. You want return(list(x, y, z)) > > if (type=="est1") est1(x,y) > if (type=="est2") est2(x,y) > } > > test<-f(1,2,type="est1") # gives Null for test The result of the first if is the value from the call to est1. The result of the second if is NULL. That's what your function returned. If you had wrapped those calls in return() you'd get what I think you expected: if (type=="est1") return(est1(x,y)) if (type=="est2") return(est2(x,y)) because the return() causes the function to exit and return a value. Duncan Murdoch > > However, without the second 'if' condition, it works properly: > Warning message: > multi-argument returns are deprecated in: return(x, y, z) >> test > $x > [1] 1 > $y > [1] 2 > $z > [1] 3 > > Basically, the function I am working on is of the above structure, be it > more complex. I would like f to return the results of function 'out' to > the user in the assigned variable, e.g. 'test'. i did consult try() and > tryCatch(), but it doesn't seem to be what I am looking for. > > Thank you for your help and understanding > mark > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] return() in nested functions
Dear WizaRds, After consulting different sources I am still unable to understand the correct use of return() in nested functions. To illustrate the problem: f <- function(x,y,type){ est1<-function(x,y){ z=x+y out(x,y,z)} est2<-function(x,y){ z=x*y out(x,y,z)} out<-function(x,y,z) return(x,y,z) if (type=="est1") est1(x,y) if (type=="est2") est2(x,y) } test<-f(1,2,type="est1") # gives Null for test However, without the second 'if' condition, it works properly: Warning message: multi-argument returns are deprecated in: return(x, y, z) > test $x [1] 1 $y [1] 2 $z [1] 3 Basically, the function I am working on is of the above structure, be it more complex. I would like f to return the results of function 'out' to the user in the assigned variable, e.g. 'test'. i did consult try() and tryCatch(), but it doesn't seem to be what I am looking for. Thank you for your help and understanding mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] HELP FOR BUGS
Hi Sir I am very new user of R for the research project on multilevel logistic regression. There is confusion about bugs() function in R and BUGS software. Is there any relation between these two? Is there any comprehensive package for Multilevel Logistic modelling in R? Please guide in this regard. Thank You RAZA - Boardwalk for $500? In 2007? Ha! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble compiling Hmisc package
On Fri, 13 Jul 2007, [EMAIL PROTECTED] wrote: > Hi: > > We're trying to install the Hmisc package on a Solaris 9 machine. But Solaris 9 does not come with a compiler called 'g95', as far as I know. So what is this? The underlying problem is that Hmisc is not written in standard Fortran. DO ... END DO statements are not Fortran77 and in Fortran 2003 I believe they are required to have integer loop indices. But most compilers cope, including the Solaris 'standard' f95. Your first port of call (see the R posting guide) is the package maintainer, Cc:ed here. Charles: the use of REAL*8 and INTEGER*4 is both non-standard and not what R has tested when being built. Please use DOUBLE PRECSION and INTEGER. And tabs are not valid: use spaces. A quick fix is likely to be to declare INTEGER xl,xr,yl,yu in largrec.f. > Here's what we get: > > R CMD INSTALL /usr/local/srctree/Hmisc_3.4-2.tar.gz > * Installing to library '/usr/local/lib/R/library' > * Installing *source* package 'Hmisc' ... > ** libs > g95 -fPIC -g -O2 -c cidxcn.f -o cidxcn.o > g95 -fPIC -g -O2 -c cidxcp.f -o cidxcp.o > g95 -fPIC -g -O2 -c hoeffd.f -o hoeffd.o > g95 -fPIC -g -O2 -c jacklins.f -o jacklins.o > g95 -fPIC -g -O2 -c largrec.f -o largrec.o > In file largrec.f:27 > > DO xl=xlim(1),xlim(2)-width,xinc > 1 > Error: Loop variable at (1) must be a scalar INTEGER > In file largrec.f:28 > > DO yl=ylim(1),ylim(2)-height,yinc > 1 > Error: Loop variable at (1) must be a scalar INTEGER > In file largrec.f:29 > >DO xr=xl+width,xlim(2),xinc >1 > Error: Loop variable at (1) must be a scalar INTEGER > In file largrec.f:30 > > DO yu=yl+height,ylim(2),yinc > 1 > Error: Loop variable at (1) must be a scalar INTEGER > make: *** [largrec.o] Error 1 > ERROR: compilation failed for package 'Hmisc' > ** Removing '/usr/local/lib/R/library/Hmisc' > > Can anybody help us? > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to estimate treatment-interaction contrasts
[EMAIL PROTECTED] wrote: > Hello, Chuck, > Thank you very much for your help! But the contrasts I want to do > simutaneously is > contrasts(B) > [,1] [,2] [,3] [,4] > b1 -4 -3 -2 -1 > b21 -3 -2 -1 > b312 -2 -1 > b4123 -1 > b51234 > > Could you please show me how to calculate estimates for ALL > intearaction constrasts using THESE contrasts? Say C2: c(-3, -3, 2, 2, > 2) as an example. I used the ortholognal constrasts as you suggest, > estimate for interaction contrast C2 is still -24.1. > Joshua Joshua: I use a variation on my contrasts to show how you might get the estimates. I then confirm the estimates by calculating the differences of differences in means "by hand". score <- c(7.2,6.5,6.9,6.4,6.9,6.1,6.9,5.3,7.2,5.7,5.1,5.9,7.6,6.9,6.8, 7.2,6.6,6.9,6.4,6.0,6.0,6.9,6.9,6.4,7.5,7.7,7.0,8.6,8.8,8.3) A <- gl(2, 15, labels=c("a1", "a2")) B <- rep(gl(5, 3, labels=c("b1", "b2", "b3", "b4", "b5")), 2) contrasts(B) <- matrix(c(3/5, 1/2, 0, 0, 3/5, -1/2, 0, 0, -2/5, 0, 2/3, 0, -2/5, 0, -1/3, 1/2, -2/5, 0, -1/3, -1/2), ncol=4, byrow=TRUE) fit1 <- aov(score ~ A*B) summary(fit1, split=list(B=1:4), expand.split = TRUE) Df Sum Sq Mean Sq F valuePr(>F) A1 3.2013 3.2013 15.1483 0.0009054 *** B4 8.7780 2.1945 10.3841 0.0001019 *** B: C1 1 1.0427 1.0427 4.9340 0.0380408 * B: C2 1 1.0208 1.0208 4.8304 0.0399049 * B: C3 1 1.2469 1.2469 5.9004 0.0246876 * B: C4 1 5.4675 5.4675 25.8715 5.637e-05 *** A:B 4 5.3420 1.3355 6.3194 0.0018616 ** A:B: C11 3.2267 3.2267 15.2684 0.0008734 *** A:B: C21 0.1008 0.1008 0.4771 0.4976647 A:B: C31 1.9136 1.9136 9.0549 0.0069317 ** A:B: C41 0.1008 0.1008 0.4771 0.4976647 Residuals 20 4.2267 0.2113 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 # Estimates with tests that match those above summary(lm(score ~ A*B)) Call: lm(formula = score ~ A * B) Residuals: Min 1Q Median 3Q Max -1.16667 -0.29167 0.0 0.29167 0.7 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.4933 0.1187 54.705 < 2e-16 *** Aa2 0.6533 0.1679 3.892 0.000905 *** B10.2889 0.2423 1.192 0.247086 B20.4000 0.3754 1.066 0.299271 B30.1333 0.3251 0.410 0.686038 B4 -1.5333 0.3754 -4.085 0.000577 *** Aa2:B1 -1.3389 0.3426 -3.907 0.000873 *** Aa2:B20.3667 0.5308 0.691 0.497665 Aa2:B3 -1.3833 0.4597 -3.009 0.006932 ** Aa2:B40.3667 0.5308 0.691 0.497665 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.4597 on 20 degrees of freedom Multiple R-Squared: 0.8038, Adjusted R-squared: 0.7156 F-statistic: 9.107 on 9 and 20 DF, p-value: 2.324e-05 # Confirm that estimates match differences of differences in means diff(rowMeans(tapply(score, list(A,B), mean)[,1:2]) - rowMeans(tapply(score, list(A,B), mean)[,3:5])) a2 -1.338889 diff(tapply(score, list(A,B), mean)[,1] - tapply(score, list(A,B), mean)[,2]) a2 0.367 diff(tapply(score, list(A,B), mean)[,3] - rowMeans(tapply(score, list(A,B), mean)[,4:5])) a2 -1.38 diff(tapply(score, list(A,B), mean)[,4] - tapply(score, list(A,B), mean)[,5]) a2 0.367 So, applying the same strategy to your contrasts would give the following: contrasts(B) <- matrix(c(-4/5, -3/5, -2/5, -1/5, 1/5, -3/5, -2/5, -1/5, 1/5, 2/5, -2/5, -1/5, 1/5, 2/5, 3/5, -1/5, 1/5, 2/5, 3/5, 4/5), ncol=4, byrow=TRUE) fit1 <- aov(score ~ A*B) summary(fit1, split=list(B=1:4), expand.split = TRUE) Df Sum Sq Mean Sq F valuePr(>F) A1 3.2013 3.2013 15.1483 0.0009054 *** B4 8.7780 2.1945 10.3841 0.0001019 *** B: C1 1 0.0301 0.0301 0.1424 0.7099296 B: C2 1 2.0335 2.0335 9.6221 0.0056199 ** B: C3 1 1.2469 1.2469 5.9004 0.0246876 * B: C4 1 5.4675 5.4675 25.8715 5.637e-05 *** A:B 4 5.3420 1.3355 6.3194 0.0018616 ** A:B: C11 0.7207 0.7207 3.4105 0.0796342 . A:B: C21 2.6068 2.6068 12.3350 0.0021927 ** A:B: C31 1.9136 1.9136 9.0549 0.0069317 ** A:B: C41 0.1008 0.1008 0.4771 0.4976647 Residuals 20 4.2267 0.2113 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 summary(lm(score ~ A*B)) Call: lm(formula = score ~ A * B) Residuals: Min 1Q Median 3Q Max -1.16667 -0.29167 0.0 0.29167 0.7 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 6.493e+00 1.187e-0154.705 < 2e-16 *** Aa2
Re: [R] learning the R language (for those strong in Ruby)
--- "David C. James" <[EMAIL PROTECTED]> wrote: > I feel like I'm not firing at all cylinders with the > R language, > despite reading over the R Language Definition. > > Has anyone seen something like an "R for Rubyists" > guide (i.e. > teaching the R language for those who are more > familar with Ruby)? > > Alternately, a book with lots of examples about how > the R language > itself works would be fantastic. Peter Dalgaard's book "Introductory Statistics with R" or John Verzani's book "Using R for introductory statistics" both might be good for a start. Dalgaad's book has an very handy appendix summarizing a lot of the basic commands. There are also quite a few excellent online books and papers available on the R site (lefthand side at bottom you will see books and other) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] create a matrix from an excel file?
> "TS" == Tavpritesh Sethi <[EMAIL PROTECTED]> > on Sat, 14 Jul 2007 12:59:03 +0530 writes: TS> how do you create a matrix from an excel file read into TS> R by the command read.delim? data.matrix(.) {is typical a bit more useful than as.matrix(.) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extending Matrix class
This is from a private question which I'm given permission to answer in public: > "IF" == Ingo Feinerer <[EMAIL PROTECTED]> > on Fri, 13 Jul 2007 16:14:07 +0200 writes: IF> Hello, We tried to derive a class from Matrix but had IF> some problems. Maybe you can help us: library("Matrix") m <- Matrix(c(1:3,rep(0,12),16:20), nrow = 4, ncol = 5) setClass("TermDocMatrix", representation(Weighting = "character"), contains = ("Matrix")) IF> Now we want to do something like: IF> new("TermDocMatrix", .Data = m, weighting = "foobar") IF> which obviously does not work due to the missing .Data IF> slot. yes, obviously, indeed. There is never any .Data slot in our matrices. IF> Note that we do not know in advance what the IF> matrix "m" actually is (we only know it is *some* IF> Matrix, e.g., we do not know if it is a dgCMatrix or a IF> lgCMatrix or ...). Is there a (simple) solution? Well, yes, but probably not the one you had wanted: setClass("TD_Matrix", representation(data = "Matrix", Weighting = "character")) A <- spMatrix(10,20, i = c(1,3:8), j = c(2,9,6:10), x = 7 * (1:7)) tdr <- new("TD_Matrix", data = A, Weighting = "foobar") tdr Now I understand that and why you had wanted to do this the original way you did - which cannot work AFAICS. OTOH, I wonder if other useRs, particularly those who know about S4 classes (and the "Matrix" classes), have better proposals maybe along the following "dream" .. I think what Ingo would want is to say: let me extend the full Matrix class hierarchy (or just the "dsparseMatrix" sub hierarchy) by a new slot 'Weighting' and hence by default inherit all methods which I don't explicitly set myself. I think this can only partially work, even for a future version of R, since the inherited methods don't know what to do with "Weighting", but it would already be interesting if all necessary new methods could be defined semi-automatically: 1) call the corresponding Matrix method 2) pass on all my extra slots Regards, Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Algorythmic Question on Array Filtration
John Kane wrote: Thanks for your time. Please find a small example below - the real data is MUCH bigger. If you look at rows 5 and 6 of this and calculate the mass precision window I have to deal with (5 ppm), you'll find the following: Row Lower 5ppm MassHigher 5ppm Intensity 5 312.9419312.9435312.945120236.181 6 312.9422312.9438312.945414404.502 The precision windows here obviously overlap and I need to get rid of one of them, which in this case should be row6, since it has the lower intensity associated with it. For now I resort to doing an intensity sort and descending into the list populate a fresh data.frame with entries that do not have any overlap, skipping those that do. If somebody has any more sound ideas, I'd appreciate to hear about them. Thanks, Joh MassIntensity 304.9117 35595.780 305.1726 18760.413 311.0636 24047.307 312.9303 12886.216 312.9435 20236.181 312.9438 14404.502 313.1763 61033.830 313.1766 50788.418 316.9118 5908.166 317.2805 14084.841 317.2833 25603.689 317.2837 22866.578 318.0114 37929.855 318.9274 27883.295 318.9889 4496.716 321.2784 3893.165 326.1166 23745.851 327.2894 5318.226 328.8852 60934.030 329.1517 31985.486 331.0426 14883.231 332.0268 55126.078 332.2798 47364.519 333.2813 11423.807 337.1990 5330.360 339.2144 38450.804 339.2867 4065.709 340.9561 54101.844 340.9770 28172.160 345.0583 17945.025 345.0583 17877.900 347.1742 7359.428 347.2407 204792.999 353.2302 87864.153 353.2302 129691.696 363.0161 20453.771 363.0943 19481.234 363.2142 9238.244 363.2315 23323.527 363.2533 20039.607 363.2534 22068.718 364.8918 16857.488 364.9368 9527.642 366.9029 18174.233 373.2197 7730.009 385.1147 27907.070 385.1148 19383.655 393.2913 11860.719 396.9074 10793.823 400.8792 10750.249 402.8729 12411.966 407.2771 11270.566 442.8689 18101.972 442.8697 10671.199 447.3470 35927.046 449.2347 6959.247 456.9339 50402.820 461.1670 8636.998 461.1670 8151.706 473.2985 13782.291 490.9224 18510.760 > I think we need a bit more information and perhaps a > small example data set to see what you want. > > I am not familiar with term mass window. Is this a > confidence interval around the mass value? > > > --- Johannes Graumann <[EMAIL PROTECTED]> > wrote: > >> Dear All, >> >> I have a data frame with the columns "Mass" and >> "Intensity" (this is mass >> spectrometry stuff). Each of the mass values gives >> rise to a mass window of >> 5 ppm around the individual mass (from mass - >> mass/1E6*5 to mass + >> mass/1E5*5). I need to filter the array such that in >> case these mass >> windows overlap I retain the mass/intensity pair >> with the highest >> intensity. >> I apologize for this question, but I have no formal >> IT education and would >> value any nudges toward favorable algorithmic >> solutions highly. >> >> Thanks for any help, >> >> Joh >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, >> reproducible code. >> > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, > minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] nearest correlation to polychoric
> "RV" == Ravi Varadhan <[EMAIL PROTECTED]> > on Fri, 13 Jul 2007 10:52:36 -0400 writes: RV> Martin, I sent you the Matlab code for this which I had RV> obtained from Nich Higham. RV> Cheng, Sheung Hun and Higham, Nick (1998) A Modified RV> Cholesky Algorithm Based on a Symmetric Indefinite RV> Factorization; \emph{SIAM J. Matrix Anal.\ Appl.}, RV> \bold{19}, 1097--1110. RV> Do you remember? I now do .. last November. I'm embarrassed to admit that I hadn't found the time at the time and had completely forgotten about it. But now that Jens already has a version of this in R -- thanks Jens -- this should really find a home in the "R universe" As a matter of fact, I was thinking of porting the algorithm to the 'Matrix' package eventually, the specific "polychor" related case may still better fit to John Fox' package. Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] create a matrix from an excel file?
how do you create a matrix from an excel file read into R by the command read.delim? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to remove the quote "" in the data frame?
Beware: you are not working with data.frames but with a vector and a matrice. (see ?cbind) Solution: convert 'res' to data.frame. Christophe On 7/14/07, Zhang Jian <[EMAIL PROTECTED]> wrote: > > If I do not add "ress" into the data frame "res", there is no quote in the > data frame. However, I add "ress", all column were found the quote. > How to remove it? > If you can delete the quote in the file "ress", that is better. > Thanks. > > > ress[1:10] > [1] "ABHO.ABNE" "ABHO.ACBA" "ABHO.ACGI" "ABHO.ACKO" "ABHO.ACMA" "ABHO.ACMO > " > [7] "ABHO.ACPS" "ABHO.ACSE" "ABHO.ACTE" "ABHO.ACTR" > > res=cbind(obv.value,p.value,mean.sim) > > res[1:10,] > obv.value p.value mean.sim > [1,] 2 1.0 6.0 > [2,] 0 1.0 0.0 > [3,]66 0.5 49.6 > [4,] 3 1.0 3.0 > [5,] 0 1.0 64.7 > [6,] 0 1.0 0.0 > [7,] 0 1.0 0.0 > [8,]51 0.5 39.8 > [9,] 0 1.0 47.4 > [10,]59 0.7 72.0 > > > ress=cbind(res,ress) > > ress[1:10,] > obv.value p.value mean.sim ress > [1,] "2" "1" "6" "ABHO.ABNE" > [2,] "0" "1" "0" "ABHO.ACBA" > [3,] "66" "0.5" "49.6" "ABHO.ACGI" > [4,] "3" "1" "3" "ABHO.ACKO" > [5,] "0" "1" "64.7" "ABHO.ACMA" > [6,] "0" "1" "0" "ABHO.ACMO" > [7,] "0" "1" "0" "ABHO.ACPS" > [8,] "51" "0.5" "39.8" "ABHO.ACSE" > [9,] "0" "1" "47.4" "ABHO.ACTE" > [10,] "59" "0.7" "72" "ABHO.ACTR" > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Christophe Pallier (http://www.pallier.org) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.