[R] Importing large data set from teradata
Hi, I want to import data from teradata.Data set is very large in size , it has around 1 million rows and 40 columns. Could anyone tell me an efficient and fast way to import data sets with this size. Thanks. Sumit [[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] mixed effects ordinal logistic regression models
Hi, How do I fit a mixed-effects regression model for ordinal data in R? More specifically, I have two crossed random effects and I would like to use proportional odds assumption with a complementary log-log link. Regards, Hakan Demirtas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] It This data viz possible in R?
An improved version below (now the connections are drawn in the correct order), library(grid) arcTextGrob - function(x=unit(0.5, npc), y=unit(0.5, npc), labels=library()$results[,1], links=sample(seq_along(labels), 20, rep=T), default.units=npc, gp=gpar(), ...) { ## circle full.height - sum(stringHeight(labels)) radius - 1.2 /(2*pi) * full.height g1 - circleGrob(0.5, 0.5, r=radius, default.units=npc, gp=gpar(col=NA)) ## text labels n - length(labels) ang - seq(0, n-1) * 2 * pi/n radius.npc - convertUnit(radius, npc, val=T) coords - data.frame(x=0.5+radius.npc*cos(ang), y=0.5+radius.npc*sin(ang)) g2 - textGrob(labels, x=coords$x , y=coords$y , rot=ang*180/pi, default.units=npc, hjust=0) ## connecting pairs xm - matrix(coords$x[links], ncol=2, byrow=T) ym - matrix(coords$y[links], ncol=2, byrow=T) ## find out which pairs are not in trigo order ## and swap them swap - as.logical(sign((xm[, 1]-0.5)*(ym[, 2]-0.5) - (xm[, 2]-0.5)*(ym[, 1]-0.5)) + 1) xm[swap, ] - rev(xm[swap]) ym[swap, ] - rev(ym[swap]) g3 - do.call(gList, mapply(curveGrob, x1=xm[, 1], y1=ym[, 1], x2=xm[, 2], y2=ym[, 2], ncp=8, curvature=0.4, square=F, SIMPLIFY=FALSE)) gTree(children=gList(g1, g2, g3), outer.radius=convertUnit(radius, npc) + convertUnit(max(stringWidth(labels)), npc)) } grid.arcText - function(...) grid.draw(arcTextGrob(...)) set.seed(1234) grid.newpage() grid.arcText() On 7 April 2010 23:13, baptiste auguie baptiste.aug...@googlemail.com wrote: The following grob might be a starting point. I couldn't find a clean way of orienting the linking arcs though... Best, baptiste library(grid) paragraph - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent adipiscing lobortis placerat. Nunc vel arcu mauris. Aliquam erat volutpat. Integer et pharetra orci. Sed rutrum facilisis dolor et condimentum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nunc leo nibh, pellentesque et convallis quis, mattis ut mi. Nunc dignissim auctor elit pulvinar malesuada. Cras dapibus hendrerit ligula quis suscipit. Proin porta tempor feugiat. Ut quis nisi lacus, et egestas tortor. Fusce porttitor tincidunt fringilla. Vivamus rhoncus ultrices elit, at fermentum nisl scelerisque et. Duis placerat est at justo vestibulum sodales. Curabitur quis eros tellus. words - strsplit(paragraph, )[[1]] labels - apply(matrix(words, ncol=3, byrow=T), 1, paste, collapse= ) arcTextGrob - function(x=unit(0.5, npc), y=unit(0.5, npc), labels=letters[1:10], links=sample(seq_along(labels), 10), min.radius=unit(2, cm), default.units=npc, gp=gpar(), ...) { ## circle of perimeter = 1.5 * the text height full.height - sum(stringHeight(labels)) radius - 1.5 /(2*pi) * full.height g1 - circleGrob(0.5, 0.5, r=radius, default.units=npc) ## text labels n - length(labels) ang - seq(0, n-1) * 2 * pi/n radius.mm - convertUnit(radius, npc, val=T) coords - data.frame(x=0.5+radius.mm*cos(ang), y=0.5+radius.mm*sin(ang)) g2 - textGrob(labels, x=coords$x , y=coords$y , rot=ang*180/pi, default.units=npc, hjust=0) ## links, ## NOTE: they are not well ordered... xm - matrix(coords$x[links], ncol=2, byrow=T) ym - matrix(coords$y[links], ncol=2, byrow=T) g3 - do.call(gList, mapply(curveGrob, x1=xm[, 1], y1=ym[, 1], x2=xm[, 2], y2=ym[, 2], ncp=8, curvature=0.3, square=F, SIMPLIFY=FALSE)) gTree(children=gList(g1, g2, g3)) } grid.arcText - function(...) grid.draw(arcTextGrob(...)) dev.new() grid.arcText(labels=labels) On 7 April 2010 16:44, Gabor Grothendieck ggrothendi...@gmail.com wrote: There is draw.arc in the plotrix package. On Wed, Apr 7, 2010 at 10:20 AM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, Barry suggested a way to place the text labels; I would like to point out the grid.curve() function that might help in connecting the labels with nice-looking curves. I don't know of a base graphics equivalent (xspline() might come close) so it might be best to opt for Grid. HTH, baptiste On 7 April 2010 15:46, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Wed, Apr 7, 2010 at 2:28 PM, Brock Tibert btibe...@yahoo.com wrote: Hi All, I am new to R, but it has been a lot of fun learning as I go and have been blow away by what it can do. Came across this example and wanted to see if ggplot2 or some other visualization package could make this sort of graphic.
Re: [R] Copulas
I want to fit a bivariate copula to bivariate data. Then I want to draw a straight line on the copula. Then I want to retrieve those origianl pairs (X.Y) which were above the line. Any ideas how to do this? Thanks, Jim [[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] Meaning of lag 0.2, 0.4,... ?
Please see that correlogram for a arbitrary time series : acf(zooreg(rnorm(39), start=as.yearmon(2008-01-01), frequency=12)) What is the meaning of lag 0.2, 0.4, in the plot? Those should not be integers? Or I am missing something? Thanks -- View this message in context: http://n4.nabble.com/Meaning-of-lag-0-2-0-4-tp1765093p1765093.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] Using read.table to read file created with read.table and qmethod = escape
This worked for me in R 2.11.0 alpha: df - data.frame(a = a\b, v = 4, z = this is Z) write.csv(df, test.csv, row.names = FALSE, quote = FALSE) read.csv(test.csv, quote = ) -Peter Ehlers On 2010-04-07 19:09, Hadley Wickham wrote: df- data.frame(a = a\b) write.table(df, test.csv, sep = ,, row = F) Is there any to load test.csv into R correctly? I've tried the following: read.table(test.csv, sep = ,) [1] V1 0 rows (or 0-length row.names) Warning message: In read.table(test.csv, sep = ,) : incomplete final line found by readTableHeader on 'test.csv' read.table(test.csv, sep = ,, allowEscapes = T) [1] V1 0 rows (or 0-length row.names) Warning message: In read.table(test.csv, sep = ,, allowEscapes = T) : incomplete final line found by readTableHeader on 'test.csv' And I can't see any other options in read.table that would apply. Regards, Hadley -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Meaning of lag 0.2, 0.4,... ?
Hi Bogaso, You could try this to get integer x-axis values: library(zoo) z = zooreg(rnorm(39), start=as.yearmon(2008-01-01), frequency=12) acf(ts(z,freq=1)) Steve Chen On 2010/4/8 下午 03:32, Bogaso wrote: Please see that correlogram for a arbitrary time series : acf(zooreg(rnorm(39), start=as.yearmon(2008-01-01), frequency=12)) What is the meaning of lag 0.2, 0.4, in the plot? Those should not be integers? Or I am missing something? 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.
Re: [R] Meaning of lag 0.2, 0.4,... ?
On Wed, 7 Apr 2010, Bogaso wrote: Please see that correlogram for a arbitrary time series : library(zoo) ## you example does not work without it! acf(zooreg(rnorm(39), start=as.yearmon(2008-01-01), frequency=12)) What is the meaning of lag 0.2, 0.4, in the plot? Those should not be integers? Or I am missing something? You are. They are in years: you told R that the series was monthly with a time unit of years. Thanks -- View this message in context: http://n4.nabble.com/Meaning-of-lag-0-2-0-4-tp1765093p1765093.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, rip...@stats.ox.ac.uk 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] mixed effects ordinal logistic regression models
HAKAN DEMIRTAS wrote: How do I fit a mixed-effects regression model for ordinal data in R? More specifically, I have two crossed random effects and I would like to use proportional odds assumption with a complementary log-log link. Not out of the box, as far I know. Try http://r-project.markmail.org/search/?q=proportional%20odds%20mixed%20model to read some of Frank Harrell's and Douglas Bates's comments in the subject. Dieter -- View this message in context: http://n4.nabble.com/mixed-effects-ordinal-logistic-regression-models-tp1761501p1770669.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] match function or ==
Please install v1.3 from R-forge : install.packages(data.table,repos=http://R-Forge.R-project.org;) It will be ready for CRAN soon. Please follow up on datatable-h...@lists.r-forge.r-project.org Matthew bo bozha...@hotmail.com wrote in message news:1270689586866-1755876.p...@n4.nabble.com... Thank you very much for the help. I installed data.table package, but I keep getting the following warnings: setkey(DT,id,date) Warning messages: 1: In `[.data.table`(deref(x), o) : This R session is 2.4.0. Please upgrade to 2.4.0+. I'm using R 2.10, but why I keep getting warnings on upgrades. Thanks again. -- View this message in context: http://n4.nabble.com/match-function-or-tp1754505p1755876.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] Code is too slow: mean-centering variables in a dataframebysubgroup
Hi Dimitri, A start has been made at explaining .SD in FAQ 2.1. This was previously on a webpage, but its just been moved to a vignette : https://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/branch2/inst/doc/faq.pdf?rev=68root=datatable Please note: that vignette is part of a development branch on r-forge, and as such isn't even released to the r-forge repository yet. Please also see FAQ 4.5 in that vignette and follow up on datatable-h...@lists.r-forge.r-project.org An introduction vignette is taking shape too (again, in the development branch i.e. bleeding edge) : https://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/branch2/inst/doc/intro.pdf?rev=68root=datatable HTH Matthew Dimitri Liakhovitski ld7...@gmail.com wrote in message news:r2rdae9a2a61004071314xc03ae851n4c9027b28df5a...@mail.gmail.com... Yes, Tom's solution is indeed the fastest! On my PC it took .17-.22 seconds while using ave() took .23-.27 seconds. And of course - the last two methods I mentioned took 1.3 SECONDS, not MINUTES (it was a typo). All that is left to me is to understand what .SD stands for. :-) Dimitri On Wed, Apr 7, 2010 at 4:04 PM, Rob Forler rfor...@uchicago.edu wrote: Leave it up to Tom to solve things wickedly fast :) Just as an fyi Dimitri, Tom is one of the developers of data.table. -Rob On Wed, Apr 7, 2010 at 2:51 PM, Dimitri Liakhovitski ld7...@gmail.com wrote: Wow, thank you, Tom! On Wed, Apr 7, 2010 at 3:46 PM, Tom Short tshort.rli...@gmail.com wrote: Here's how I would have done the data.table method. It's a bit faster than the ave approach on my machine: # install.packages(data.table,repos=http://R-Forge.R-project.org;) library(data.table) f3 - function(frame) { + frame - as.data.table(frame) + frame[, lapply(.SD[,2:ncol(.SD), with = FALSE], + function(x) x / mean(x, na.rm = TRUE)), + by = group] + } system.time(new.frame2 - f2(frame)) # ave user system elapsed 0.50 0.08 1.24 system.time(new.frame3 - f3(frame)) # data.table user system elapsed 0.25 0.01 0.30 - Tom Tom Short On Wed, Apr 7, 2010 at 12:46 PM, Dimitri Liakhovitski ld7...@gmail.com wrote: I would like to thank once more everyone who helped me with this question. I compared the speed for different approaches. Below are the results of my comparisons - in case anyone is interested: ### Building an EXAMPLE FRAME with N rows - with groups and a lot of NAs: N-10 set.seed(1234) frame-data.frame(group=rep(paste(group,1:10),N/10),a=rnorm(1:N),b=rnorm(1:N),c=rnorm(1:N),d=rnorm(1:N),e=rnorm(1:N),f=rnorm(1:N),g=rnorm(1:N)) frame-frame[order(frame$group),] ## Introducing 60% NAs: names.used-names(frame)[2:length(frame)] set.seed(1234) for(i in names.used){ i.for.NA-sample(1:N,round((N*.6),0)) frame[[i]][i.for.NA]-NA } lapply(frame[2:8], function(x) length(x[is.na(x)])) # Checking that it worked ORIGframe-frame ## placeholder for the unchanged original frame ### Objective of the code - divide each value by its group mean ### METHOD 1 - the FASTEST - using ave():## frame-ORIGframe f2 - function(frame) { for(i in 2:ncol(frame)) { frame[,i] - ave(frame[,i], frame[,1], FUN=function(x)x/mean(x,na.rm=TRUE)) } frame } system.time({new.frame-f2(frame)}) # Took me 0.23-0.27 sec ### ### METHOD 2 - fast, just a bit slower - using data.table: ## # If you don't have it - install the package - NOT from CRAN: install.packages(data.table,repos=http://R-Forge.R-project.org;) library(data.table) frame-ORIGframe system.time({ table-data.table(frame) colMeanFunction-function(data,key){ data[[key]]=NULL ret=as.matrix(data)/matrix(rep(as.numeric(colMeans(as.data.frame(data),na.rm=T)),nrow(data)),nrow=nrow(data),ncol=ncol(data),byrow=T) return(ret) } groupedMeans = table[,colMeanFunction(.SD, group), by=group] names.to.use-names(groupedMeans) for(i in 1:length(groupedMeans)){groupedMeans[[i]]-as.data.frame(groupedMeans[[i]])} groupedMeans-do.call(cbind, groupedMeans) names(groupedMeans)-names.to.use }) # Took me 0.37-.45 sec ### ### METHOD 3 - fast, a tad slower (using model.matrix matrix multiplication):## frame-ORIGframe system.time({ mat - as.matrix(frame[,-1]) mm - model.matrix(~0+group,frame) col.grp.N - crossprod( !is.na(mat), mm ) # Use this line if don't want to use NAs for mean calculations # col.grp.N - crossprod( mat != 0 , mm ) # Use this line if don't want to use zeros for mean calculations mat[is.na(mat)] - 0.0 col.grp.sum - crossprod( mat, mm ) mat - mat / ( t(col.grp.sum/col.grp.N)[ frame$group,] ) is.na(mat) - is.na(frame[,-1]) mat-as.data.frame(mat) }) # Took me 0.44-0.50 sec ### ###
Re: [R] It This data viz possible in R?
On 04/08/2010 12:44 AM, Gabor Grothendieck wrote: There is draw.arc in the plotrix package. Well, draw.arc is specified by center, radius and start/finish angles, so it would be a lot of calculation to get these from the two points that must be joined on the circumference. I would probably translate this into the Postscript arct command, as you would probably have to use the Postscript or similar device to get a decent image. I programmed something similar, but a lot simpler, some years ago in Postscript and it worked out pretty well. Getting the correct angle for the text was tricky, you can see how some of the text on the example is upside down. 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] Question about simple.median.test
I am studying Using R for Introductory Statistics and find it in general very useful. At present, I am stumbling over the function simple.median.test. x [1] 12.8 3.5 2.9 9.4 8.7 0.7 0.2 2.8 1.9 2.8 3.1 15.8 simple.median.test (x,median=5) [1] 0.3876953 simple.median.test (x,median=10) [1] 0.03857422 until here it is identical to the document. Then I played for myself: simple.median.test (x,median=3) [1] 1.225586 The result is 1 here. Is my interpretation wrong, that the result is a probability? Uwe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] kriging problem - very urgent
Please consider using the R-sig-geo list for kriging questions. In fact, using str() would show that your z is badly impacted by your misuse of the c() function - this was almost certainly not what you wanted to do. Constructing your coordinates by using seq() is always a bad idea, as you need to be very careful in assigning position to data. Start by making sure that your (long, lat) matrix of coordinates is correctly associated with the data (you speak of a matrix with missing values - think of it as a vector, or use an sp function to convert from image format to a SpatialGridDataFrame, and coerce to a SpatialPixelsDataFrame). In fact, if your data are on a grid, it is more than puzzling for what purpose you want to use kriging interpolation, unless to hope to change resolution, or fill in the missing values. You need to think much more carefully about your data representations. Those used in the gstat package were chosen to avoid slip-ups with input data (and output data), and use by default classes defined in the sp package. Have you consulted the Spatial task view on CRAN? Hope this helps, Roger karine heerah wrote: Hi everybody, I have a longitude vector and a latitude one. Associated to these coordinates, i have a matrix with some data at some coordinates but not all. Lon - seq(136.025,144.975,0.05) Lat - rev(seq(-66.975,-65.525,0.05)) dim(z) - c(Lon,Lat) And i have tried to apply to these data a kriging function. But first i need to reshape these 3 variables to have a dataframe with these and with the corresponding z values with the good coordinates. Do you know how i can do that? And i will have the same problem with the object that return the krige function (gstat package). It gives me a dataframe, and i want a matrix for the prediction. How can i do that, in order to plot it with the image function after. Thanks a lot Karine HEERAH Master 2 , océanographie et environnements marins Université Pierre et Marie Curie (Paris 6) 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 _ [[elided Hotmail spam]] tre téléphone! [[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. - Roger Bivand Economic Geography Section Department of Economics Norwegian School of Economics and Business Administration Helleveien 30 N-5045 Bergen, Norway -- View this message in context: http://n4.nabble.com/kriging-problem-very-urgent-tp1754267p1773886.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] Palette color order in bwplot (lattice violin plot) vs. boxplot
On 08/04/2010 02:11, Felix Andrews wrote: On 8 April 2010 03:34, Luigi Ponti lpo...@inbox.com wrote: Thanks for the hint, Felix: the following code makes it but (don't know why) the median dots disappear. bwplot(count ~ spray, data = InsectSprays, groups = spray, panel = panel.superpose, panel.groups = function(..., box.ratio) { panel.violin(..., varwidth = FALSE, box.ratio = box.ratio, cut = 0) panel.bwplot(..., box.ratio = .1) }, fill = MyPalette ) I tried to change box.dot parameter to no avail. Not sure what is going on here. It would appear that the panel.groups = function(){} is not sure where to read graphical parameters from (just guessing). It would be interesting to know your opinion. The problem is that panel.superpose() passes on arguments 'col.line' and 'col.symbol', but unless otherwise specified, 'col' is passed as NA (which is an invisible color). Thanks -- I made a wrong assumption that there was always a default value different from NA. Your options are to specify pch = |, which is not affected by 'col', OK, this works fine. or to pass 'col' explicitly: bwplot(count ~ spray, data = InsectSprays, groups = spray, panel = panel.superpose, panel.groups = function(..., box.ratio, col) { panel.violin(..., col = col, varwidth = FALSE, box.ratio = box.ratio, cut = 0) panel.bwplot(..., col = black, box.ratio = .1) }, fill = MyPalette, pch = 16 ) Works very well too, and thanks for adding col = col to panel.violin(), which allowed me to control the color of the violins independently as well as to specify parameters inside bwplot() via par.settings = list() without any conflict arising from multiple calls to col=. Kind regards, Luigi [[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] subsetting a matrix with specified no of columns
Hello! All, I am working on 1x1000 matrix say 'mat' and i want to subset this matrix in a fashion that in new matrix i get columns 2,3,9,10,16,17,23,24...so on. That is pair of columns after every interval of 7. I tried following but i got an error which is obvious. dim(mat) [1] 1 10 a=mat[,c(seq(c(2,3),ncol(mat),7))] Warning messages: 1: In if (n 0L) stop(wrong sign in 'by' argument) : the condition has length 1 and only the first element will be used 2: In if (n .Machine$integer.max) stop('by' argument is much too small) : the condition has length 1 and only the first element will be used 3: In if (dd 100 * .Machine$double.eps) return(from) : the condition has length 1 and only the first element will be used 4: In 0L:n : numerical expression has 2 elements: only the first used Is there any other way to do it?? Please, help! regards Lee [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] XML-2.8 not writing indented XML anymore
Hi, just wanted to note this (mild) regression. I tried saveXML(traml) with different compression= and indent= settings, but the output remained in a single line for XML-2.8-1 Without writing to a file the string representation after saveXML() looks quite similar, with the exception of a \n which seems to be at the end in XML-2.6 output and at the beginning (just after the ?xml?) in XML-2.8-1. Nothing major, most annoying is the indentatino stuff, but the \n issue might point to the difference ? The code for my tests is at the end of this mail. Yours, Steffen ### saveXML(traml, file=bug.xml) ?xml version=1.0? TraML xmlns=http://psi.hupo.org/ms/traml; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; version=0.9.4 xsi:schemaLocation=http://psi.hupo.org/ms/traml TraML0.9.4.xsd cvList cv id=MS fullName=Proteomics Standards Initiative Mass Spectrometry Ontology version=2.29.0 URI=http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo/ /cvList /TraMLsneum...@paddy:~/tex/papers/2009tandemms/ sessionInfo() R version 2.10.1 (2009-12-14) x86_64-pc-linux-gnu other attached packages: [1] XML_2.8-1 saveXML(traml) [1] ?xml version=\1.0\?\n\nTraML xmlns=\http://psi.hupo.org/ms/traml\; xmlns:xsi=\http://www.w3.org/2001/XMLSchema-instance\; version=\0.9.4\ xsi:schemaLocation=\http://psi.hupo.org/ms/traml TraML0.9.4.xsd\\n cvList\ncv id=\MS\ fullName=\Proteomics Standards Initiative Mass Spectrometry Ontology\ version=\2.29.0\ URI=\http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo\/\n /cvList\n/TraML ### saveXML(traml, file=bug.xml) ?xml version=1.0? TraML xmlns=http://psi.hupo.org/ms/traml; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; version=0.9.4 xsi:schemaLocation=http://psi.hupo.org/ms/traml TraML0.9.4.xsd cvList cv id=MS fullName=Proteomics Standards Initiative Mass Spectrometry Ontology version=2.29.0 URI=http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo/ /cvList /TraML sessionInfo() R version 2.10.0 (2009-10-26) x86_64-unknown-linux-gnu other attached packages: [1] XML_2.6-0 saveXML(traml) [1] ?xml version=\1.0\?\n TraML xmlns=\http://psi.hupo.org/ms/traml\; xmlns:xsi=\http://www.w3.org/2001/XMLSchema-instance\; version=\0.9.4\ xsi:schemaLocation=\http://psi.hupo.org/ms/traml TraML0.9.4.xsd\\n cvList\ncv id=\MS\ fullName=\Proteomics Standards Initiative Mass Spectrometry Ontology\ version=\2.29.0\ URI=\http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo\/\n /cvList\n/TraML\n ### library(XML) tramlVersion=0.9.4 schemaLocation=http://psi.hupo.org/ms/traml TraML0.9.4.xsd ## ## TraML Root ## traml = xmlTree(tag=TraML, attrs=c( version=tramlVersion, xsi:schemaLocation=schemaLocation), namespaces = c( http://psi.hupo.org/ms/traml;, xsi=http://www.w3.org/2001/XMLSchema-instance;) ) ## ## CV List ## traml$addNode(cvList, close = FALSE) traml$addNode(cv, attrs=c( id=MS, fullName=Proteomics Standards Initiative Mass Spectrometry Ontology, version=2.29.0, URI=http://psidev.cvs.sourceforge.net/*checkout*/psidev/psi/psi-ms/mzML/controlledVocabulary/psi-ms.obo;)) traml$closeTag() ## cvList saveXML(traml) sessionInfo() -- IPB HalleAG Massenspektrometrie Bioinformatik Dr. Steffen Neumann http://www.IPB-Halle.DE Weinberg 3 http://msbi.bic-gh.de 06120 Halle Tel. +49 (0) 345 5582 - 1470 +49 (0) 345 5582 - 0 sneumann(at)IPB-Halle.DE Fax. +49 (0) 345 5582 - 1409 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] subsetting a matrix with specified no of columns
On Apr 8, 2010, at 7:39 AM, Lee William wrote: Hello! All, I am working on 1x1000 matrix say 'mat' and i want to subset this matrix in a fashion that in new matrix i get columns 2,3,9,10,16,17,23,24...so on. That is pair of columns after every interval of 7. I tried following but i got an error which is obvious. a - mat[ , sort( c(seq(2, 1000, by=7), 1 +seq(2, 1000, by=7)))] dim(mat) [1] 1 10 a=mat[,c(seq(c(2,3),ncol(mat),7))] Warning messages: 1: In if (n 0L) stop(wrong sign in 'by' argument) : the condition has length 1 and only the first element will be used 2: In if (n .Machine$integer.max) stop('by' argument is much too small) : the condition has length 1 and only the first element will be used 3: In if (dd 100 * .Machine$double.eps) return(from) : the condition has length 1 and only the first element will be used 4: In 0L:n : numerical expression has 2 elements: only the first used Is there any other way to do it?? Please, help! regards Lee [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help in attach function
On 07/04/2010 4:24 PM, Changbin Du wrote: Hi, r-community, This morning, I MET the following problem several times when I try to attach the data set. When I closed the current console and reopen the R console, the problem disappear. BUt with the time passed on, the problem occurs again. Can anyone help me with this? attach(total) The following object(s) are masked from total ( position 3 ) : acid base cell_evalue cell_hit charged freq_cell freq_hypo freq_intra gene_id gene_name hydrophobic hypo_evalue hypo_hit log_cell log_hypo log_pfam num_cell num_genes operon_id outcome pfam_align pfam_evalue pfam_per_id polar position target total_length It appears you are attaching it multiple times, and never detaching it. So the most recent one masks an earlier one. This is a very easy error to make, which is one reason I always discourage this kind of use of attach(). (There are other common errors associated with it too. Just don't use it.) 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] square root of inverse
On Apr 8, 2010, at 1:45 AM, arindam fadikar wrote: Dear users, How to get a symmetric square root of a positive definite matrix? I have tried using spectral decomposition, but some eigen values come out to be complex. Is there any function in R that can give the symmetric square root of a pd matrix? require(expm) ?sqrtm -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] recoding variables-recode not working
Dear, my variable is numerical indicating how many times smb done test summary(Q12) Min. 1st Qu. MedianMean 3rd Qu.Max.NA's 0. 0. 0. 0.7989 1. 30. 66. I want to change this to categories-- 0=none testing; 1:30=done testing (NA excluded) John, *cut(Q12, breaks=c(0,1,30), include.lowest=TRUE, labels=c('0', '1 and more'))* is working. Only, when I want frequencies (for ex.) for this new 2 categories, R is returning me freq for all 0 to 30. 2010/4/7 John Fox j...@mcmaster.ca Dear Vlatka, It's impossible to know what the problem is without knowing something about your data, which you didn't tell us either in this message or your subsequent one. The recode command should work: (x - c(rep(0, 5), sample(1:30, 5, replace=TRUE))) [1] 0 0 0 0 0 17 27 19 19 2 recode(x, 0='A'; 1:30='B') [1] A A A A A B B B B B The cut command requires include.lowest=TRUE and it helps to spell the labels argument correctly: cut(x, breaks=c(0,1,30), include.lowest=TRUE, labels=c('0', '1 and more')) [1] 0 0 0 0 0 1 and more [7] 1 and more 1 and more 1 and more 1 and more Levels: 0 1 and more I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vlatka Matkovic Puljic Sent: April-07-10 1:31 PM To: r-help@r-project.org Subject: [R] recoding variables-recode not working Hi, I have numerical variable that I want to recode into categories '0' and '1 and more' and do analysis with that data. I have tried various of possibilities to do so, but I am sucked and nothing is working. recode(Q12, 0='A';1:30='B') cut(Q12, breaks=c(0,1,30), lables=c('0', '1 and more')) cat(Q12, 0=0;1-33=1) What should I do to make it right? -- ** Vlatka [[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. -- ** Vlatka MatkoviÄ PuljiÄ 095/8618 171 [[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] recoding variables-recode not working
On Apr 8, 2010, at 8:13 AM, Vlatka Matkovic Puljic wrote: Dear, my variable is numerical indicating how many times smb done test summary(Q12) Min. 1st Qu. MedianMean 3rd Qu.Max.NA's 0. 0. 0. 0.7989 1. 30. 66. I want to change this to categories-- 0=none testing; 1:30=done testing (NA excluded) John, *cut(Q12, breaks=c(0,1,30), include.lowest=TRUE, labels=c('0', '1 and more'))* is working. Only, when I want frequencies (for ex.) for this new 2 categories, R is returning me freq for all 0 to 30. It what fashion are you telling R that you want frequencies? Did you assign the output of cut(Q12, ...) to a new variable? -- David. 2010/4/7 John Fox j...@mcmaster.ca Dear Vlatka, It's impossible to know what the problem is without knowing something about your data, which you didn't tell us either in this message or your subsequent one. The recode command should work: (x - c(rep(0, 5), sample(1:30, 5, replace=TRUE))) [1] 0 0 0 0 0 17 27 19 19 2 recode(x, 0='A'; 1:30='B') [1] A A A A A B B B B B The cut command requires include.lowest=TRUE and it helps to spell the labels argument correctly: cut(x, breaks=c(0,1,30), include.lowest=TRUE, labels=c('0', '1 and more')) [1] 0 0 0 0 0 1 and more [7] 1 and more 1 and more 1 and more 1 and more Levels: 0 1 and more I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Vlatka Matkovic Puljic Sent: April-07-10 1:31 PM To: r-help@r-project.org Subject: [R] recoding variables-recode not working Hi, I have numerical variable that I want to recode into categories '0' and '1 and more' and do analysis with that data. I have tried various of possibilities to do so, but I am sucked and nothing is working. recode(Q12, 0='A';1:30='B') cut(Q12, breaks=c(0,1,30), lables=c('0', '1 and more')) cat(Q12, 0=0;1-33=1) What should I do to make it right? -- ** Vlatka [[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. -- ** Vlatka Matković Puljić 095/8618 171 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Intra-Class correlation psych package missing data
Hello R users, and perhaps William Revelle in particular, I'm curious as to how ICC deals with missing data, so for example you are sampling individuals over set periods in time and one individual is missing or was not recaptured at that given time point - leading to NA in the dataset. My thought was that it should then omit data by individual, but I'm not convinced that that is what it is doing? Does anyone know, I have looked at ?ICC but there is no information there, apologies if I have missed it in any other help file, I have looked, but to no avail! Thanks in advance, Ross -- View this message in context: http://n4.nabble.com/Intra-Class-correlation-psych-package-missing-data-tp1773942p1773942.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] recoding variables-recode not working
Now I have :) Thanx a lot! 2010/4/8 David Winsemius dwinsem...@comcast.net On Apr 8, 2010, at 8:13 AM, Vlatka Matkovic Puljic wrote: Dear, my variable is numerical indicating how many times smb done test summary(Q12) Min. 1st Qu. MedianMean 3rd Qu.Max.NA's 0. 0. 0. 0.7989 1. 30. 66. I want to change this to categories-- 0=none testing; 1:30=done testing (NA excluded) John, *cut(Q12, breaks=c(0,1,30), include.lowest=TRUE, labels=c('0', '1 and more'))* is working. Only, when I want frequencies (for ex.) for this new 2 categories, R is returning me freq for all 0 to 30. It what fashion are you telling R that you want frequencies? Did you assign the output of cut(Q12, ...) to a new variable? -- David. 2010/4/7 John Fox j...@mcmaster.ca Dear Vlatka, It's impossible to know what the problem is without knowing something about your data, which you didn't tell us either in this message or your subsequent one. The recode command should work: (x - c(rep(0, 5), sample(1:30, 5, replace=TRUE))) [1] 0 0 0 0 0 17 27 19 19 2 recode(x, 0='A'; 1:30='B') [1] A A A A A B B B B B The cut command requires include.lowest=TRUE and it helps to spell the labels argument correctly: cut(x, breaks=c(0,1,30), include.lowest=TRUE, labels=c('0', '1 and more')) [1] 0 0 0 0 0 1 and more [7] 1 and more 1 and more 1 and more 1 and more Levels: 0 1 and more I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Vlatka Matkovic Puljic Sent: April-07-10 1:31 PM To: r-help@r-project.org Subject: [R] recoding variables-recode not working Hi, I have numerical variable that I want to recode into categories '0' and '1 and more' and do analysis with that data. I have tried various of possibilities to do so, but I am sucked and nothing is working. recode(Q12, 0='A';1:30='B') cut(Q12, breaks=c(0,1,30), lables=c('0', '1 and more')) cat(Q12, 0=0;1-33=1) What should I do to make it right? -- ** Vlatka [[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. -- ** Vlatka Matkoviæ Puljiæ 095/8618 171 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT -- ** Vlatka Matkoviæ Puljiæ 095/8618 171 [[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] Caret package and lasso
Dear Max, Thanks for the reply. I will wait for your further comment on this. Regards Linda Garcia On Wed, Apr 7, 2010 at 8:03 PM, Max Kuhn mxk...@gmail.com wrote: Linda, Thanks for the example. I did this to make it more reproducible: set.seed(1) X-matrix(rnorm(50*100),nrow=50) y-rnorm(50*1) dimnames(X) colnames(X) - paste(V, 1:nrow(X)) # Applying caret package set.seed(2) con-trainControl(method=cv,number=10) data-NULL data- train(X,y, lasso, metric=RMSE,tuneLength = 10, trControl = con) I see your point here, but this code gives the same results: fit2 - enet(X, y, lambda = 0) predict(fit2, mode = fraction, s = data$bestTune$.fraction, type = coefficient)$coef (at least train() names the predictors). To me, it looks like enet is doing some filtering: dim(X) [1] 50 100 length(fit2$meanx) [1] 56 This appears to be independent of caret. I would contact the package maintainer off-list and ask. Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://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] Question about simple.median.test
On 2010-04-08 4:52, Uwe Dippel wrote: I am studying Using R for Introductory Statistics and find it in general very useful. At present, I am stumbling over the function simple.median.test. x [1] 12.8 3.5 2.9 9.4 8.7 0.7 0.2 2.8 1.9 2.8 3.1 15.8 simple.median.test (x,median=5) [1] 0.3876953 simple.median.test (x,median=10) [1] 0.03857422 until here it is identical to the document. Then I played for myself: simple.median.test (x,median=3) [1] 1.225586 The result is 1 here. Is my interpretation wrong, that the result is a probability? That looks like a bug in simple.median.test, due to simply doubling the one-sided p-value. -Peter Ehlers Uwe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Interest in R Users Group in Dallas, TX?
I would like to know if there is anyone like me interested in an R User Group in Dallas, TX. David Smith at REvolutions was kind enough to help getting it started. My first thought would to have some informal meet ups at some local Dallas locations to discuss overall goals, ideas, wishes of the RUG. The next step would be to nominate and elect a leadership team. Then get the ball rolling to a more formal meet up process with presentations, workshops, and tutorial sessions. Please let me know if there is any interest. [[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] Using read.table to read file created with read.table and qmethod = escape
df - data.frame(a = a\b, v = 4, z = this is Z) write.csv(df, test.csv, row.names = FALSE, quote = FALSE) read.csv(test.csv, quote = ) Unfortunately my real example is more like: df - data.frame(a = a\b, v = 4, z = this is: A, B, C) so quote = F won't work. Can write.table and read.table really be so asymmetric? Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University 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] as.ffdf.data.frame now breaks if using pattern
Ah, I see. Thanks. It works for me too. Best, R. 2010/4/7 Jens Oehlschlägel jens.oehlschlae...@truecluster.com: Ramon, for me this works setwd(d:/tmp) ffd - as.ffdf(d, col_args=list(pattern = paste(getwd(), /fftmp, sep = ))) filename(ffd) $x [1] d:/tmp/fftmp35c34861.ff $y [1] d:/tmp/fftmp5be946bb.ff $z [1] d:/tmp/fftmp26c49ce.ff Jens -Ursprüngliche Nachricht- Von: Ramon Diaz-Uriarte rdia...@gmail.com Gesendet: Apr 7, 2010 7:01:23 PM An: r-help@r-project.org Betreff: as.ffdf.data.frame now breaks if using pattern Dear All, I am using package ff. In version 2.1-1 it was possible to use pattern with as.ffdf.data.frame: d - data.frame(x=1:26, y=letters, z=Sys.time()+1:26) as.ffdf(d, pattern = paste(getwd(), /fftmp, sep = )) With the latest version, the last command crashes. I wonder if the new behavior is intentional or a bug. If intentional, what is the recommended way of using pattern now? Thanks, R. -- Ramon Diaz-Uriarte Structural Biology and Biocomputing Programme Spanish National Cancer Centre (CNIO) http://ligarto.org/rdiaz Phone: +34-91-732-8000 ext. 3019 Fax: +-34-91-224-6972 -- Ramon Diaz-Uriarte Structural Biology and Biocomputing Programme Spanish National Cancer Centre (CNIO) http://ligarto.org/rdiaz Phone: +34-91-732-8000 ext. 3019 Fax: +-34-91-224-6972 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 read.table to read file created with read.table and qmethod = escape
You were using read.csv and not read.table. The following seems to work with using a separator that will probably not appear in the text: df - data.frame(a = a\b, v = 4, z = this is: A, B, C) write.table(df, test.csv, row.names = FALSE, quote = FALSE, sep='\x01') read.table(test.csv, quote = , sep='\x01', header=TRUE) a vz 1 ab 4 this is: A, B, C On Thu, Apr 8, 2010 at 9:07 AM, Hadley Wickham had...@rice.edu wrote: df - data.frame(a = a\b, v = 4, z = this is Z) write.csv(df, test.csv, row.names = FALSE, quote = FALSE) read.csv(test.csv, quote = ) Unfortunately my real example is more like: df - data.frame(a = a\b, v = 4, z = this is: A, B, C) so quote = F won't work. Can write.table and read.table really be so asymmetric? Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University 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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Using read.table to read file created with read.table and qmethod = escape
On Apr 8, 2010, at 9:07 AM, Hadley Wickham wrote: df - data.frame(a = a\b, v = 4, z = this is Z) write.csv(df, test.csv, row.names = FALSE, quote = FALSE) read.csv(test.csv, quote = ) Unfortunately my real example is more like: df - data.frame(a = a\b, v = 4, z = this is: A, B, C) so quote = F won't work. Can write.table and read.table really be so asymmetric? write() is a wrapper for cat() and read() is a wrapper for scan() so the question should really be can cat() and scan() be so asymmetric. Looking at their help pages, I would say that at least some degree of asymmetry is plausible. Perhaps using save() with load() , or dput() with dget(), which are pairings that promise to have symmetry? -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Struggeling with svydesign()
Dear Thomas, Thank you for your informative answer. We used epi.stratasize() to estimate the required sample size per stratum. Notice in the example below that it can select a sample size smaller than 2 in the very small strata. Would you recommend to sample at least two items per stratum or rather to merge some strata a priori until the sample size is at least 2? Or is there a better way to estimate the sample size per stratum? Note that the stratification only aims to get a good geographical coverage (the strata a geographical regions). We are not interested in estimates per stratum. library(epiR) N - c(39, 270, 1060, 1336, 118, 26, 154, 10, 3) epi.stratasize(strata.n = N, strata.mean = 0.9, epsilon = 0.05, method = proportion) $strata.sample [1] 2 15 57 72 6 1 8 1 0 $total.sample [1] 162 The probability of sampling was proportional with the area (larger polygons are more likely to be selected than smaller ones). So we will use weights = I(1/Area), as you suggested. Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek team Biometrie Kwaliteitszorg Gaverstraat 4 9500 Geraardsbergen Belgium Research Institute for Nature and Forest team Biometrics Quality Assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: Thomas Lumley [mailto:tlum...@u.washington.edu] Verzonden: woensdag 7 april 2010 18:51 Aan: ONKELINX, Thierry CC: r-help@r-project.org Onderwerp: Re: [R] Struggeling with svydesign() On Wed, 7 Apr 2010, ONKELINX, Thierry wrote: Dear all, We are analysing some survey data and we are not sure if we are using the correct syntax for our design. The population of interest is a set of 4416 polygons with different sizes ranging from 0.003 to 45.6 ha, 7460 ha in total. Each polygon has a binary attribute (presence/absence) and we want to estimate the probability of presence in the population. We used sampling with replacement weighted by the area of the polygon. The population was stratified using 2 variables: block and type. Each of the 14 blocks is a 20 by 50 km geographical region. Type is a two level factor. Not every level is present in each block. Each block has a Status attribute with two levels: medium (9 blocks) or good (5 blocks). Besides the overall ratio, we would like the estimate the ratio per Status. The samplesize per stratum was calculated with epi.stratasize() from the epiR package. The population size in the 21 strata ranges from 1 to 1158. The sample size ranges from 0 in the blocks with very few polygons (20), 1 in blocks with a low number of polygon (20 - 50) and up to 25 polygons in the largest strata. That sounds strange. If you have a stratified sample and have set the sample size in some strata to be zero, you cannot possibly learn anything about those strata and so you can't get unbiased population estimates. In order to get unbiased estimates and valid standard errors you need at least two samples per stratum. You're going to have to combine some of the strata so that each stratum has at least two observations. Since your design only makes sense if you assume the small, unsampled, strata are similar to some of the larger strata, it should be possible for you to combine them. Does the syntax below represents the data structure above? Any comments are welcome. library(survey) svydesign( id = ~ 1, #no clustering weights = ~ Area, #weighted by the area of the polygon strata = ~ Status + Block + Type, nest = TRUE ) You want strata = ~interaction(Block,Type,drop=TRUE), which specifies a single stage of sampling in which the strata are combinations of Block and Type. The fact that you need drop=TRUE is a bug, which I will fix. # Is Area a correct weighting factor? Or should we use the area divided by the sum of the total area (per stratum?) It's not clear to me from your description whether the probability of sampling a particular region is proportional to its Area or inversely proportional to its Area. If the probability is proportional to Area, the weight would be 1/Area svydesign( id = ~ 1, #no clustering weights = ~ I(1/Area), #weighted by the area of the polygon strata = ~ interaction(Block, Type,drop=TRUE), nest = TRUE ) # The code
Re: [R] How to locate the difference from two data frames
Dear David, Erik and Charles, Thank you for your input. Both mapply() and which() can do the job. Just one exception. If there is a missing value as NA in the data frame a and a data point (either numerical or character) in the corresponding position of b, then mapply() only returns NA for that position rather than FALSE, and which() cannot pick up that position either. Thanks again. Jun On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry cbe...@tajo.ucsd.eduwrote: On Wed, 7 Apr 2010, Jun Shen wrote: Dear all, I understand identical (a,b) will tell me if a and b are exactly the same or not. But what if they are different, is there anyway to tell which element(s) are different? Thanks. which( a != b, arr.ind = TRUE) HTH, Chuck Jun [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 [[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] 3-D response surface using wireframe()
Regarding the screen argument in wireframe(), here is what I understand about how it works after much trial-and-error: After each rotation, new axes are in effect defined for the next rotation as at the start: x is to the right of the 2D view, y is towards the top, and z is positive out of the page towards you. Understanding this reset of coordinate system after each rotation is key to understanding how the sequence of rotations will be done. Rotations follow the right-hand rule: positive angles follow curved fingers of right hand, with thumb pointing in positive direction of associated axis. I labeled a wooden block with axes and turned it in my hand to help me make the initial guess at the sequence of rotations I would want for a given view. Scott Waichler Pacific Northwest National Laboratory P.O. Box 999, Richland, WA 99352 scott.waich...@pnl.gov 509-372-4423, 509-341-4051 (cell) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 read.table to read file created with read.table and qmethod = escape
On Apr 8, 2010, at 9:20 AM, jim holtman wrote: You were using read.csv and not read.table. The following seems to work with using a separator that will probably not appear in the text: Modified Jim's version: df - data.frame(a = a\b, v = 4, z = this is: A, B, C, stringsAsFactors=FALSE) write.table(df, test.csv, row.names = FALSE, quote = FALSE, sep='\x01') df2 -read.table(test.csv, quote = , sep='\x01', header=TRUE, stringsAsFactors=FALSE) a vz 1 ab 4 this is: A, B, C It also works if you create and read them as character vectors with ... , stringsAsFactors=FALSE) although the '' now gets displayed at the console with an escape since it is not a level label. df2$a [1] a\b -- David. On Thu, Apr 8, 2010 at 9:07 AM, Hadley Wickham had...@rice.edu wrote: df - data.frame(a = a\b, v = 4, z = this is Z) write.csv(df, test.csv, row.names = FALSE, quote = FALSE) read.csv(test.csv, quote = ) Unfortunately my real example is more like: df - data.frame(a = a\b, v = 4, z = this is: A, B, C) so quote = F won't work. Can write.table and read.table really be so asymmetric? Hadley -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Time Series question
Hello, I am wondering whether 'R' has a command to produce coefficient estimates for AR/MA model when variance-covariance matrix is given as an input. Thank you very much for your help, MoonJung * Moon Jung Cho Office of Survey Methods Research U.S. Bureau of Labor Statistics 2 Massachusetts Ave. N.E. Washington, D.C. 20212 W) 202-691-7384 Fax) 202-691-7426 [[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] khat and included polygons
Dear list, I have a question regarding the included polygon in the khat function of the splancs library defining the area where points appear. I have not only one simple polygon included, my map includes several islands. I read my map which was a shape file by readShapeSpatial of the maptools library. Then I split up the SpatialPolygonsDataFrame into the included polygons by coor - NULL for (i in 1:[number of polygons]) coor- rbind(coor,m...@polygons[[1]]@polygons[[...@coords) I am using now this newly generated polygon coor in the khat command. k_funk_ca - khat(as.points(cases), coor,s=0:1000) I do not know if there is a problem using multiple polygons that way or if khat produces then only results for the first polygon or even completely wrong results. Does anyone know the answer? Thanks a lot, Sven Schmiedel PhD student at Copenhagen Unversity Danish Cancer Society Institute for Cancer Epidemiology [[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] Halting execution in Rcmdr
Hi, Does anyone know how to halt Rcmdr? If I make an error and execution is taking a very long time. Is there a way to halt it WITHOUT killing Rcmdr or Rconsole? -- View this message in context: http://n4.nabble.com/Halting-execution-in-Rcmdr-tp1773753p1773753.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] bootstrap confidence intervals, non iid
It's possible I have failed to understand your situation (it's not clearly described). If your model captures the dependence structure (e.g. that induced by a common-but-unknown block effect), then in many cases it could be set up to work. If the dependence is of some form not captured in the model, then it might not. -- View this message in context: http://n4.nabble.com/bootstrap-confidence-intervals-non-iid-tp1751619p1770084.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] Blotter: addTxn() method
I was testing some strategy and got very bizarre results (too good). I quickly found, that the problem is in addTxn() method and it is related to the commission parameter. In the description of the method, you can find that the fees will be subtracted. TxnFees: fees associated with the transaction, e.g. commissions. Fees are indicated as negative values and will be subtracted from the transaction value. Optionally, ‘TxnFees’ can also provide a function of two argument quantity and price which permits user-defined transaction costs, possibly as function of transaction volume and price. Here is an example, where the sock is sold and Avg.Cost is actually higher than Price and opposite when the stock is bought. Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost Pos.Qty 2010-03-17-148117.10 17.33080 -17348.13 117.2171-148 2010-03-18 148117.04 17.32192 17304.60 116.9230 0 From my point of view, then the stock is sold, I should get less -17313.47, not more -17348.13. Is it the bug? -- View this message in context: http://n4.nabble.com/Blotter-addTxn-method-tp1773855p1773855.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] Using read.table to read file created with read.table and qmethod = escape
Can write.table and read.table really be so asymmetric? write() is a wrapper for cat() and read() is a wrapper for scan() so the question should really be can cat() and scan() be so asymmetric. Looking at their help pages, I would say that at least some degree of asymmetry is plausible. Perhaps using save() with load() , or dput() with dget(), which are pairings that promise to have symmetry? Why should I have to care about the internal implementation details? This is one of the things that really frustrates me (and other new users of R) - read.table/write.table and read.csv/write.csv are named symmetrically, but do not work symmetrically. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University 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 read.table to read file created with read.table and qmethod = escape
On Thu, Apr 8, 2010 at 8:20 AM, jim holtman jholt...@gmail.com wrote: You were using read.csv and not read.table. The following seems to work with using a separator that will probably not appear in the text: df - data.frame(a = a\b, v = 4, z = this is: A, B, C) write.table(df, test.csv, row.names = FALSE, quote = FALSE, sep='\x01') Perhaps it wasn't clear from my problem statement, but I already have files saved using read.table. And they took about 12 hours to create, so I'd rather not have to resave them all. I just can't believe there is no way to read them in! Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University 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] How to locate the difference from two data frames
On Apr 8, 2010, at 9:47 AM, Jun Shen wrote: Dear David, Erik and Charles, Thank you for your input. Both mapply() and which() can do the job. Just one exception. If there is a missing value as NA in the data frame a and a data point (either numerical or character) in the corresponding position of b, then mapply() only returns NA for that position rather than FALSE, and which() cannot pick up that position either. Thanks again. You seem to have changed the programming challenge from identification to replicating identical(). If so then you can get closer with wrapping isTRUE(all() around the mapply(== , attributes( ...), ...) step, and wrap the == call in isTRUE(all(.)) isTRUE(all(mapply(==, df1, df2)) ) [1] FALSE since all(c(NA, TRUE, TRUE)) == NA and isTRUE(NA) == FALSE -- David. Jun On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 7 Apr 2010, Jun Shen wrote: Dear all, I understand identical (a,b) will tell me if a and b are exactly the same or not. But what if they are different, is there anyway to tell which element(s) are different? Thanks. which( a != b, arr.ind = TRUE) HTH, Chuck Jun [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] use read.table for a partial reading
Hi everyone, I've got a matrix data with 20 variables (V1, V2, V3, ...) and 215 rows (observations). I'm interested to read only the first and second variables using read.table function. How can I do? Thanks in advance. Paolo. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: use read.table for a partial reading
Hi what about some.data - read.table()[ ,1:2] Regards Petr r-help-boun...@r-project.org napsal dne 08.04.2010 16:05:39: Hi everyone, I've got a matrix data with 20 variables (V1, V2, V3, ...) and 215 rows (observations). I'm interested to read only the first and second variables using read.table function. How can I do? Thanks in advance. Paolo. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem using elements in a vector
Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x-rbinom(5200,1,0.5) y-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1,1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so for example, say i have the vector (1,1). it would be 1000 X 1.005 X 1.005 and if the element is 0, then i need to multiply by .995 - i.e. say the vector was (1,1,0) the value would be 1000 X 1.005 X 1.005 X .995. so my questions are these: 1. how do i make R do this automatically for each element and 2. as each term is multiplied, i want to graph the progress of the initial 1000. any help would be greatly appreciated. -- View this message in context: http://n4.nabble.com/R-Problem-using-elements-in-a-vector-tp1774136p1774136.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] Question on using elements of a vector
Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x-rbinom(5200,1,0.5) y-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1,1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so for example, say i have the vector (1,1). it would be 1000 X 1.005 X 1.005 and if the element is 0, then i need to multiply by .995 - i.e. say the vector was (1,1,0) the value would be 1000 X 1.005 X 1.005 X .995. so my questions are these: 1. how do i make R do this automatically for each element and 2. as each term is multiplied, i want to graph the progress of the initial 1000. any help would be greatly appreciated. _ New, Used, Demo, Dealer or Private? Find it at CarPoint.com.au [[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] Accessing elements of plm outputs
Dear all, I've just migrated from STATA to R for runing panel regressions and I was very happy to discover the plm package. However, I have a problem when trying to access the Total Sum of Squares and Residual Sum of Squares on this output: summary(output) Oneway (individual) effect Within Model Call: plm(formula = Y ~ X1 + X2, data = db, model = within) Unbalanced Panel: n=10, T=9-11, N=108 Residuals : Min. 1st Qu. Median 3rd Qu.Max. -6.500 -2.200 -0.374 1.550 8.730 Coefficients : Estimate Std. Error t-value Pr(|t|) X1 113.302650 8.517736 13.302 2e-16 *** X2 -0.084414 0.109625 -0.770 0.4432 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Total Sum of Squares:3208.3 Residual Sum of Squares: 1059.6 F-statistic: 97.3365 on 2 and 96 DF, p-value: 2.22e-16 I would like to do so because I'm running some hundreds times a similar regression and I want to store those results in a vector and then plot them. I've tried to do so with summary(output)[] but neither the Total Sum of Squares or the Residual Sum of Squares are on the list. I would be glad if somebody can help me. Thank you very much! Eduardo Marinho. -- View this message in context: http://n4.nabble.com/Accessing-elements-of-plm-outputs-tp1774143p1774143.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] Problem using elements in a vector
just convert your vector from 0,1 to .995,1.005 and use cumprod On Thu, Apr 8, 2010 at 10:22 AM, Redhwan redhwanza...@hotmail.com wrote: Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x-rbinom(5200,1,0.5) y-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1,1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so for example, say i have the vector (1,1). it would be 1000 X 1.005 X 1.005 and if the element is 0, then i need to multiply by .995 - i.e. say the vector was (1,1,0) the value would be 1000 X 1.005 X 1.005 X .995. so my questions are these: 1. how do i make R do this automatically for each element and 2. as each term is multiplied, i want to graph the progress of the initial 1000. any help would be greatly appreciated. -- View this message in context: http://n4.nabble.com/R-Problem-using-elements-in-a-vector-tp1774136p1774136.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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] Strange csv parsing problem
Hadley, The cause of the count.fields result is the comma in 'nftc,%20' at about column 300 (for me). Since commas between quotes should normally not matter, this must be due to the comma appearing inside escaped quotes, i.e. we have: abc\def,ghi\jkl. Remove the comma and count.fields gives 11 for all rows. From your other post(s) on escaped quotes, I assume that this won't solve your problem with the existing files. (: Try this: create a text file with the lines a,a \bc\ d\e,f\g count.fields(file, sep = ,). [1] 1 1 2 -Peter Ehlers On 2010-04-07 19:26, Hadley Wickham wrote: url- http://dl.dropbox.com/u/41902/22240.csv; read.csv(url)[, 1] [1] oppose NAoppose support read.csv(url, header = F)[, 1] [1] url [2] http://maplight.org/us-congress/bill/109-hr-5825/387248; [3] http://maplight.org/us-congress/bill/110-hr-3546/378743; [4] http://maplight.org/us-congress/bill/111-s-908/365504; [5] http://maplight.org/us-congress/bill/111-hr-3245/373358; count.fields(url, sep = ,) [1] 11 11 11 12 11 This seems like it should be an error - I suspect it might be caused by the escaped quote (\) in line 4 column 432 causing the first column to be treated as column names: read.csv(url, row.names = NULL)[, 1] [1] http://maplight.org/us-congress/bill/109-hr-5825/387248; [2] http://maplight.org/us-congress/bill/110-hr-3546/378743; [3] http://maplight.org/us-congress/bill/111-s-908/365504; [4] http://maplight.org/us-congress/bill/111-hr-3245/373358; Hadley -- Peter Ehlers University of Calgary __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Exchanging zoo object dates
Hi, I have two zoo objects (time series of same frequency) say A and B. I need to exchange A's dates for B's. Is there and easy way? I managed to do it by converting A to a vector and pasting it on a zoo vector (all ones) with B's dates but I wonder if there is an easier way by some zoo command I have overlooked... Thanks in advance, Costas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: Question on using elements of a vector
Hi r-help-boun...@r-project.org napsal dne 08.04.2010 16:23:53: Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x-rbinom(5200,1,0.5) y-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1, 1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so for example, say i have the vector (1,1). it would be 1000 X 1.005 X 1.005 and if the element is 0, then i need to multiply by .995 - i.e. say the vector was (1,1,0) the value would be 1000 X 1.005 X 1.005 X .995. so my questions are these: 1. how do i make R do this automatically for each element and 2. as each term is multiplied, i want to graph the progress of the initial 1000. I am not sure if I understood correctly. Does this do what you want? vec-sample(c(0,1), 10, replace=T) vec.2-vec+1 1000*cumprod(c(0.995, 1.005)[vec.2] Regards Petr any help would be greatly appreciated. _ New, Used, Demo, Dealer or Private? Find it at CarPoint.com.au [[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] C-index and Cox model
Dear all R users, I am building a Cox PH model on a small dataset. I am wondering how to measure the predictive power of my cox model? Normally the ROC curve or Gini value are used in logistic regression model. Is there any similar measurement suitable for Cox model? Also if I use C-index statistic to measure the predictive power, is it a time-dependent value (i.e. do I need to calculate it for each time period?) or we can calculate it as a single value for the whole model ignoring the time? Thank you so much. Bessy -- View this message in context: http://n4.nabble.com/C-index-and-Cox-model-tp1774155p1774155.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] RWeka - Error when attempting to summary() model
Whew, figured it out through trial and error. In case anyone else runs into this problem, the issue ended up being with the data in one of the columns. I knew I didn't have any actual missing values, but one of the columns is a text field which can have the literal value of NA. I guess R was interpreting those as a special case and then running into problems later. When I replaced the NA with another value, the classifier now sees the right number of rows, and I can run a summary() function fine. From: d.dasc...@hotmail.com To: r-help@r-project.org Date: Wed, 7 Apr 2010 18:44:34 -0400 Subject: [R] RWeka - Error when attempting to summary() model I'm a big fan of both Weka and R (quite new at R :) ), and jumped at the chance to use them together. Unfortunately, I'm running into what is probably a dumb error when trying to view info about my model. A Google search turned up 0 hits for the actual error I got (last line), but you all are smarter! My code is below, but basically my data frame (q) is imported via RODBC and has 1586 rows (as you can see from nrow() ). q$Site is the column I hope to classify by using the JRip classifier. When I view the m object, the model seems to have been trained on a lot fewer rows than expected (10 vs 1586?), and the summary() command fails with the error I mentioned I haven't seen anyone run into. My guess is something is wrong with the specification of the training set, but when I add control=Weka_control(F=1) to specify only one fold, the end result is the same with the degenerate confusion matrix error. Is there some other way I should be forcing it to train on more rows? Is that issue related to not being able to generate a confusion matrix? attach(q) nrow(q) [1] 1586 summary(Site) ABCDEF 265190260344329198 m - JRip(Site~.,data=q) m JRIP rules: === (Dinosaur = TRex) = Site=A (3.0/0.0) = Site=B (5.0/2.0) Number of Rules : 2 summary(m) Error in evaluate_Weka_classifier(object, ...) : Cannot set dimnames on degenerate confusion matrix. _ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. N:WL:en-US:WM_HMP:042010_2 [[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. _ The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail. PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5 [[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] Exchanging zoo object dates
Assuming they are of the same length try this: library(zoo) # test data A - zoo(1:3, Sys.Date() + 1:3) B - zoo(4:6, Sys.Date() + 14:16) time(A) - time(B) A 2010-04-22 2010-04-23 2010-04-24 1 2 3 Next time please provide test data with your post. On Thu, Apr 8, 2010 at 10:35 AM, Research risk2...@ath.forthnet.gr wrote: Hi, I have two zoo objects (time series of same frequency) say A and B. I need to exchange A's dates for B's. Is there and easy way? I managed to do it by converting A to a vector and pasting it on a zoo vector (all ones) with B's dates but I wonder if there is an easier way by some zoo command I have overlooked... Thanks in advance, Costas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Using read.table to read file created with read.table and qmethod = escape
On Apr 8, 2010, at 10:01 AM, Hadley Wickham wrote: Can write.table and read.table really be so asymmetric? write() is a wrapper for cat() and read() is a wrapper for scan() so the question should really be can cat() and scan() be so asymmetric. Looking at their help pages, I would say that at least some degree of asymmetry is plausible. Perhaps using save() with load() , or dput() with dget(), which are pairings that promise to have symmetry? Why should I have to care about the internal implementation details? This is one of the things that really frustrates me (and other new users of R) - read.table/write.table and read.csv/write.csv are named symmetrically, but do not work symmetrically. I hope you won't take it amiss if I think it's great that you (in particular) get frustrated. You have already turned frustrations in other areas into productivity tools. I do have one further observation on this one that extends my earlier suggestion regarding the fact that this semi-strange behavior was a factor-type related issue of asymmetry rather than a character-type one: df - data.frame(a = a\b, v = 4, z = this is: A, B, C, stringsAsFactors=FALSE) write.csv(df, test.csv, row.names = FALSE) df2- read.csv(test.csv, header=TRUE, stringsAsFactors=FALSE) df2 a vz 1 ab 4 this is: A, B, C df2$a [1] a\b Might I inquire if anyone know why displaying the dataframe version of the a element is different on the console from the vector version? I think it related to this behavior: df2[[1]] [1] a\b df2[1] a 1 ab Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xts off by one confusion or error
Hullo I may have missed something blindingly obvious here. I'm using xts to handle some timeseries data. I've got daily measurements for 100 years. If I try to reduce the error rate by taking means of each month, I'm getting what at first sight appears to be conflicting information. Here's a small subset to show the problem: A small set of data: vv x 2010-02-01 6.1 2010-02-02 6.1 2010-02-03 6.0 2010-02-04 6.0 2010-02-05 6.0 2010-02-06 6.1 2010-02-07 6.1 2010-02-08 6.1 2010-02-09 6.1 2010-02-10 6.2 Aggregate: aggregate (vv, as.yearmon (index (vv)), mean) Feb 2010 6.08 That's fine. But if I explicitly convert to xts (which the answer ought to be, so this should be a noop), the values shift back by one month: xts (aggregate (vv, as.yearmon (index (vv)), mean)) x Jan 2010 6.08 Just to confirm the classes: class (aggregate (vv, as.yearmon (index (vv)), mean)) [1] zoo class (vv) [1] xts zoo And to confirm that as.yearmon is returning the right month: as.yearmon (index (vv)) [1] Feb 2010 Feb 2010 Feb 2010 Feb 2010 Feb 2010 Feb 2010 [7] Feb 2010 Feb 2010 Feb 2010 Feb 2010 This run was on a stock Fedora 10 build: version _ platform i386-redhat-linux-gnu arch i386 os linux-gnu system i386, linux-gnu status major 2 minor 10.0 year 2009 month 10 day26 svn rev50208 language R version.string R version 2.10.0 (2009-10-26) And from installed.packages (): xtsNA NA GPL-32.10.0 zooNA NA GPL-22.10.0 Any help gratefully received. Tim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Strange csv parsing problem
Remove the comma and count.fields gives 11 for all rows. From your other post(s) on escaped quotes, I assume that this won't solve your problem with the existing files. (: Right - but assuming I'm not crazy, that should cause an error in read.csv, right? It shouldn't just parse the file regardless. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University 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] Reading dates in R using SQL and otherwise (and some interesting behavior by the data editor)
Hello Everyone,  I am a newbie with about a month's worth of experience using R. I've just spent a little time learning how to work with date values. Mostly, this has involved converting text values into dates.  So far, I've managed to figure out how to do this in R proper using as.Date. However, I'm still struggling with doing this using SQL and RODBC.  In the process of learning to create date values in R proper, I noticed some interesting behavior on the part of the data editor. At first, this led me to believe that my efforts had been unsuccessful. The output from my R console below illustrates this behavior.  test - mydata test$test_date - as.Date(test$ae_datestarted, format='%m/%d/%Y') class(test$test_date) [1] Date mode(test$test_date) [1] numeric fix(test)  (At this point, I clicked on the test_date column) Warning: class discarded from column âtest_dateâ class(test$test_date) [1] character mode(test$test_date) [1] character  When I run my code, it works correctly. But when I open the data frame in the data editor and click on the test_date column, the editor says that it is character. And beyond that, the editor discards the class for test_date. Should the editor do this? Or is it my fault for trying to look at test_date in the editor in the first place? In SAS, I'm used to creating data and then opening the dataset to look at what I've done. Maybe I shouldn't be doing this in R though.  Returning to the issue of converting text values to dates using SQL (Server) and RODBC. Does anyone know how ot do this? I've been trying to do this using things like Cast and Convert. Usually, these attempts fail. When SQL Server does seem to be sending something back, it appears that R cannot accept it. Any help with this problem would be greatly appreciated.  Thanks,  Paul      __ [[elided Yahoo spam]] avourite sites. Download it now [[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] Extracting specific rows from irregular zoo object and merging with a regular zoo object
Hello, everyone I have the following problem: Say I have an irregular zoo timeseries like this: a - zoo(rep(1:9), as.Date(c(2009-03-20, 2009-03-27, 2009-04-24, 2009-04-25, 2009-04-30, 2009-05-15, 2009-05-22, 2009-05-29, 2009-06-26))) and I have regular zoo timeseries like this: b - zoo(rep(1:4), as.Date(c(2009-03-31, 2009-04-30, 2009-05-31, 2009-06-30))) From a I need to extract those rows that hold values for the last day of each month (creating series c). Then I have to merge these values with b, such that the result has the index of c. How could I do this most efficiently? Thank you in advance! Best, Sergey -- Simplicity is the last step of art./Bruce Lee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] square root of inverse
On Thu, Apr 8, 2010 at 5:38 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 8, 2010, at 1:45 AM, arindam fadikar wrote: Dear users, How to get a symmetric square root of a positive definite matrix? I have tried using spectral decomposition, but some eigen values come out to be complex. Is there any function in R that can give the symmetric square root of a pd matrix? require(expm) ?sqrtm expm is not a package, but a function which gives exp of a matrix, and i dont get any result from ?sqrtm. Please help. -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[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] plm package twoways effect problem
Hello everyone, I have a peoblem to create the twoways effect in the plm package. when i try to create the following dsn1-plm(lnQ~lnC+lnL+lnM+lnE+eco+RD,data=newdata,effect=twoways,model=within) i have this error: Error in rep.int(c(1, numeric(n)), n - 1L) : negative length vectors are not allowed and to be honest i have no idea what does it mean!! can someone give me any idea what it would mean? Thank you for your help in advance -- View this message in context: http://n4.nabble.com/plm-package-twoways-effect-problem-tp1774246p1774246.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] Extracting specific rows from irregular zoo object and merging with a regular zoo object
Omit rep. You just want a - zoo(1:9, ...). To get the last day of the month you don`t need b since as.Date.yearmon will give it with the argument frac = 1: aggregate(a, as.Date(as.yearmon(time(a)), frac = 1), tail, 1) 2009-03-31 2009-04-30 2009-05-31 2009-06-30 2 5 8 9 On Thu, Apr 8, 2010 at 11:18 AM, Sergey Goriatchev serg...@gmail.com wrote: Hello, everyone I have the following problem: Say I have an irregular zoo timeseries like this: a - zoo(rep(1:9), as.Date(c(2009-03-20, 2009-03-27, 2009-04-24, 2009-04-25, 2009-04-30, 2009-05-15, 2009-05-22, 2009-05-29, 2009-06-26))) and I have regular zoo timeseries like this: b - zoo(rep(1:4), as.Date(c(2009-03-31, 2009-04-30, 2009-05-31, 2009-06-30))) From a I need to extract those rows that hold values for the last day of each month (creating series c). Then I have to merge these values with b, such that the result has the index of c. How could I do this most efficiently? Thank you in advance! Best, Sergey -- Simplicity is the last step of art./Bruce Lee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] square root of inverse
try this, install.packages(expm, repos=http://R-Forge.R-project.org;) On 8 April 2010 17:28, arindam fadikar arindam.fadi...@gmail.com wrote: On Thu, Apr 8, 2010 at 5:38 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 8, 2010, at 1:45 AM, arindam fadikar wrote: Dear users, How to get a symmetric square root of a positive definite matrix? I have tried using spectral decomposition, but some eigen values come out to be complex. Is there any function in R that can give the symmetric square root of a pd matrix? require(expm) ?sqrtm expm is not a package, but a function which gives exp of a matrix, and i dont get any result from ?sqrtm. Please help. -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Extracting specific rows from irregular zoo object and merging with a regular zoo object
Thank you, Gabor! This is a very elegant solution. But instead of general last day of month in the index, how can I have last day of each month as they are presented in a, for example, not March 31, but March 27? Regards, Sergey On Thu, Apr 8, 2010 at 17:27, Gabor Grothendieck ggrothendi...@gmail.com wrote: Omit rep. You just want a - zoo(1:9, ...). To get the last day of the month you don`t need b since as.Date.yearmon will give it with the argument frac = 1: aggregate(a, as.Date(as.yearmon(time(a)), frac = 1), tail, 1) 2009-03-31 2009-04-30 2009-05-31 2009-06-30 2 5 8 9 On Thu, Apr 8, 2010 at 11:18 AM, Sergey Goriatchev serg...@gmail.com wrote: Hello, everyone I have the following problem: Say I have an irregular zoo timeseries like this: a - zoo(rep(1:9), as.Date(c(2009-03-20, 2009-03-27, 2009-04-24, 2009-04-25, 2009-04-30, 2009-05-15, 2009-05-22, 2009-05-29, 2009-06-26))) and I have regular zoo timeseries like this: b - zoo(rep(1:4), as.Date(c(2009-03-31, 2009-04-30, 2009-05-31, 2009-06-30))) From a I need to extract those rows that hold values for the last day of each month (creating series c). Then I have to merge these values with b, such that the result has the index of c. How could I do this most efficiently? Thank you in advance! Best, Sergey -- Simplicity is the last step of art./Bruce Lee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Simplicity is the last step of art./Bruce Lee The more you know, the more you know you don't know. /Myself I'm not young enough to know everything. /Oscar Wilde Experience is one thing you can't get for nothing. /Oscar Wilde When you are finished changing, you're finished. /Benjamin Franklin Luck is where preparation meets opportunity. /George Patten Kniven skärpes bara mot stenen. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] square root of inverse
On Thu, 8 Apr 2010, arindam fadikar wrote: On Thu, Apr 8, 2010 at 5:38 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 8, 2010, at 1:45 AM, arindam fadikar wrote: Dear users, How to get a symmetric square root of a positive definite matrix? I have tried using spectral decomposition, but some eigen values come out to be complex. Is there any function in R that can give the symmetric square root of a pd matrix? require(expm) ?sqrtm expm is not a package, but a function which gives exp of a matrix, and i dont get any result from ?sqrtm. Please help. install.packages(expm, repos=http://R-Forge.R-project.org;) HTH, Chuck -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] square root of inverse
On Apr 8, 2010, at 11:28 AM, arindam fadikar wrote: On Thu, Apr 8, 2010 at 5:38 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 8, 2010, at 1:45 AM, arindam fadikar wrote: Dear users, How to get a symmetric square root of a positive definite matrix? I have tried using spectral decomposition, but some eigen values come out to be complex. Is there any function in R that can give the symmetric square root of a pd matrix? require(expm) ?sqrtm expm is not a package, but a function which gives exp of a matrix, and i dont get any result from ?sqrtm. Please help. It most assuredly _is_ a package. It's on R-forge rather than on CRAN. Since you apparently have the Matrix package loaded, you are seeing a different version of expm (the function). You might also try searching about this topic: RSiteSearch(complex square root matrix) Information on package 'expm' Description: Package: expm Type: Package Title: Matrix exponential Version: 0.96-2 Date: 2009-06-06 Author:Vincent Goulet, Christophe Dutang, Martin Maechler, David Firth, Marina Shapira, Michael Stadelmann Maintainer:Expm Developers expm-develop...@lists.r-forge.r-project.org -- David -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strange csv parsing problem
On 2010-04-08 9:10, Hadley Wickham wrote: Remove the comma and count.fields gives 11 for all rows. From your other post(s) on escaped quotes, I assume that this won't solve your problem with the existing files. (: Right - but assuming I'm not crazy, that should cause an error in read.csv, right? It shouldn't just parse the file regardless. I don't think you're crazy. I would have expected an error, too. Maybe read.table should run count.fields first. But I haven't looked at the code yet. -Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 3-D response surface using wireframe()
Scott, This is a good explanation and a good practice. Thank you, John --- On Thu, 4/8/10, Waichler, Scott R scott.waich...@pnl.gov wrote: From: Waichler, Scott R scott.waich...@pnl.gov Subject: Re: 3-D response surface using wireframe() To: arrayprof...@yahoo.com arrayprof...@yahoo.com Cc: r-help@r-project.org r-help@r-project.org Date: Thursday, April 8, 2010, 9:51 AM Regarding the screen argument in wireframe(), here is what I understand about how it works after much trial-and-error: After each rotation, new axes are in effect defined for the next rotation as at the start: x is to the right of the 2D view, y is towards the top, and z is positive out of the page towards you. Understanding this reset of coordinate system after each rotation is key to understanding how the sequence of rotations will be done. Rotations follow the right-hand rule: positive angles follow curved fingers of right hand, with thumb pointing in positive direction of associated axis. I labeled a wooden block with axes and turned it in my hand to help me make the initial guess at the sequence of rotations I would want for a given view. Scott Waichler Pacific Northwest National Laboratory P.O. Box 999, Richland, WA 99352 scott.waich...@pnl.gov 509-372-4423, 509-341-4051 (cell) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] general linear hypothesis testing for manova model
Hello, I have a MANOVA model and I want to test the following hypothesis: LBM = 0 where B is the parameter estimates. Is there any function to do this in R? Cheers, Philippe -- Philippe Hupé Institut Curie, CNRS UMR 144, INSERM U900 26 rue d'Ulm 75005 Paris - France Email : philippe.h...@curie.fr Tél :+33 (0)1 56 24 69 91 Fax: +33 (0)1 56 24 69 11 website : http://bioinfo.curie.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 specific rows from irregular zoo object and merging with a regular zoo object
On Thu, Apr 8, 2010 at 11:42 AM, Sergey Goriatchev serg...@gmail.com wrote: Thank you, Gabor! This is a very elegant solution. But instead of general last day of month in the index, how can I have last day of each month as they are presented in a, for example, not March 31, but March 27? Try this: a[!duplicated(as.yearmon(time(a)), fromLast = TRUE)] 2009-03-27 2009-04-30 2009-05-29 2009-06-26 2 5 8 9 or this: last.date - ave(time(a), as.yearmon(time(a)), FUN = function(x) tail(x, 1)) aggregate(a, last.date, tail, 1) 2009-03-27 2009-04-30 2009-05-29 2009-06-26 2 5 8 9 Note that the examples in ?aggregate.zoo include some that are very similar examples are shown here. Also see ?ave . __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem using elements in a vector
This reads like homework. You should show some evidence where you are stuck or pick up an R book/manual/introduction after which you should be able to do this yourself quite easily. Daniel - cuncta stricte discussurus - - cuncta stricte discussurus - -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Redhwan Sent: Thursday, April 08, 2010 10:22 AM To: r-help@r-project.org Subject: [R] Problem using elements in a vector Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x-rbinom(5200,1,0.5) y-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1,1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so for example, say i have the vector (1,1). it would be 1000 X 1.005 X 1.005 and if the element is 0, then i need to multiply by .995 - i.e. say the vector was (1,1,0) the value would be 1000 X 1.005 X 1.005 X .995. so my questions are these: 1. how do i make R do this automatically for each element and 2. as each term is multiplied, i want to graph the progress of the initial 1000. any help would be greatly appreciated. -- View this message in context: http://n4.nabble.com/R-Problem-using-elements-in-a-vector-tp1774136p1774136. html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Struggeling with svydesign()
On Thu, 8 Apr 2010, ONKELINX, Thierry wrote: Dear Thomas, Thank you for your informative answer. We used epi.stratasize() to estimate the required sample size per stratum. Notice in the example below that it can select a sample size smaller than 2 in the very small strata. Would you recommend to sample at least two items per stratum or rather to merge some strata a priori until the sample size is at least 2? Merging the strata would be best Or is there a better way to estimate the sample size per stratum? Note that the stratification only aims to get a good geographical coverage (the strata a geographical regions). We are not interested in estimates per stratum. library(epiR) N - c(39, 270, 1060, 1336, 118, 26, 154, 10, 3) epi.stratasize(strata.n = N, strata.mean = 0.9, epsilon = 0.05, method = proportion) $strata.sample [1] 2 15 57 72 6 1 8 1 0 $total.sample [1] 162 The probability of sampling was proportional with the area (larger polygons are more likely to be selected than smaller ones). So we will use weights = I(1/Area), as you suggested. If you are using probability proportional to size and you want to use finite-population correctsions, you also need to specify the fpc= argument differently. The simplest version is an approximation that uses only the marginal sampling probabilities svydesign(id=~1, fpc=~p, pps=brewer, strata=~strat where p is a variable with the actual sampling probability (not just proportional to sampling probability). Also, how did you do the sampling? It's quite hard to do unequal probability sampling without replacement (the R sample() function doesn't actually do it, though the sampling package does). -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity 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] Error in leaps.setup
On Wed, 7 Apr 2010, thedoctor81877 wrote: Hullo, I am trying to use the leaps package, keep getting the following error: Error in leaps.setup(x, y, wt = wt, nbest = nbest, nvmax = NCOL(x) + int, : y and x different lengths x might be a data frame rather than a matrix. In any case, although you don't say, my psychic debugging powers tell me that you are using the leaps() function from the package. Use regsubsets() instead. As the help page indicates, leaps() is just there for compatibility with S-PLUS. My data set is attached below. No, it isn't. It may have been stripped off by the mailing list. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity 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] subsetting a matrix with specified no of columns
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Lee William Sent: Thursday, April 08, 2010 4:40 AM To: r-help@r-project.org Subject: [R] subsetting a matrix with specified no of columns Hello! All, I am working on 1x1000 matrix say 'mat' and i want to subset this matrix in a fashion that in new matrix i get columns 2,3,9,10,16,17,23,24...so on. That is pair of columns after every interval of 7. I tried following but i got an error which is obvious. dim(mat) [1] 1 10 a=mat[,c(seq(c(2,3),ncol(mat),7))] You could use a logical subscript like a - mat[ , seq_len(ncol(mat))%%7 %in% c(2,3)] Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com Warning messages: 1: In if (n 0L) stop(wrong sign in 'by' argument) : the condition has length 1 and only the first element will be used 2: In if (n .Machine$integer.max) stop('by' argument is much too small) : the condition has length 1 and only the first element will be used 3: In if (dd 100 * .Machine$double.eps) return(from) : the condition has length 1 and only the first element will be used 4: In 0L:n : numerical expression has 2 elements: only the first used Is there any other way to do it?? Please, help! regards Lee [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help in attach function
Thanks so much! Duncan, I appreciated! On Thu, Apr 8, 2010 at 5:03 AM, Duncan Murdoch murd...@stats.uwo.ca wrote: On 07/04/2010 4:24 PM, Changbin Du wrote: Hi, r-community, This morning, I MET the following problem several times when I try to attach the data set. When I closed the current console and reopen the R console, the problem disappear. BUt with the time passed on, the problem occurs again. Can anyone help me with this? attach(total) The following object(s) are masked from total ( position 3 ) : acid base cell_evalue cell_hit charged freq_cell freq_hypo freq_intra gene_id gene_name hydrophobic hypo_evalue hypo_hit log_cell log_hypo log_pfam num_cell num_genes operon_id outcome pfam_align pfam_evalue pfam_per_id polar position target total_length It appears you are attaching it multiple times, and never detaching it. So the most recent one masks an earlier one. This is a very easy error to make, which is one reason I always discourage this kind of use of attach(). (There are other common errors associated with it too. Just don't use it.) Duncan Murdoch -- Sincerely, Changbin -- Changbin Du DOE Joint Genome Institute Bldg 400 Rm 457 2800 Mitchell Dr Walnut Creet, CA 94598 Phone: 925-927-2856 [[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] reshape panel data
I have a data set with observations on 549 cities spanning an 18 year period. However, some of cities did not report in one or more of the 18 years. I would like to implement the procedure suggested by Wooldridge section 17.1.3 in his Econometric analysis of cross section and panel data to correct for attrition. For example the table below indicates that the 3rd and the 7th cities in the data set do not have observations for several years. The Wooldridge procedure requires the generation of a selection variable that takes on the value of 1 if the city reports in that year and 0 otherwise. How do I assign a zero to a city when it does not have an observation for that year? For example. Suppose I have the following data set. The observation range over three years 1990-1992. But some cities did not report in some years. The original data looks like this: Cicoidyear other_variables seclection-variable 1 1990 x x x x x x x 1 1 1991 xx 1 2 1991 xx 1 3 1990 xx 1 3 1991 xx 1 3 1992 xx 1 I would like to get a data set that looks like this: Cicoidyear other_variables seclection-variable 1 1990 x x x x x x x1 1 1991 xx 1 1 1992 ... 0 2 1990 0 2 1991 xx 1 2 1992 0 3 1990 xx 1 3 1991 xx 1 3 1992 xx 1 I can reshape the data using STATA with the following three simple commands: xtset Cicoid year tsfill ,full replace selection_variable=0 if selection_variable==. I proclaim the data as a panel series identifying the ID and TIME index variables. Then use the time-series fill command. I have searched the help and vignettes of both the zoo and plm packages but cannot find the solution. Can anyone help? Thanks, Richard Saba __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] texi2dvi runs but produces no output
I am working on a Windows XP machine with R 2.10.1 and a recent installation of MiKTeX 2.8. I use LyX (www.lyx.org) to write documents and have it set up to run Sweave, Stangle, and make the PDF through R using a batch script and a MakeSweave.R file. This system worked just fine until I ran some MiKTeX updates yesterday. This is a bit embarrassing as I helped produce a How-to guide to getting this working that is posted at the LyX Wiki (http://wiki.lyx.org/LyX/LyxWithRThroughSweave). After the updates yesterday, everything goes smoothly except that the code in the MakeSweave.R file that runs texi2dvi seems not to produce a PDF but gives no warnings or errors. The contents of the batch file are: Rterm --no-site-file --no-save -f C:/Program Files/LyX 1.6.5/bin/MakeSweave.R --args %1 The batch file is called in the temporary directory where LyX does its work, which is also open to all access. I have to admit that I still confused on the --args %1 part, but I can see that it works in the console transcript. The MakeSweave.R contents are: library(tools) args - commandArgs() filename - args[length(args)] Sweave(filename) Stangle(filename) basename - sub(\\.(Rnw|Rtex|nw)$, , filename) texi2dvi(paste(basename, .tex, sep=), pdf=TRUE) I run LyX from a command window and watch what goes on in the background. All goes fine through the whole process, texi2dvi runs and finishes, and then LyX pukes an error that it cannot open the PDF because the PDF does not exist. Indeed, if I check the temp directory for LyX, all files are present but the PDF. I get no other warnings or errors from texi2dvi and cannot figure out why this happens. In case it helps, I can run example(Sweave) and then texi2dvi(Sweave-test-1.tex, pdf=TRUE) and the same thing happens. No PDF. Can someone help me figure out why texi2dvi fails to produce a PDF? A potential complication (as always) is that I am working in a non-Admin account on the machine. I can invoke Admin permissions to change things and had managed to get everything working before. Permissions may be an issue, but I have set full access to all the folders involved in this process (R, LyX, MiKTeX bins for example), and this got it working prior to updates. I am hoping that is not it. It seems like an issue with texi2dvi. Dave Hewitt Research Fishery Biologist USGS Western Fisheries Research Center Klamath Falls Field Station, Oregon http://profile.usgs.gov/dhewitt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] general linear hypothesis testing for manova model
Dear Philippe, The linear.hypothesis() function in the car package should do what you want. I hope this helps, John John Fox Senator William McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Philippe Hupé Sent: April-08-10 12:03 PM To: R-help Subject: [R] general linear hypothesis testing for manova model Hello, I have a MANOVA model and I want to test the following hypothesis: LBM = 0 where B is the parameter estimates. Is there any function to do this in R? Cheers, Philippe -- Philippe Hupé Institut Curie, CNRS UMR 144, INSERM U900 26 rue d'Ulm 75005 Paris - France Email : philippe.h...@curie.fr Tél : +33 (0)1 56 24 69 91 Fax: +33 (0)1 56 24 69 11 website : http://bioinfo.curie.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] LondonR meeting 4th May
Good afternoon everyone, I am pleased to confirm the details of the next LondonR meeting: Date:Wednesday 4th May Time:6pm - 9pm Venue: The Shooting Star 125- 129 Middlesex Street E1 7JF (Nearest Tubes- Liverpool Street, Moorgate or Bank) I will distribute the agenda as soon as it has been finalised. If you would like to attend, please confirm via email to: lond...@mango-solutions.com As ever, we need volunteers to present at the meeting. If you feel you have something to input into this meeting or can recommend someone else, we would be delighted to hear from you. If you have any suggestions or comments about the event, please let us know. Please do not hesitate to contact me with any queries. Sarah Lewis mangosolutions T: +44 (0)1249 767700 F: +44 (0)1249 767707 Unit 2 Greenways Business Park Bellinger Close Chippenham Wilts SN15 1BN UK LEGAL NOTICE \ This message is intended for the use of...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with mtext
Dear list I am experiencing a very annoying problem with mtext, although I have been using this command for many years. The following code prints test twice in the outer margin, once at .7 where it should be, and once at the bottom somewhere. I also notice that the command takes longer than normal to execute, and it seems to overprint many times. Can anyone reproduce this? Is it a bug? I am on OSX 10.5.8 using R version 2.10.1 Thanks for advice. Sebastian layout(matrix(c(1:6),ncol=1)) par(oma=c(3,3,.5,5)) plot(c(1:10)) plot(c(1:10)) plot(c(1:10)) plot(c(1:10)) plot(c(1:10)) plot(c(1:10)) mtext(side=2,at=.7,test,outer=T,las=0,line=1.7) [[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] I can´t run the example shown in the inline pa ckage
I want to run some R script using the inline package (which allows to create and run inline C++ code in my humble understanding). So, after loading the required packages and copy and paste the example that runs C code (in the Reference Manual as a PDF), I have a compilation error. Any body has ever tried this inline package? -- View this message in context: http://n4.nabble.com/I-can-t-run-the-example-shown-in-the-inline-package-tp1774328p1774328.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] reshape panel data
See: http://n4.nabble.com/panel-data-td1749549.html On Thu, Apr 8, 2010 at 12:55 PM, Richard Saba saba...@auburn.edu wrote: I have a data set with observations on 549 cities spanning an 18 year period. However, some of cities did not report in one or more of the 18 years. I would like to implement the procedure suggested by Wooldridge section 17.1.3 in his Econometric analysis of cross section and panel data to correct for attrition. For example the table below indicates that the 3rd and the 7th cities in the data set do not have observations for several years. The Wooldridge procedure requires the generation of a selection variable that takes on the value of 1 if the city reports in that year and 0 otherwise. How do I assign a zero to a city when it does not have an observation for that year? For example. Suppose I have the following data set. The observation range over three years 1990-1992. But some cities did not report in some years. The original data looks like this: Cicoid year other_variables seclection-variable 1 1990 x x x x x x x 1 1 1991 xx 1 2 1991 xx 1 3 1990 xx 1 3 1991 xx 1 3 1992 xx 1 I would like to get a data set that looks like this: Cicoid year other_variables seclection-variable 1 1990 x x x x x x x 1 1 1991 xx 1 1 1992 ... 0 2 1990 0 2 1991 xx 1 2 1992 0 3 1990 xx 1 3 1991 xx 1 3 1992 xx 1 I can reshape the data using STATA with the following three simple commands: xtset Cicoid year tsfill ,full replace selection_variable=0 if selection_variable==. I proclaim the data as a panel series identifying the ID and TIME index variables. Then use the time-series fill command. I have searched the help and vignettes of both the zoo and plm packages but cannot find the solution. Can anyone help? Thanks, Richard Saba __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RandomForest how to identify two classes when only one is present
I'm trying to do: randomForest(f, data = moths.train) But I get this error: Error in randomForest.default(m, y, ...) : Need at least two classes to do classification. When I look at the data for this, I realize there are no positive cases of this item: [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Levels: 0 Is there a way to show RandomForest that both 0 and 1 are possible and run randomForest? Thanks -- View this message in context: http://n4.nabble.com/RandomForest-how-to-identify-two-classes-when-only-one-is-present-tp1774388p1774388.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to locate the difference from two data frames
David, Thanks for the suggestion. Now I have worked out a general solution. Assume a and b are two data frames with same dimensions 1. Call identical(a,b) to get an overall assessment. If you get a FALSE 2. Call which(mapply(identical,unlist(a),unlist(b))==FALSE), you will get a result like TIME5 85 which means, the row 5 and the column with name TIME is different. This also works for missing values. Thanks for everyone. Jun Shen from Millipore On Thu, Apr 8, 2010 at 9:08 AM, David Winsemius dwinsem...@comcast.netwrote: On Apr 8, 2010, at 9:47 AM, Jun Shen wrote: Dear David, Erik and Charles, Thank you for your input. Both mapply() and which() can do the job. Just one exception. If there is a missing value as NA in the data frame a and a data point (either numerical or character) in the corresponding position of b, then mapply() only returns NA for that position rather than FALSE, and which() cannot pick up that position either. Thanks again. You seem to have changed the programming challenge from identification to replicating identical(). If so then you can get closer with wrapping isTRUE(all() around the mapply(== , attributes( ...), ...) step, and wrap the == call in isTRUE(all(.)) isTRUE(all(mapply(==, df1, df2)) ) [1] FALSE since all(c(NA, TRUE, TRUE)) == NA and isTRUE(NA) == FALSE -- David. Jun On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 7 Apr 2010, Jun Shen wrote: Dear all, I understand identical (a,b) will tell me if a and b are exactly the same or not. But what if they are different, is there anyway to tell which element(s) are different? Thanks. which( a != b, arr.ind = TRUE) HTH, Chuck Jun [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] I can´t run the example shown in the inline package
On Thu, Apr 8, 2010 at 11:32 AM, satu satu2...@live.com.ar wrote: I want to run some R script using the inline package (which allows to create and run inline C++ code in my humble understanding). So, after loading the required packages and copy and paste the example that runs C code (in the Reference Manual as a PDF), I have a compilation error. Any body has ever tried this inline package? Yes. Some of us use it frequently. Perhaps we could be of more help to you if you posted a log of what you tried and what the results were. Read the posting guide (URL given at the bottom of every message on this list) for suggestions on how to do so. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] incomplete final line found by readTableHeader
Hi I am trying this x - read.table(/home/kenji/1245/GDS1_2grps_.cls, header = F, skip = 2) x - read.table(/home/kenji/1246/MYCset.cls, header = F, skip = 2) Warning message: In read.table(/home/kenji/1246/MYCset.cls, header = F, skip = 2) : incomplete final line found by readTableHeader on '/home/kenji/1246/MYCset.cls' Here are the hex's ke...@yule:~$ hd 1245/GDS1_2grps_.cls 31 32 20 32 20 31 0a 23 20 43 44 31 39 2b 20 43 |12 2 1.# CD19+ C| 0010 44 34 30 4c 0a 30 20 30 20 30 20 30 20 30 20 30 |D40L.0 0 0 0 0 0| 0020 20 31 20 31 20 31 20 31 20 31 20 31 0a | 1 1 1 1 1 1.| 002d ke...@yule:~$ hd 1246/ job938_MYC_RMA.gct MYCset.cls .MYCset.cls.swp ke...@yule:~$ hd 1246/MYCset.cls 31 32 20 32 20 31 0a 23 20 4d 59 43 20 4e 6f 74 |12 2 1.# MYC Not| 0010 0a 30 20 30 20 30 20 30 20 30 20 30 20 31 20 31 |.0 0 0 0 0 0 1 1| 0020 20 31 20 31 20 31 20 31 | 1 1 1 1| 0028 So it seems the problem is the linefeed (0a) absent in the second file, probably generated by some evil excel or something like this. My question is: is there any simple way to make read.table robust to deal with this problem? I would like to avoid solutions such as re-implement using scan or asking the user to deal with this for me, changing himself the file. Thanks in advance Leonardo K. Shikida Vetta Labs +55(31)2551-6936 ext 203 http://www.vettalabs.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] incomplete final line found by readTableHeader
On Apr 8, 2010, at 2:14 PM, Leonardo K. Shikida wrote: Hi I am trying this x - read.table(/home/kenji/1245/GDS1_2grps_.cls, header = F, skip = 2) x - read.table(/home/kenji/1246/MYCset.cls, header = F, skip = 2) Warning message: In read.table(/home/kenji/1246/MYCset.cls, header = F, skip = 2) : incomplete final line found by readTableHeader on '/home/kenji/1246/MYCset.cls' Here are the hex's ke...@yule:~$ hd 1245/GDS1_2grps_.cls 31 32 20 32 20 31 0a 23 20 43 44 31 39 2b 20 43 |12 2 1.# CD19+ C| 0010 44 34 30 4c 0a 30 20 30 20 30 20 30 20 30 20 30 |D40L.0 0 0 0 0 0| 0020 20 31 20 31 20 31 20 31 20 31 20 31 0a | 1 1 1 1 1 1.| 002d ke...@yule:~$ hd 1246/ job938_MYC_RMA.gct MYCset.cls .MYCset.cls.swp ke...@yule:~$ hd 1246/MYCset.cls 31 32 20 32 20 31 0a 23 20 4d 59 43 20 4e 6f 74 |12 2 1.# MYC Not| 0010 0a 30 20 30 20 30 20 30 20 30 20 30 20 31 20 31 |.0 0 0 0 0 0 1 1| 0020 20 31 20 31 20 31 20 31 | 1 1 1 1| 0028 So it seems the problem is the linefeed (0a) absent in the second file, probably generated by some evil excel or something like this. My question is: is there any simple way to make read.table robust to deal with this problem? I would like to avoid solutions such as re-implement using scan or asking the user to deal with this for me, changing himself the file. Did the line get read? (I have failed in my efforts on a Mac to create a file with a text editor that throws that warning.) In a sense it appears to already be robust , since it only generated a warning, rather than an error. If you want to programmatically turn off warnings, then: ?warnings ?options # with a bunch of settings for warn Perhaps inside your function you could call set warn = -1 the restore to =0 before exit. options(warn=-1) read.table( ... ) options(warn=0) Thanks in advance Leonardo K. Shikida Vetta Labs +55(31)2551-6936 ext 203 http://www.vettalabs.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] incomplete final line found by readTableHeader
sorry, it was read, indeed. TIA Leonardo K. Shikida Vetta Labs +55(31)2551-6936 ext 203 http://www.vettalabs.com On Thu, Apr 8, 2010 at 3:43 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 8, 2010, at 2:14 PM, Leonardo K. Shikida wrote: Hi I am trying this x - read.table(/home/kenji/1245/GDS1_2grps_.cls, header = F, skip = 2) x - read.table(/home/kenji/1246/MYCset.cls, header = F, skip = 2) Warning message: In read.table(/home/kenji/1246/MYCset.cls, header = F, skip = 2) : incomplete final line found by readTableHeader on '/home/kenji/1246/MYCset.cls' Here are the hex's ke...@yule:~$ hd 1245/GDS1_2grps_.cls 31 32 20 32 20 31 0a 23 20 43 44 31 39 2b 20 43 |12 2 1.# CD19+ C| 0010 44 34 30 4c 0a 30 20 30 20 30 20 30 20 30 20 30 |D40L.0 0 0 0 0 0| 0020 20 31 20 31 20 31 20 31 20 31 20 31 0a | 1 1 1 1 1 1.| 002d ke...@yule:~$ hd 1246/ job938_MYC_RMA.gct MYCset.cls .MYCset.cls.swp ke...@yule:~$ hd 1246/MYCset.cls 31 32 20 32 20 31 0a 23 20 4d 59 43 20 4e 6f 74 |12 2 1.# MYC Not| 0010 0a 30 20 30 20 30 20 30 20 30 20 30 20 31 20 31 |.0 0 0 0 0 0 1 1| 0020 20 31 20 31 20 31 20 31 | 1 1 1 1| 0028 So it seems the problem is the linefeed (0a) absent in the second file, probably generated by some evil excel or something like this. My question is: is there any simple way to make read.table robust to deal with this problem? I would like to avoid solutions such as re-implement using scan or asking the user to deal with this for me, changing himself the file. Did the line get read? (I have failed in my efforts on a Mac to create a file with a text editor that throws that warning.) In a sense it appears to already be robust , since it only generated a warning, rather than an error. If you want to programmatically turn off warnings, then: ?warnings ?options # with a bunch of settings for warn Perhaps inside your function you could call set warn = -1 the restore to =0 before exit. options(warn=-1) read.table( ... ) options(warn=0) Thanks in advance Leonardo K. Shikida Vetta Labs +55(31)2551-6936 ext 203 http://www.vettalabs.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] erasing an area of a graph
I have a case where the easiest way to draw a particular symbol would be to draw something a little bigger, and then use polygon(... , col=0) to erase the extra stuff. Just how to do this best when par('bg') = 'transparent' is, however, eluding me. I've looked through the archives and the book R Graphics without quite seeing the light. Help or pointers to help would be welcome. Terry T Details (for the inquiring mind). In drawing a pedigree subjects are depicted as cirle, square, diamond, or triangle (for gender= male, female, unknown, terminated). This can be subdivided into shaded regions to show the value of various ancillary variables. One ancillary is easy - just fill with a color. For two you fill the left and right half separately, etc. Two, three, four, ... variables become special cases for each symbol. An easy solution is to draw a larger circle with the requisite number of shaded slices, then erase away what we don't want. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 locate the difference from two data frames
On Apr 8, 2010, at 1:34 PM, Jun Shen wrote: David, Thanks for the suggestion. Now I have worked out a general solution. Assume a and b are two data frames with same dimensions 1. Call identical(a,b) to get an overall assessment. If you get a FALSE 2. Call which(mapply(identical,unlist(a),unlist(b))==FALSE), you will get a result like TIME5 85 which means, the row 5 and the column with name TIME is different. This also works for missing values. Thanks for everyone. Looks that all.equal is already set up to provide such a service: all.equal(df1,df2) [1] Component 1: 'is.NA' value mismatch: 1 in current 0 in target I was under the misimpression that all.equal was for approximate equality of numeric values but that only appears to be part of its design. -- David. Jun Shen from Millipore On Thu, Apr 8, 2010 at 9:08 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 8, 2010, at 9:47 AM, Jun Shen wrote: Dear David, Erik and Charles, Thank you for your input. Both mapply() and which() can do the job. Just one exception. If there is a missing value as NA in the data frame a and a data point (either numerical or character) in the corresponding position of b, then mapply() only returns NA for that position rather than FALSE, and which() cannot pick up that position either. Thanks again. You seem to have changed the programming challenge from identification to replicating identical(). If so then you can get closer with wrapping isTRUE(all() around the mapply(== , attributes( ...), ...) step, and wrap the == call in isTRUE(all(.)) isTRUE(all(mapply(==, df1, df2)) ) [1] FALSE since all(c(NA, TRUE, TRUE)) == NA and isTRUE(NA) == FALSE -- David. Jun On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 7 Apr 2010, Jun Shen wrote: Dear all, I understand identical (a,b) will tell me if a and b are exactly the same or not. But what if they are different, is there anyway to tell which element(s) are different? Thanks. which( a != b, arr.ind = TRUE) HTH, Chuck Jun [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3-D response surface using wireframe()
David, That does the job! Thanks a lot. Now I am very very close to what I want. Still have a couple of small adjustments to make. 1. I use drape=TRUE to draw grid and color on the surface, is there a parameter to adjust the density of the grid? 2. Is there a way that I can add grid to the axis surface? I mean the sides of the box, between x y, between x z, and between y z? And I need to choose which 3 side of the box that I want to add grid? Thank you all for the help. It's fun to play with wireframe John --- On Wed, 4/7/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] 3-D response surface using wireframe() To: array chip arrayprof...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, April 7, 2010, 9:22 PM On Apr 7, 2010, at 8:58 PM, array chip wrote: With the help document, i finally find a set of values of for x=,y= and z= in screen argument that gives me the correct rotation of the plot. But now it plots x and y axis (tick marks and labels) along the top of the plot. Is there one way to plot x and y axis on the bottom of the plot? Look at the scpos argument to specify the scales location. (Still lacking an example and therrefore doing this from memory.) -- David Thanks John --- On Wed, 4/7/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] 3-D response surface using wireframe() To: array chip arrayprof...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, April 7, 2010, 8:07 AM A search with the following strategy: RSiteSearch(lattice wireframe rotate axes) Followed by adding requests to search earlier years' archives produced this link which has a further link to a document that answers most of your questions, at least the ones that are comprehensible: http://tolstoy.newcastle.edu.au/R/e2/help/07/03/12534.html --David. On Apr 6, 2010, at 7:12 PM, array chip wrote: I am working on plotting a response surface using wireframe(). The default style/orientation is z | | y | \ | \ | \ | \ | \ | \ | \ | \|x 0 Now what I want the orientation of axes is: z | | | | | /0\ / \ / \ / \ / \ / \ y z Two z axes? How interesting! My understanding is that the screen=list(z=,y=,x=) control the orientation of axes, but even after reading the help page of screen argument, I still don't understand how to use it. screen: A list determining the sequence of rotations to be applied to the data before being plotted. The initial position starts with the viewing point along the positive z-axis, and the x and y axes in the usual position. Each component of the list should be named one of x, y or z (repititions are allowed), with their values indicating the amount of rotation about that axis in degrees. Can anyone explain to me how the screen argument works? And what values (x,y,z) I should choose for the orientation that I want? Another question is wireframe(0 will draw all 8 edges of the cubic by default, is there anyway that I can control what edges I can draw, what I can hide? thanks very much! John __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plm package twoways effect problem
On Thu, 8 Apr 2010, seral wrote: Hello everyone, I have a peoblem to create the twoways effect in the plm package. when i try to create the following dsn1-plm(lnQ~lnC+lnL+lnM+lnE+eco+RD,data=newdata,effect=twoways,model=within) i have this error: Error in rep.int(c(1, numeric(n)), n - 1L) : negative length vectors are not allowed and to be honest i have no idea what does it mean!! can someone give me any idea what it would mean? This is the second time in two days that you post the same question. The reason that you didn't receive an answer is not that you didn't post often enough...it's that it's hard to say anything with the information you provide. See the posting guide (link given below) on how to ask a better question. Z Thank you for your help in advance -- View this message in context: http://n4.nabble.com/plm-package-twoways-effect-problem-tp1774246p1774246.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accessing elements of plm outputs
On Thu, 8 Apr 2010, ECAMF wrote: Dear all, I've just migrated from STATA to R for runing panel regressions and I was very happy to discover the plm package. However, I have a problem when trying to access the Total Sum of Squares and Residual Sum of Squares on this output: summary(output) Oneway (individual) effect Within Model Call: plm(formula = Y ~ X1 + X2, data = db, model = within) Unbalanced Panel: n=10, T=9-11, N=108 Residuals : Min. 1st Qu. Median 3rd Qu.Max. -6.500 -2.200 -0.374 1.550 8.730 Coefficients : Estimate Std. Error t-value Pr(|t|) X1 113.302650 8.517736 13.302 2e-16 *** X2 -0.084414 0.109625 -0.770 0.4432 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Total Sum of Squares:3208.3 Residual Sum of Squares: 1059.6 F-statistic: 97.3365 on 2 and 96 DF, p-value: 2.22e-16 I would like to do so because I'm running some hundreds times a similar regression and I want to store those results in a vector and then plot them. I've tried to do so with summary(output)[] but neither the Total Sum of Squares or the Residual Sum of Squares are on the list. The residual sum of squares can be computed via sum(residuals(output)^2) The total sum of squares is more difficult, I think. plm contains a tss() generic with suitable methods - but this is only used internally but not exported in the user interface. Thus, you currently have to do plm:::tss.plm(output) This is really dirty as it accesses a specific method (rather than the generic) in the namespace (rather than the exported user interface). But I don't think there's currently a better way. The package authors (both Cc) might be able to give more guidance though. hth, Z I would be glad if somebody can help me. Thank you very much! Eduardo Marinho. -- View this message in context: http://n4.nabble.com/Accessing-elements-of-plm-outputs-tp1774143p1774143.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading dates in R using SQL and otherwise (and some interesting behavior by the data editor)
If you want to look at the dataframe, then consider using View. On Thu, Apr 8, 2010 at 11:14 AM, Paul Miller pjmiller...@yahoo.com wrote: Hello Everyone, I am a newbie with about a month's worth of experience using R. I've just spent a little time learning how to work with date values. Mostly, this has involved converting text values into dates. So far, I've managed to figure out how to do this in R proper using as.Date. However, I'm still struggling with doing this using SQL and RODBC. In the process of learning to create date values in R proper, I noticed some interesting behavior on the part of the data editor. At first, this led me to believe that my efforts had been unsuccessful. The output from my R console below illustrates this behavior. test - mydata test$test_date - as.Date(test$ae_datestarted, format='%m/%d/%Y') class(test$test_date) [1] Date mode(test$test_date) [1] numeric fix(test) (At this point, I clicked on the test_date column) Warning: class discarded from column test_date class(test$test_date) [1] character mode(test$test_date) [1] character When I run my code, it works correctly. But when I open the data frame in the data editor and click on the test_date column, the editor says that it is character. And beyond that, the editor discards the class for test_date. Should the editor do this? Or is it my fault for trying to look at test_date in the editor in the first place? In SAS, I'm used to creating data and then opening the dataset to look at what I've done. Maybe I shouldn't be doing this in R though. Returning to the issue of converting text values to dates using SQL (Server) and RODBC. Does anyone know how ot do this? I've been trying to do this using things like Cast and Convert. Usually, these attempts fail. When SQL Server does seem to be sending something back, it appears that R cannot accept it. Any help with this problem would be greatly appreciated. Thanks, Paul __ [[elided Yahoo spam]] avourite sites. Download it now [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[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] 3-D response surface using wireframe()
On Apr 8, 2010, at 3:13 PM, array chip wrote: David, That does the job! Thanks a lot. Now I am very very close to what I want. Still have a couple of small adjustments to make. 1. I use drape=TRUE to draw grid and color on the surface, is there a parameter to adjust the density of the grid? If you mean the spacing between points, then isn't that determined by the density of the gridded data arguments before they get to the wireframe function? 2. Is there a way that I can add grid to the axis surface? I mean the sides of the box, between x y, between x z, and between y z? And I need to choose which 3 side of the box that I want to add grid? See Figure 13.7 of Sarkar's Lattice text for an example of a panel function that collapses the contourLines of the volcano dataset at the top bounding surface by using ltransform3dto3d with a z argument of zlim.scaled[2]. I would think that a grid could be 3dto3d transformed similarly. -- David. Thank you all for the help. It's fun to play with wireframe John --- On Wed, 4/7/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] 3-D response surface using wireframe() To: array chip arrayprof...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, April 7, 2010, 9:22 PM On Apr 7, 2010, at 8:58 PM, array chip wrote: With the help document, i finally find a set of values of for x=,y= and z= in screen argument that gives me the correct rotation of the plot. But now it plots x and y axis (tick marks and labels) along the top of the plot. Is there one way to plot x and y axis on the bottom of the plot? Look at the scpos argument to specify the scales location. (Still lacking an example and therrefore doing this from memory.) -- David Thanks John --- On Wed, 4/7/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] 3-D response surface using wireframe() To: array chip arrayprof...@yahoo.com Cc: r-help@r-project.org Date: Wednesday, April 7, 2010, 8:07 AM A search with the following strategy: RSiteSearch(lattice wireframe rotate axes) Followed by adding requests to search earlier years' archives produced this link which has a further link to a document that answers most of your questions, at least the ones that are comprehensible: http://tolstoy.newcastle.edu.au/R/e2/help/07/03/12534.html --David. On Apr 6, 2010, at 7:12 PM, array chip wrote: I am working on plotting a response surface using wireframe(). The default style/orientation is z | | y | \ | \ | \ | \| \ | \ | \ | \|x 0 Now what I want the orientation of axes is: z | | | | | /0\ / \ / \ / \ / \ / \ y z Two z axes? How interesting! My understanding is that the screen=list(z=,y=,x=) control the orientation of axes, but even after reading the help page of screen argument, I still don't understand how to use it. screen: A list determining the sequence of rotations to be applied to the data before being plotted. The initial position starts with the viewing point along the positive z-axis, and the x and y axes in the usual position. Each component of the list should be named one of x, y or z (repititions are allowed), with their values indicating the amount of rotation about that axis in degrees. Can anyone explain to me how the screen argument works? And what values (x,y,z) I should choose for the orientation that I want? Another question is wireframe(0 will draw all 8 edges of the cubic by default, is there anyway that I can control what edges I can draw, what I can hide? thanks very much! John __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to manipulate object in specific environment?
Hi I want to simplify my problem into a prototype, how to write a function to get all the object in your current environment, e.g. .GlobalEnv, and print their mode? For example, if I have object a,b,c... in my environment, a=1;b='test';c=matrix(0,3,3). I want to write a function myfun(), when I run myfun(), this retrieve all the objects in my environment automatically and print their mode or class one by one. Thanks Regards Tengfei -- Tengfei Yin MCDB PhD student 1620 Howe Hall, 2274, Iowa State University Ames, IA,50011-2274 Homepage: www.tengfei.name English Blog: www.tengfei.name/en Chinese Blog: www.tengfei.name/ch [[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 locate the difference from two data frames
David, all.equal() only tells how many mismatches there are including missing values but it doesn't tell me the location of each mismatch. For example, if I have one NA mismatch and three numerical mismatches, all.equal(a,b) gives [1] Component 2: 'is.NA' value mismatch: 1 in current 0 in target [2] Component 3: 3 string mismatches This only tells the missing value mismatch is in the second column (component) and 3 numerical mismatches in the third column. But no row information which(mapply(identical,unlist(a),unlist(b))==FALSE) gives TIME5 DV1 DV2 DV17 85 161 162 177 It tells me exactly which columns and rows to have the mismatches. In this case is column TIME row 5 and column DV rows 1, 2 and 17. You can ignore the serial numbers that followed. Jun On Thu, Apr 8, 2010 at 1:58 PM, David Winsemius dwinsem...@comcast.netwrote: On Apr 8, 2010, at 1:34 PM, Jun Shen wrote: David, Thanks for the suggestion. Now I have worked out a general solution. Assume a and b are two data frames with same dimensions 1. Call identical(a,b) to get an overall assessment. If you get a FALSE 2. Call which(mapply(identical,unlist(a),unlist(b))==FALSE), you will get a result like TIME5 85 which means, the row 5 and the column with name TIME is different. This also works for missing values. Thanks for everyone. Looks that all.equal is already set up to provide such a service: all.equal(df1,df2) [1] Component 1: 'is.NA' value mismatch: 1 in current 0 in target I was under the misimpression that all.equal was for approximate equality of numeric values but that only appears to be part of its design. -- David. Jun Shen from Millipore On Thu, Apr 8, 2010 at 9:08 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 8, 2010, at 9:47 AM, Jun Shen wrote: Dear David, Erik and Charles, Thank you for your input. Both mapply() and which() can do the job. Just one exception. If there is a missing value as NA in the data frame a and a data point (either numerical or character) in the corresponding position of b, then mapply() only returns NA for that position rather than FALSE, and which() cannot pick up that position either. Thanks again. You seem to have changed the programming challenge from identification to replicating identical(). If so then you can get closer with wrapping isTRUE(all() around the mapply(== , attributes( ...), ...) step, and wrap the == call in isTRUE(all(.)) isTRUE(all(mapply(==, df1, df2)) ) [1] FALSE since all(c(NA, TRUE, TRUE)) == NA and isTRUE(NA) == FALSE -- David. Jun On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 7 Apr 2010, Jun Shen wrote: Dear all, I understand identical (a,b) will tell me if a and b are exactly the same or not. But what if they are different, is there anyway to tell which element(s) are different? Thanks. which( a != b, arr.ind = TRUE) HTH, Chuck Jun [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] estimating the starting value within a ODE using nls and lsoda
Hi Dave, first of all, fitting starting values of a dynamic model the same way like its parameters is indeed the usual method. In that case parameters *and* some or all initial value(s) of the dynamic model are both in fact 'parameters' for the statistical model fitting problem. Fitting a nonlinear model can be easy or problematic or even impossible, depending on the data and the model structure. In such cases one speaks about identifiability and there are several methods that can help to find parameter combinations that can be identified simultaneously. It is not important whether such a statistical parameter was originally a 'parameter' or an 'initial value' of the dynamic model, it simply depends on collinearity of the problem: http://en.wikipedia.org/wiki/Multicollinearity Several methods for identifiability analysis are provided in the CRAN package FME (Flexible Modelling Environment), which comes with extensive documentation (package vignettes as pdf files) and examples and there is a recent paper in the Journal of Statistical Software: http://www.jstatsoft.org/v33/i03 Look for function 'collin' that implements a collinearity index. In addition, function 'modFit', that is also in this package provides an interface to use different optimizers of R in a unique way, namely nls, nlminb, optim, nls.lm (from package minpack), and pseudoOptim, a pseudo-random search algorithm. Another hint, because you are still using odesolve (from Woodrow Setzer). This package has now a direct and compatible successor deSolve (Soetaert, Petzoldt, Setzer), see: http://www.jstatsoft.org/v33/i09 deSolve is even more stable than the former version and contains many many more solvers, not only lsoda and rk4, can handle other types of differential equations too and has much more documentation. Hope it helps! Thomas Petzoldt PS: There is also a dedicated mailing list for such questions: https://stat.ethz.ch/mailman/listinfo/r-sig-dynamic-models -- Thomas Petzoldt Technische Universitaet Dresden Institut fuer Hydrobiologie 01062 Dresden GERMANY http://tu-dresden.de/Members/thomas.petzoldt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 locate the difference from two data frames
On Apr 8, 2010, at 4:03 PM, Jun Shen wrote: David, all.equal() only tells how many mismatches there are including missing values but it doesn't tell me the location of each mismatch. Yes, I noticed that after further testing. I agree Charles' solution is more informative and I wonder if it could be added to the functionality of all.equal (which purports to tell the user where objects differ)? For example, if I have one NA mismatch and three numerical mismatches, all.equal(a,b) gives [1] Component 2: 'is.NA' value mismatch: 1 in current 0 in target [2] Component 3: 3 string mismatches This only tells the missing value mismatch is in the second column (component) and 3 numerical mismatches in the third column. But no row information which(mapply(identical,unlist(a),unlist(b))==FALSE) gives TIME5 DV1 DV2 DV17 85 161 162 177 It tells me exactly which columns and rows to have the mismatches. In this case is column TIME row 5 and column DV rows 1, 2 and 17. You can ignore the serial numbers that followed. Jun On Thu, Apr 8, 2010 at 1:58 PM, David Winsemius dwinsem...@comcast.net wrote: On Apr 8, 2010, at 1:34 PM, Jun Shen wrote: David, Thanks for the suggestion. Now I have worked out a general solution. Assume a and b are two data frames with same dimensions 1. Call identical(a,b) to get an overall assessment. If you get a FALSE 2. Call which(mapply(identical,unlist(a),unlist(b))==FALSE), you will get a result like TIME5 85 which means, the row 5 and the column with name TIME is different. This also works for missing values. Thanks for everyone. Looks that all.equal is already set up to provide such a service: all.equal(df1,df2) [1] Component 1: 'is.NA' value mismatch: 1 in current 0 in target I was under the misimpression that all.equal was for approximate equality of numeric values but that only appears to be part of its design. -- David. Jun Shen from Millipore On Thu, Apr 8, 2010 at 9:08 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 8, 2010, at 9:47 AM, Jun Shen wrote: Dear David, Erik and Charles, Thank you for your input. Both mapply() and which() can do the job. Just one exception. If there is a missing value as NA in the data frame a and a data point (either numerical or character) in the corresponding position of b, then mapply() only returns NA for that position rather than FALSE, and which() cannot pick up that position either. Thanks again. You seem to have changed the programming challenge from identification to replicating identical(). If so then you can get closer with wrapping isTRUE(all() around the mapply(== , attributes( ...), ...) step, and wrap the == call in isTRUE(all(.)) isTRUE(all(mapply(==, df1, df2)) ) [1] FALSE since all(c(NA, TRUE, TRUE)) == NA and isTRUE(NA) == FALSE -- David. Jun On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry cbe...@tajo.ucsd.edu wrote: On Wed, 7 Apr 2010, Jun Shen wrote: Dear all, I understand identical (a,b) will tell me if a and b are exactly the same or not. But what if they are different, is there anyway to tell which element(s) are different? Thanks. which( a != b, arr.ind = TRUE) HTH, Chuck Jun [[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. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.