Re: [R] How to clear R memory in a for loop
On 20/10/2014 17:53, John McKown wrote: On Mon, Oct 20, 2014 at 10:30 AM, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: Dear Rers, I am trying to run a for-loop in R. During each iteration I read in an mp3 file and do some basic processing. If I do what I need to do for each file one by one - it works fine. But once I start running a loop, it soon runs out of memory and says: can't allocate a vector of size... In each iteration of my loop I always overwrite the previously created object and do gc(). Any hints on how to fight this? Thanks a lot! Please don't use HTML for messages. What occurs to me, from reading the other replies, is that perhaps within the loop you are causing other objects to be allocated. And that can be done just by doing a simple assignment, so it may not be obvious. What this can do is cause what we called a "sand bar" in the old days. That's where you allocate a big chunk of memory for an object. Say this take up 1/2 of your available space. You now create a small object. This object is _probably_ right next to the large object. You now release the large object. Your apparent free space is now almost what it was at the beginning. But when you try to allocate another large object which is, say, 2/3 of the maximum space, you can't because that small object is sitting right in the middle of our memory space. So you _can_ allocate 2 large objects which are 1/3 your free space size, but not 1 object which is 2/3 of the free space size. Which can lead to your type of situation. This is just a SWAG based on some experience in other systems. Most "garbage collection" do _not_ do memory consolidation. I don't know about R. That is true of R (except for the early days which did have a moving garbage collector). However 'your available space' is not the amount of RAM you have but the process address space. The latter is enormous on any 64-bit OS, so 'memory fragmentation' (as this is termed) is a thing of the past except for those limited to many-years-old OSes. -- Brian D. Ripley, rip...@stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Ternary Plots Do Not Display Ellipses in PDF
Hi I think the problem is that, as David Carlson pointed out, ellipses() works by redrawing the plot and adding more to it. This means that your PDF version has *two pages*, one with the original plot, then another with the plot-plus-ellipses. Paul On 10/15/14 10:20, Rich Shepard wrote: A rather strange situation here and I've not found the source of the problem. The point is to print a ternary plot matrix of compositional data with ellipses enclosing 95% of the variance in each plot. The ellipses display on the monitor, dev = x11cairo (see attached winters-x11cairo.pdf), but not when sent directly to a file, dev = pdf (see attached winters-pdf.pdf). Here's winters.acomp: structure(c(0.0667, 0.0612244897959184, 0.0434782608695652, 0.043956043956044, 0.05, 0.0161290322580645, 0.6, 0.571428571428571, 0.623188405797101, 0.593406593406593, 0.433, 0.629032258064516, 0.0667, 0.0612244897959184, 0.101449275362319, 0.0659340659340659, 0.0667, 0.032258064516129, 0.244, 0.26530612244898, 0.217391304347826, 0.263736263736264, 0.367, 0.290322580645161, 0.0222, 0.0408163265306122, 0.0144927536231884, 0.032967032967033, 0.0833, 0.032258064516129), .Dim = c(6L, 5L), .Dimnames = list( NULL, c("filter", "gather", "graze", "predate", "shred")), class = "acomp") And this is the command sequence: library(compositions) plot(winters.acomp, main="Winters Creek", cex=0.5) r <- sqrt(qchisq(p=0.95, df=4)) mn <- mean(winters.acomp) vr <- var(winters.acomp) plot(winters.acomp, main="Winters Creek", cex=0.5) ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE, col='red', lwd=2) # monitor plot window is manually closed. pdf("winters-pdf.pdf") plot(winters.acomp, main="Winters Creek", cex=0.5) ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE, col='red', lwd=2) dev.off() What am I not seeing here that causes the different outputs? Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 p...@stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] pasteFromExcel
On Oct 20, 2014, at 2:34 PM, Dan Murphy wrote: > Good ideas, David. > > 1) By "confirm that MS Excel honors that OutDec" I mean that, in a > location (France? others?) where options("OutDec") is a comma, does MS > Excel format numbers that way when displaying currencies with decimal > places? I have no way of knowing if that is true in all OutDec = "," > locales. > > 2) I wish it were as simple as just removing unwanted "adornments." > The issue is that such "adornments" must be in their proper places for > the character string to represent a currency value, or a numeric value > for that matter. If I add one more comma to your first element in the > wrong place, it should not translate to a valid numeric, but it does > with your gsub, which would be a bug if that were in pasteFromExcel: >> gsub(rmchar, "", c("$1,0,00", "1,200", "800")) > [1] "1000" "1200" "800" If you wanted to restrict the substitutions to only the commas that were succeeded by three digits then this succeeds: gsub("(\\,)(\\d{3,3})", "\\2", c("1,000,000,000.00") ) [1] "10.00" You should also take a look at formatC which has provisions for output using commas. - david. > > When I originally looked into this I believed I couldn't be the first > one asking that question .. and I wasn't. There are many hits for > regular expressions that purport to successfully identify well-formed > *US dollar* currency strings. The expression in pasteFromExcel is > based on > http://stackoverflow.com/questions/354044/what-is-the-best-u-s-currency-regex. > > I'm curious if anyone has come across -- and tested -- a similar > regular expression in other places that might have use for > pasteFromExcel. > > This is how pasteFromExcel uses its currency regular expression (the > first ugly assignment is what I'm looking for in other locales around > the world -- maybe there's a Regular Expression mailing list out > there): > > currencypattern <- > "^\\$?\\-?([1-9]{1}[0-9]{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\-?\\$?([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\$?\\(([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))\\)$" > > # Here's a test vector > x <- c("1,234.00", "12,34.00", "$1,000", "(124)", "$(123)", "($123)", > " 1,000 ", "NA") > > # grep will tell you whether elements of x, trimmed of > beginning/ending whitespace, match the currencypattern > grep(currencypattern, trim(x)) > [1] 1 3 4 5 7 # correct answer > > *Now* one may remove unwanted characters from the well-formed strings. > And deal with the "negatives" of course .. and NAs. See how that's > done in excelRio.r in the excelRio package on github: > https://github.com/trinostics/excelRio > > Thanks for your interest. > > > On Mon, Oct 20, 2014 at 10:56 AM, David Winsemius > wrote: >> >> On Oct 20, 2014, at 10:29 AM, Dan Murphy wrote: >> >>> Nice. >>> So if someone were to offer a currency regular expression that works >>> in their locale, I should also ask them to give me the results of >>> Sys.getlocale("LC_MONETARY") >>> and >>> options("OutDec") >>> and confirm that MS Excel honors that OutDec. >> >> I'm not sure we can know what you mean by "confirm that MS Excel honors that >> OutDec." The result of options("OutDec") was intended for you to determine >> what character not to remove from a monetary value in an R workspace. If the >> assumption is that all values will be in the same unit and that the user is >> not doing any currency conversions then: >> >>> decsep <- options("OutDec") >>> rmchar <- paste0( "[$£€", c(".", ",")[!c(".", ",") %in% decsep], "]" ) >>> gsub(rmchar, "", c("$1,000", "1,200", "800")) >> [1] "1000" "1200" "800" >> >> >>> Thank you, David. >>> -Dan >>> >>> On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius >>> wrote: On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote: > To Users of Excel: > > Following advice from Brian and Markus, I created an RMarkdown "vignette" > that shows an example of how the pasteFromExcel function in the excelRio > package on github could be used by an actuary to transfer a triangle from > Excel to R. See today's post at http://trinostics.blogspot.com/ > > Unfortunately, if you are located outside the US, the demonstrated > functionality will not work for you because the currency regex implemented > assumes the dollar sign ($) and comma/decimal punctuation of the form > 999,999.00. > > If anyone is interested in contributing currency regex expressions that > work in your locale, I would be happy to try to incorporate them in the > package. If anyone knows how best to determine the user's locale (might > "timezone" suffice?), I'd appreciate that help too. > ?Sys.getlocale # perhaps "LC_MONETARY" ?options # look for OutDec >
Re: [R] pasteFromExcel
Good ideas, David. 1) By "confirm that MS Excel honors that OutDec" I mean that, in a location (France? others?) where options("OutDec") is a comma, does MS Excel format numbers that way when displaying currencies with decimal places? I have no way of knowing if that is true in all OutDec = "," locales. 2) I wish it were as simple as just removing unwanted "adornments." The issue is that such "adornments" must be in their proper places for the character string to represent a currency value, or a numeric value for that matter. If I add one more comma to your first element in the wrong place, it should not translate to a valid numeric, but it does with your gsub, which would be a bug if that were in pasteFromExcel: > gsub(rmchar, "", c("$1,0,00", "1,200", "800")) [1] "1000" "1200" "800" When I originally looked into this I believed I couldn't be the first one asking that question .. and I wasn't. There are many hits for regular expressions that purport to successfully identify well-formed *US dollar* currency strings. The expression in pasteFromExcel is based on http://stackoverflow.com/questions/354044/what-is-the-best-u-s-currency-regex. I'm curious if anyone has come across -- and tested -- a similar regular expression in other places that might have use for pasteFromExcel. This is how pasteFromExcel uses its currency regular expression (the first ugly assignment is what I'm looking for in other locales around the world -- maybe there's a Regular Expression mailing list out there): currencypattern <- "^\\$?\\-?([1-9]{1}[0-9]{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\-?\\$?([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))$|^\\$?\\(([1-9]{1}\\d{0,2}(\\,\\d{3})*(\\.\\d{0,2})?|[1-9]{1}\\d{0,}(\\.\\d{0,2})?|0(\\.\\d{0,2})?|(\\.\\d{1,2}))\\)$" # Here's a test vector x <- c("1,234.00", "12,34.00", "$1,000", "(124)", "$(123)", "($123)", " 1,000 ", "NA") # grep will tell you whether elements of x, trimmed of beginning/ending whitespace, match the currencypattern grep(currencypattern, trim(x)) [1] 1 3 4 5 7 # correct answer *Now* one may remove unwanted characters from the well-formed strings. And deal with the "negatives" of course .. and NAs. See how that's done in excelRio.r in the excelRio package on github: https://github.com/trinostics/excelRio Thanks for your interest. On Mon, Oct 20, 2014 at 10:56 AM, David Winsemius wrote: > > On Oct 20, 2014, at 10:29 AM, Dan Murphy wrote: > >> Nice. >> So if someone were to offer a currency regular expression that works >> in their locale, I should also ask them to give me the results of >> Sys.getlocale("LC_MONETARY") >> and >> options("OutDec") >> and confirm that MS Excel honors that OutDec. > > I'm not sure we can know what you mean by "confirm that MS Excel honors that > OutDec." The result of options("OutDec") was intended for you to determine > what character not to remove from a monetary value in an R workspace. If the > assumption is that all values will be in the same unit and that the user is > not doing any currency conversions then: > >> decsep <- options("OutDec") >> rmchar <- paste0( "[$£€", c(".", ",")[!c(".", ",") %in% decsep], "]" ) >> gsub(rmchar, "", c("$1,000", "1,200", "800")) > [1] "1000" "1200" "800" > > >> Thank you, David. >> -Dan >> >> On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius >> wrote: >>> >>> On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote: >>> To Users of Excel: Following advice from Brian and Markus, I created an RMarkdown "vignette" that shows an example of how the pasteFromExcel function in the excelRio package on github could be used by an actuary to transfer a triangle from Excel to R. See today's post at http://trinostics.blogspot.com/ Unfortunately, if you are located outside the US, the demonstrated functionality will not work for you because the currency regex implemented assumes the dollar sign ($) and comma/decimal punctuation of the form 999,999.00. If anyone is interested in contributing currency regex expressions that work in your locale, I would be happy to try to incorporate them in the package. If anyone knows how best to determine the user's locale (might "timezone" suffice?), I'd appreciate that help too. >>> >>> ?Sys.getlocale # perhaps "LC_MONETARY" >>> >>> ?options # look for OutDec >>> >>> [[alternative HTML version deleted]] >>> >>> >>> >>> David Winsemius >>> Alameda, CA, USA >>> > > David Winsemius > Alameda, CA, USA > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] making a plot
Thanks David and Adrés, it worked fine. Enrico. 2014-10-20 15:37 GMT-02:00 David Winsemius : > > On Oct 20, 2014, at 8:24 AM, Andrés Aragón wrote: > > > Enrico, > > > > This may help you: > > > > text(locator(1), "*", cex=1.5,adj=0.5 > > > > and > > > > text(locator(1), "º", cex=1.5,adj=0.5 > > Why not just use the values of x2 and y2 that were given to segments: > > > text( (ano+ranges)[1:3], 1:3, "*", cex=1.5,adj=0.5) > > text( (ano+ranges)[4:6], 4:6 , "º", cex=1.5,adj=0.5) > > > > > > > Draw your plot, then write the code, locate the cursor on your plot, put > > the symbols where you want itl and click. > > > > Regards, > > > > > > Andrés > > > > PS ?locator > > > > > > 2014-10-20 9:46 GMT-05:00 Enrico Colosimo : > > > >> Dear all, > >> > >> I am struggling to make a plot for my survival analysis > >> class. > >> > >> This is my script > >> > >> > >> labels<-c('1','2','3','4','5','6') > >> ano<-c(2001,2002,2003,2004,2006,2008) > >> ranges<-c(6,3,4,5,4,2) > >> dotchart(ano, labels=labels, xlab='ano', > >> ylab='Pacientes',pch=20,xlim=c(min(ano), max(ano+ranges))) > >> segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4) > >> > >> I need to put an asterix (failure) by the end of the three first lines > and > >> a small circle (censoring) > >> by the end of the last three. > >> > >> Someone can help me? > >> > >> Thanks, > >> Enrico. > >> > >>[[alternative HTML version deleted]] > > > -- > > David Winsemius > Alameda, CA, USA > > [[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] format negative numbers
On Oct 20, 2014, at 4:32 AM, PIKAL Petr wrote: > Hi > > Thanks to all who responded. > > My input string is rather clumsy. Actually it can have leading or trailing > empty space too, it can be mixture of positive and negative numbers. > > In the meantime I made small function which just strips of - sign and make > numbers from factors, find numbers which have - sign and change numbers which > shall be negative to negative. Not as elegant as your solution but works even > when there are leading or trailing spaces. > > zapor <- function(x) { > num<-as.numeric(gsub("(-)", "", x)) Might want to just use sub() since your method would accept things like "-100" > zap<- grep("-", x) > num[zap]<- num[zap] * (-1) > num} > >> x <- as.factor( c(" 123.4- " , " 123 ")) >> zapor(x) > [1] -123.4 123.0 >> gsub("^(\\s+)([0-9.]+)(-){0,1}(\\s)+$", "\\3\\2", as.factor( c(" 123.4- " , " 123 ") ) ) [1] "-123.4" "123" Then just `as.numeric`. You method looks more elegant. Depending on the local you may get into trouble with variation in decimal markers. > > I just thought that there is some reason for presenting negative numbers with > minus sign behind the number in finance community and therefore somebody > already invented clever way how to deal with such numbers. > > Cheers > Petr > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >> project.org] On Behalf Of Marc Girondot >> Sent: Monday, October 20, 2014 12:53 PM >> To: r-help@r-project.org >> Subject: Re: [R] format negative numbers >> >> Is it what you want? >> >>> st <- "0.123-" >>> gsub("(.+)(-)", "\\2\\1", st) >> [1] "-0.123" >>> st <- "0.123" >>> gsub("(.+)(-)", "\\2\\1", st) >> [1] "0.123" >> >> Sincerely >> Marc >> >> Le 20/10/2014 09:03, PIKAL Petr a écrit : >>> Dear all. >>> >>> Before I start fishing in (for me) murky regular expression waters I >> try to ask community about changing format of negative numbers. >>> >>> For some reason I get a file with negative numbers formatted with >> negative sign at end of number. >>> >>> something like >>> >>> 0.123- >>> >>> It is imported as factors and I need to convert it to numbers again. >> Before converting I need to change it to "correct" format >>> >>> -0.123 >>> >>> Does anybody know some simple way? >>> >>> Cheers >>> Petr >>> >>> >>> >>> Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a >> David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] distance from fitted line
Thankyou Turner, As i said It was out of my curiosity.Thankyou very much for your reply. :) Eliza > Date: Tue, 21 Oct 2014 08:40:39 +1300 > From: r.tur...@auckland.ac.nz > To: eliza_bo...@hotmail.com > CC: joachim.audena...@pcsierteelt.be; r-help@r-project.org > Subject: Re: [R] distance from fitted line > > > On 20/10/14 23:00, eliza botto wrote: > > > Thankyou very much Joachim. Actually I already know the residual() > > command. I only wanted to know that is there a way to account for the > > fitted lines? its more of a criosity rather than a problem. :) > > Thankyou very much once again. > > What (on earth!) do you mean by "account for the fitted lines"? The > residuals *are* the (signed, vertical) distances of the observed values > from the fitted line. > > cheers, > > Rolf Turner > > -- > Rolf Turner > Technical Editor ANZJS [[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 overwrite a Unary operator ?
There is currently no way to write your own unary operator in R. The only current unary operators are prefix (-, +, !). It would take some major changes to the parser to recognize the syntax that you want (which could also break other things that already work well), and with the oo and other methods it is not really needed. You can technically pass and empty expression to a binary operator: > `%++%` <- function(a,b) a + 1 > x <- 5 > x %++% {} [1] 6 but that does not change the value of the variable (and using `assign` just creates its own problems). And syntax like above is more appropriate for a obfuscated R contest than for anything that you want to be understood. There are assignment functions and you could create an object type and an assignment for such that you might be able to have syntax like: a <- {} to increment a, but you would need to declare a class for a before using it and it would probably be even more complicated than needed. If you really want C like syntax then you could always make an active binding: > f <- local({ + e <- environment() + x <- 1 + list(inc = function(v) { + if(missing(v)) { + e$x <- e$x + 1 + } else { + stop('unary inc cannot be assigned to') + } + x + }, + dec = function(v) { + e$x <- e$x - 1 + x + } ) } ) > > makeActiveBinding("x++", f$inc, .GlobalEnv) > makeActiveBinding("x--", f$dec, .GlobalEnv) > > `x++` [1] 2 > `x++` [1] 3 > `x++` [1] 4 > `x--` [1] 3 > `x--` [1] 2 > `x++` [1] 3 > But it seems simpler to just go with the reference class system at this point. On Sun, Oct 19, 2014 at 11:17 AM, PO SU wrote: > > It's a good way to use RF OOS, but it's not my needing, actually, i want is > there exists a way to write a %++% form function that can pass one param to > it? > So i can use 1%++% to get 2 ,a<-2 , a%++% to get a<-3 . > It seems that the operator overwrite system in R, must pass two params. Is it > true? > > > > > -- > > PO SU > mail: desolato...@163.com > Majored in Statistics from SJTU > > > > At 2014-10-18 00:54:40, "Greg Snow" <538...@gmail.com> wrote: >>You may be interested in looking at Reference Classes/objects (see >>?setRefClass). This is a form of OO programming that is more similar >>to C++ and Java. You could create a counter object that you could >>then increment with syntax like: >> >>x$inc() >>x$inc(5) >> >>The first would increment by the default (1), the second would then >>increment by 5. >> >> >> >>On Fri, Oct 17, 2014 at 2:06 AM, PO SU wrote: >>> >>> Tks for your alternative way's details. but like you mentioned in graphics >>> package, i still wonder how to overload an operator which can pass one >>> param like +2 . >>> There seems exists some examples for my needing. But i try to find them but >>> without any results. >>> can you show me some examples from it? >>> >>> >>> >>> >>> >>> >>> -- >>> >>> PO SU >>> mail: desolato...@163.com >>> Majored in Statistics from SJTU >>> >>> >>> >>> At 2014-10-17 15:16:47, "David Winsemius" wrote: On Oct 16, 2014, at 10:36 PM, PO SU wrote: > > Tks for your advice, let the ++ problem alone, how to write an > Unary operator ? Is it permitted in R? > suchasa<-2 , a%+2% will let a be 4 . OK, that's just wrong. Oh, OK, just for fun, as it were: inc <- function(x) { eval.parent(substitute(x <- x + 1)) } > inc(10) Error in 10 <- 10 + 1 : invalid (do_set) left-hand side to assignment > y=10 > inc(y) > y [1] 11 > I just want to know it , i won't pollute r with it , because i know > what is r . : ) > It's certainly permitted. Just look at all the overloadings of the "+" operator in graphics packages. Look up the documentation on methods in R. Why not just use a well-behaved function, though? .inc <- function(x) x+1 > .inc(10) [1] 11 Then you won't be tempted to try 10 <- .inc(10) because it just wouldn't make sense. -- David. > -- > > PO SU > mail: desolato...@163.com > Majored in Statistics from SJTU > > > > > At 2014-10-17 13:09:47, "Rolf Turner" wrote: >> On 17/10/14 17:29, PO SU wrote: >>> >>> Dear expeRts, >>> Now i want to know how to implement an Unary operator like i++ >>> in cpp's synax form. >>> e.g. 2++ will let 2 be 3 , a<-2 ,a++ ,will let a be 3 >>> I tried this : >>> '%++%'<-function(x){ >>>x<<-x+1 >>> } >>> but it have problem, the biggest one is it seems the function need >>> twoparams like a%++%b , how to write a function needing just one >>> param? >>> >>> TKS ! >> >> Just ***DON'T***. The "++" operator is useful only for those wish to >> write code which is obscure to the point of incomprehensibility. It >> makes C and its offspring "write only" languages. >> >> If you are going to use R, use R and don't p
Re: [R] distance from fitted line
On 20/10/14 23:00, eliza botto wrote: Thankyou very much Joachim. Actually I already know the residual() command. I only wanted to know that is there a way to account for the fitted lines? its more of a criosity rather than a problem. :) Thankyou very much once again. What (on earth!) do you mean by "account for the fitted lines"? The residuals *are* the (signed, vertical) distances of the observed values from the fitted line. cheers, Rolf Turner -- Rolf Turner Technical Editor ANZJS __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 clear R memory in a for loop
Thank you, everybody. Bill - do I interpret your response correctly if I say: we should check if tuneR is handling .wav files better than mp3 files. On Mon, Oct 20, 2014 at 12:53 PM, William Dunlap wrote: > tuneR::readMP3 may not be allocating (or freeing) memory correctly. On both > Linux and Windows I get the following (where 'jingle.mp3' is a sample mp3 that > comes with Processing 2.1 which has a quarter million samples in it). If I do > this as a sequence of top-level expression instead of as a for loop R does not > crash. Perhaps you should talk with tuneR's maintainer, who could run > valgrind > over it. > >> library(tuneR) > tuneR >= 1.0 has changed its Wave class definition. > Use updateWave(object) to convert Wave objects saved with previous > versions of tuneR. >> b <- readMP3("jingle.mp3") >> for(i in 1:100){cat(i,"");b <- readMP3("jingle.mp3")} > 1 2 > *** caught segfault *** > address 0x3a81000, cause 'memory not mapped' > > Traceback: > 1: .Call("do_read_mp3", data, package = "tuneR") > 2: readMP3("jingle.mp3") > > Possible actions: > 1: abort (with core dump, if enabled) > 2: normal R exit > 3: exit R without saving workspace > 4: exit R saving workspace > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > > On Mon, Oct 20, 2014 at 9:25 AM, Jeff Newmiller > wrote: >> It is your responsibility (not mine) to simplify your example to the point >> where it is small, self-contained, and reproducible (see the footer of this >> message). In fact, doing so often highlights the issue to you before you >> share it. If any old downloadable mp3 file can be used to reproduce the >> problem then you would not need to share yours. (Note that this list strips >> off most attachments, so links are better anyway.) >> >> I suspect that one file read repeatedly might create the problem... if it >> doesn't, then that would be helpful to know. In any event, your "example" is >> missing the key element of repetition, so it is not hardly reproducible. The >> extra things you are doing to make it loop are likely to be important here. >> --- >> Jeff NewmillerThe . . Go Live... >> DCN:Basics: ##.#. ##.#. Live Go... >> Live: OO#.. Dead: OO#.. Playing >> Research Engineer (Solar/BatteriesO.O#. #.O#. with >> /Software/Embedded Controllers) .OO#. .OO#. rocks...1k >> --- >> Sent from my phone. Please excuse my brevity. >> >> On October 20, 2014 9:05:45 AM PDT, Dimitri Liakhovitski >> wrote: >>>Jeff, >>> >>>here is what I do with each file using library(tuneR): >>> >>>b<-readMP3("cairnomount.mp3") >>>myrange<-range(b@left) >>>write.table(myrange,"x myrange.txt",sep="\t") >>> >>>Would you like me to attach a bunch of large mp3 files? >>>I don't feel I have the right to clog people's inboxes with large >>>files. >>> >>>Thanks! >>> >>> >>> >>>On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller >>> >>>wrote: >>> You don't say what processing you are doing.. the answer to your >>>question is very likely there. To communicate effectively on this mailing >>>list, self-contained examples are needed. And in order to not corrupt the >>>example you will need to post in plain text. >>>--- Jeff NewmillerThe . . Go >>>Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. >>>Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. >>>rocks...1k >>>--- Sent from my phone. Please excuse my brevity. On October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: >Dear Rers, > >I am trying to run a for-loop in R. >During each iteration I read in an mp3 file and do some basic >processing. >If I do what I need to do for each file one by one - it works fine. >But once I start running a loop, it soon runs out of memory and >>>says: >can't >allocate a vector of size... >In each iteration of my loop I always overwrite the previously >>>created >object and do gc(). > >Any hints on how to fight this? > >Thanks a lot! > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commente
[R] glmer with multiple random slopes
Hi all, I'm modeling the probability that a subject attacks or rejects a prey item based on its proportion of yellow coloration and size. There are two populations of prey, one defended and the other undefended, so subjects should reject one type and accept others. Each subject has a unique rejection threshold that is a line on a contour plot with coloration and size on the x and y axes. I want to estimate the error around that line's slope, and believe that I need to estimate two random slopes per subject to do so, one in the color dimension and the other in the size dimension. The code that I think I should use to do this is: glmer(attack ~ prop.color + size + (prop.color + size|subject, family = binomial), but I cannot find a reference or example for fitting random slopes in different continuous dimensions. I would appreciate any pointers in the right direction. Thanks, David In case I've given a poor description of the problem, below is code to visualize the rejection threshold, using an optimal decision threshold rather than one estimated from the data: library(mnormt) library(lattice) modelms<- 31.2 mimicms<- 24 sds<- 4*4 modelmc<- 0.7 mimicmc<- 0.4 sdc<- 0.15*0.15 xv<-seq(0,1,0.01) yv<-seq(10,50,0.1) ys <- matrix(NA,length(xv),length(coeffs[1,])) for(i in 1:length(xv)) ys[i,] <- (coeffs[1,]+coeffs[2,]*xv[i])/(coeffs[3,]*-1) mu <- c(modelmc,modelms) #model sigma <- matrix(c(sdc,0,0,sds),2,2) z1<-NULL for(x in xv){ f <- dmnorm(cbind(x,yv), mu, sigma) z1<-rbind(z1,f) } contour(xv,yv,z1, nlevels = 5,col = "blue", lty = "solid", lwd = 1.8, xlab = "proportion yellow", ylab = "size") mu <- c(mimicmc,mimicms) #mimic sigma <- matrix(c(sdc,0,0,sds),2,2) z2<-NULL for(x in xv){ f <- dmnorm(cbind(x,yv), mu, sigma) z2<-rbind(z2,f) } contour(xv,yv,z2, nlevels = 5,add = TRUE,col = "red", lty = "solid", lwd = 1.8) contour(xv,yv,z2-z1, nlevels = 1,add = TRUE, col = "black", lty = "solid", lwd = 2.5) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] pasteFromExcel
On Oct 20, 2014, at 10:29 AM, Dan Murphy wrote: > Nice. > So if someone were to offer a currency regular expression that works > in their locale, I should also ask them to give me the results of > Sys.getlocale("LC_MONETARY") > and > options("OutDec") > and confirm that MS Excel honors that OutDec. I'm not sure we can know what you mean by "confirm that MS Excel honors that OutDec." The result of options("OutDec") was intended for you to determine what character not to remove from a monetary value in an R workspace. If the assumption is that all values will be in the same unit and that the user is not doing any currency conversions then: > decsep <- options("OutDec") > rmchar <- paste0( "[$£€", c(".", ",")[!c(".", ",") %in% decsep], "]" ) > gsub(rmchar, "", c("$1,000", "1,200", "800")) [1] "1000" "1200" "800" > Thank you, David. > -Dan > > On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius > wrote: >> >> On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote: >> >>> To Users of Excel: >>> >>> Following advice from Brian and Markus, I created an RMarkdown "vignette" >>> that shows an example of how the pasteFromExcel function in the excelRio >>> package on github could be used by an actuary to transfer a triangle from >>> Excel to R. See today's post at http://trinostics.blogspot.com/ >>> >>> Unfortunately, if you are located outside the US, the demonstrated >>> functionality will not work for you because the currency regex implemented >>> assumes the dollar sign ($) and comma/decimal punctuation of the form >>> 999,999.00. >>> >>> If anyone is interested in contributing currency regex expressions that >>> work in your locale, I would be happy to try to incorporate them in the >>> package. If anyone knows how best to determine the user's locale (might >>> "timezone" suffice?), I'd appreciate that help too. >>> >> >> ?Sys.getlocale # perhaps "LC_MONETARY" >> >> ?options # look for OutDec >> >> >>> [[alternative HTML version deleted]] >> >> >> >> David Winsemius >> Alameda, CA, USA >> David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] making a plot
On Oct 20, 2014, at 8:24 AM, Andrés Aragón wrote: > Enrico, > > This may help you: > > text(locator(1), "*", cex=1.5,adj=0.5 > > and > > text(locator(1), "º", cex=1.5,adj=0.5 Why not just use the values of x2 and y2 that were given to segments: > text( (ano+ranges)[1:3], 1:3, "*", cex=1.5,adj=0.5) > text( (ano+ranges)[4:6], 4:6 , "º", cex=1.5,adj=0.5) > > > Draw your plot, then write the code, locate the cursor on your plot, put > the symbols where you want itl and click. > > Regards, > > > Andrés > > PS ?locator > > > 2014-10-20 9:46 GMT-05:00 Enrico Colosimo : > >> Dear all, >> >> I am struggling to make a plot for my survival analysis >> class. >> >> This is my script >> >> >> labels<-c('1','2','3','4','5','6') >> ano<-c(2001,2002,2003,2004,2006,2008) >> ranges<-c(6,3,4,5,4,2) >> dotchart(ano, labels=labels, xlab='ano', >> ylab='Pacientes',pch=20,xlim=c(min(ano), max(ano+ranges))) >> segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4) >> >> I need to put an asterix (failure) by the end of the three first lines and >> a small circle (censoring) >> by the end of the last three. >> >> Someone can help me? >> >> Thanks, >> Enrico. >> >>[[alternative HTML version deleted]] > -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matching genes to a list of gene groups an built binary data frame
On Oct 20, 2014, at 6:28 AM, Karim Mezhoud wrote: > Genes <- c("ACACA", "BAX" , "BCL2", "BID", "BAX", "MAPK9") > > and a list of group of genes > > ListGroup <- list(group1=c("ACACA" ,"AHSA1" ,"AIMP2", "AKR1B1", > "AKT1", "AKT1S1"), group2=c("ANXA1" , "AR" , "ARID1A" , > "ATM" , "BAK1" , "BAX" ), group3=c("BCL2" ,"BCL2L1" , > "BCL2L11" , "BECN1" ,"BID" , "BIRC2")) Desired: > I would like to built a data frame as: > > ACACA BAX BCL2 BID BAX MAPK9 > group11 00 0 0 0 > group20 1 0 0 1 0 > group30 01 1 0 0 > > sapply(Genes, function(x) as.numeric(sapply(ListGroup, '%in%', x=x) ) ) ACACA BAX BCL2 BID BAX MAPK9 [1,] 1 00 0 0 0 [2,] 0 10 0 1 0 [3,] 0 01 1 0 0 ?'%in%' The x=x asserts that the x value will be used as the first argument to %in% so ListGroup items will be used as the table arguments. It's a matrix, so as.data.frame would be needed to deliver a dfrm. -- David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] understanding the no-label concept
On Thu, Oct 16, 2014 at 3:19 PM, wrote: >> aa <- 1:5 >> names(aa) <- c("Eins", "Zwei", "Drei", "Vier", "Fünf") >> aa > Eins Zwei Drei Vier Fünf >12345 >> table(aa) > 1 2 3 4 5 > 1 1 1 1 1 > > You see? It didn't work. perhaps you want table(names(aa)) Or maybe just aa <- - c("Eins", "Zwei", "Drei", "Vier", "Fünf") table(aa) > >> aa <- c(aa, 1, 2) >> aa > Eins Zwei Drei Vier Fünf >1234512 This does get more complicated if you want to add things by number. But why not just aa <- - c("Eins", "Zwei", "Drei", "Vier", "Fünf") aa <- c(aa, "Eins", "Zwei") table(aa) ? > > This is no solution for my case. > > But... > >> bb <- matrix(1:12, 3, 4, dimnames=list(letters[1:3], LETTERS[1:4])) Not really sure what this is meant to demonstrate. More generally there is no one-to-one mapping between the stata concept of variable and value labels to concepts in R. First, there is no equivalent of Stata variable labels. There is ?comment but it doesn't survive subsetting. The role that value labels play in Stata are covered variously in R by 1) just using character strings to store the information that you would typically put in a stata value label, b) naming your variable, or c) using factors. Personally I usually find option 1) more convenient. Best, Ista > > Nice. But look dam complex for a simple task. I see I have to change a > lot of the concepts in my mind and my workflows. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] pasteFromExcel
Nice. So if someone were to offer a currency regular expression that works in their locale, I should also ask them to give me the results of Sys.getlocale("LC_MONETARY") and options("OutDec") and confirm that MS Excel honors that OutDec. Thank you, David. -Dan On Mon, Oct 20, 2014 at 10:04 AM, David Winsemius wrote: > > On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote: > >> To Users of Excel: >> >> Following advice from Brian and Markus, I created an RMarkdown "vignette" >> that shows an example of how the pasteFromExcel function in the excelRio >> package on github could be used by an actuary to transfer a triangle from >> Excel to R. See today's post at http://trinostics.blogspot.com/ >> >> Unfortunately, if you are located outside the US, the demonstrated >> functionality will not work for you because the currency regex implemented >> assumes the dollar sign ($) and comma/decimal punctuation of the form >> 999,999.00. >> >> If anyone is interested in contributing currency regex expressions that >> work in your locale, I would be happy to try to incorporate them in the >> package. If anyone knows how best to determine the user's locale (might >> "timezone" suffice?), I'd appreciate that help too. >> > > ?Sys.getlocale # perhaps "LC_MONETARY" > > ?options # look for OutDec > > >> [[alternative HTML version deleted]] > > > > David Winsemius > Alameda, CA, USA > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] format negative numbers
You could do it with minimal use of regular expressions, along the lines of this example: x <- c('123','2.31','2.313-', '45-') is.neg <- grepl('-',x) xn <- x xn[is.neg] <- paste0( '-', substring(x[is.neg],1, nchar(x[is.neg])-1)) xn <- as.numeric(xn) I made a copy, 'xn', so that original and final can easily be compared, but it's not necessary to do so. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 10/20/14, 12:03 AM, "PIKAL Petr" wrote: >Dear all. > >Before I start fishing in (for me) murky regular expression waters I try >to ask community about changing format of negative numbers. > >For some reason I get a file with negative numbers formatted with >negative sign at end of number. > >something like > >0.123- > >It is imported as factors and I need to convert it to numbers again. >Before converting I need to change it to "correct" format > >-0.123 > >Does anybody know some simple way? > >Cheers >Petr > > > >Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou >určeny pouze jeho adresátům. >Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě >neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho >kopie vymažte ze svého systému. >Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento >email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. >Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi >či zpožděním přenosu e-mailu. > >V případě, že je tento e-mail součástí obchodního jednání: >- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření >smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. >- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně >přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze >strany příjemce s dodatkem či odchylkou. >- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve >výslovným dosažením shody na všech jejích náležitostech. >- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za >společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně >zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly >adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, >předloženy nebo jejich existence je adresátovi či osobě jím zastoupené >známá. > >This e-mail and any documents attached to it may be confidential and are >intended only for its intended recipients. >If you received this e-mail by mistake, please immediately inform its >sender. Delete the contents of this e-mail with all attachments and its >copies from your system. >If you are not the intended recipient of this e-mail, you are not >authorized to use, disseminate, copy or disclose this e-mail in any >manner. >The sender of this e-mail shall not be liable for any possible damage >caused by modifications of the e-mail or by delay with transfer of the >email. > >In case that this e-mail forms part of business dealings: >- the sender reserves the right to end negotiations about entering into a >contract in any time, for any reason, and without stating any reasoning. >- if the e-mail contains an offer, the recipient is entitled to >immediately accept such offer; The sender of this e-mail (offer) excludes >any acceptance of the offer on the part of the recipient containing any >amendment or variation. >- the sender insists on that the respective contract is concluded only >upon an express mutual agreement on all its aspects. >- the sender of this e-mail informs that he/she is not authorized to >enter into any contracts on behalf of the company except for cases in >which he/she is expressly authorized to do so in writing, and such >authorization or power of attorney is submitted to the recipient or the >person represented by the recipient, or the existence of such >authorization is known to the recipient of the person represented by the >recipient. >__ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/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] pasteFromExcel
On Oct 19, 2014, at 11:18 PM, Dan Murphy wrote: > To Users of Excel: > > Following advice from Brian and Markus, I created an RMarkdown "vignette" > that shows an example of how the pasteFromExcel function in the excelRio > package on github could be used by an actuary to transfer a triangle from > Excel to R. See today's post at http://trinostics.blogspot.com/ > > Unfortunately, if you are located outside the US, the demonstrated > functionality will not work for you because the currency regex implemented > assumes the dollar sign ($) and comma/decimal punctuation of the form > 999,999.00. > > If anyone is interested in contributing currency regex expressions that > work in your locale, I would be happy to try to incorporate them in the > package. If anyone knows how best to determine the user's locale (might > "timezone" suffice?), I'd appreciate that help too. > ?Sys.getlocale # perhaps "LC_MONETARY" ?options # look for OutDec > [[alternative HTML version deleted]] David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to clear R memory in a for loop
tuneR::readMP3 may not be allocating (or freeing) memory correctly. On both Linux and Windows I get the following (where 'jingle.mp3' is a sample mp3 that comes with Processing 2.1 which has a quarter million samples in it). If I do this as a sequence of top-level expression instead of as a for loop R does not crash. Perhaps you should talk with tuneR's maintainer, who could run valgrind over it. > library(tuneR) tuneR >= 1.0 has changed its Wave class definition. Use updateWave(object) to convert Wave objects saved with previous versions of tuneR. > b <- readMP3("jingle.mp3") > for(i in 1:100){cat(i,"");b <- readMP3("jingle.mp3")} 1 2 *** caught segfault *** address 0x3a81000, cause 'memory not mapped' Traceback: 1: .Call("do_read_mp3", data, package = "tuneR") 2: readMP3("jingle.mp3") Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Bill Dunlap TIBCO Software wdunlap tibco.com On Mon, Oct 20, 2014 at 9:25 AM, Jeff Newmiller wrote: > It is your responsibility (not mine) to simplify your example to the point > where it is small, self-contained, and reproducible (see the footer of this > message). In fact, doing so often highlights the issue to you before you > share it. If any old downloadable mp3 file can be used to reproduce the > problem then you would not need to share yours. (Note that this list strips > off most attachments, so links are better anyway.) > > I suspect that one file read repeatedly might create the problem... if it > doesn't, then that would be helpful to know. In any event, your "example" is > missing the key element of repetition, so it is not hardly reproducible. The > extra things you are doing to make it loop are likely to be important here. > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On October 20, 2014 9:05:45 AM PDT, Dimitri Liakhovitski > wrote: >>Jeff, >> >>here is what I do with each file using library(tuneR): >> >>b<-readMP3("cairnomount.mp3") >>myrange<-range(b@left) >>write.table(myrange,"x myrange.txt",sep="\t") >> >>Would you like me to attach a bunch of large mp3 files? >>I don't feel I have the right to clog people's inboxes with large >>files. >> >>Thanks! >> >> >> >>On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller >> >>wrote: >> >>> You don't say what processing you are doing.. the answer to your >>question >>> is very likely there. To communicate effectively on this mailing >>list, >>> self-contained examples are needed. And in order to not corrupt the >>example >>> you will need to post in plain text. >>> >>--- >>> Jeff NewmillerThe . . Go >>Live... >>> DCN:Basics: ##.#. ##.#. Live >>> Go... >>> Live: OO#.. Dead: OO#.. >>Playing >>> Research Engineer (Solar/BatteriesO.O#. #.O#. with >>> /Software/Embedded Controllers) .OO#. .OO#. >>rocks...1k >>> >>--- >>> Sent from my phone. Please excuse my brevity. >>> >>> On October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski < >>> dimitri.liakhovit...@gmail.com> wrote: >>> >Dear Rers, >>> > >>> >I am trying to run a for-loop in R. >>> >During each iteration I read in an mp3 file and do some basic >>> >processing. >>> >If I do what I need to do for each file one by one - it works fine. >>> >But once I start running a loop, it soon runs out of memory and >>says: >>> >can't >>> >allocate a vector of size... >>> >In each iteration of my loop I always overwrite the previously >>created >>> >object and do gc(). >>> > >>> >Any hints on how to fight this? >>> > >>> >Thanks a lot! >>> > >>> > [[alternative HTML version deleted]] >>> > >>> >__ >>> >R-help@r-project.org mailing list >>> >https://stat.ethz.ch/mailman/listinfo/r-help >>> >PLEASE do read the posting guide >>> >http://www.R-project.org/posting-guide.html >>> >and provide commented, minimal, self-contained, reproducible code. >>> >>> > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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 clear R memory in a for loop
On Mon, Oct 20, 2014 at 10:30 AM, Dimitri Liakhovitski < dimitri.liakhovit...@gmail.com> wrote: > Dear Rers, > > I am trying to run a for-loop in R. > During each iteration I read in an mp3 file and do some basic processing. > If I do what I need to do for each file one by one - it works fine. > But once I start running a loop, it soon runs out of memory and says: can't > allocate a vector of size... > In each iteration of my loop I always overwrite the previously created > object and do gc(). > > Any hints on how to fight this? > > Thanks a lot! > > > Please don't use HTML for messages. What occurs to me, from reading the other replies, is that perhaps within the loop you are causing other objects to be allocated. And that can be done just by doing a simple assignment, so it may not be obvious. What this can do is cause what we called a "sand bar" in the old days. That's where you allocate a big chunk of memory for an object. Say this take up 1/2 of your available space. You now create a small object. This object is _probably_ right next to the large object. You now release the large object. Your apparent free space is now almost what it was at the beginning. But when you try to allocate another large object which is, say, 2/3 of the maximum space, you can't because that small object is sitting right in the middle of our memory space. So you _can_ allocate 2 large objects which are 1/3 your free space size, but not 1 object which is 2/3 of the free space size. Which can lead to your type of situation. This is just a SWAG based on some experience in other systems. Most "garbage collection" do _not_ do memory consolidation. I don't know about R. -- The temperature of the aqueous content of an unremittingly ogled culinary vessel will not achieve 100 degrees on the Celsius scale. Maranatha! <>< John McKown [[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 clear R memory in a for loop
It is your responsibility (not mine) to simplify your example to the point where it is small, self-contained, and reproducible (see the footer of this message). In fact, doing so often highlights the issue to you before you share it. If any old downloadable mp3 file can be used to reproduce the problem then you would not need to share yours. (Note that this list strips off most attachments, so links are better anyway.) I suspect that one file read repeatedly might create the problem... if it doesn't, then that would be helpful to know. In any event, your "example" is missing the key element of repetition, so it is not hardly reproducible. The extra things you are doing to make it loop are likely to be important here. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On October 20, 2014 9:05:45 AM PDT, Dimitri Liakhovitski wrote: >Jeff, > >here is what I do with each file using library(tuneR): > >b<-readMP3("cairnomount.mp3") >myrange<-range(b@left) >write.table(myrange,"x myrange.txt",sep="\t") > >Would you like me to attach a bunch of large mp3 files? >I don't feel I have the right to clog people's inboxes with large >files. > >Thanks! > > > >On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller > >wrote: > >> You don't say what processing you are doing.. the answer to your >question >> is very likely there. To communicate effectively on this mailing >list, >> self-contained examples are needed. And in order to not corrupt the >example >> you will need to post in plain text. >> >--- >> Jeff NewmillerThe . . Go >Live... >> DCN:Basics: ##.#. ##.#. Live >> Go... >> Live: OO#.. Dead: OO#.. >Playing >> Research Engineer (Solar/BatteriesO.O#. #.O#. with >> /Software/Embedded Controllers) .OO#. .OO#. >rocks...1k >> >--- >> Sent from my phone. Please excuse my brevity. >> >> On October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski < >> dimitri.liakhovit...@gmail.com> wrote: >> >Dear Rers, >> > >> >I am trying to run a for-loop in R. >> >During each iteration I read in an mp3 file and do some basic >> >processing. >> >If I do what I need to do for each file one by one - it works fine. >> >But once I start running a loop, it soon runs out of memory and >says: >> >can't >> >allocate a vector of size... >> >In each iteration of my loop I always overwrite the previously >created >> >object and do gc(). >> > >> >Any hints on how to fight this? >> > >> >Thanks a lot! >> > >> > [[alternative HTML version deleted]] >> > >> >__ >> >R-help@r-project.org mailing list >> >https://stat.ethz.ch/mailman/listinfo/r-help >> >PLEASE do read the posting guide >> >http://www.R-project.org/posting-guide.html >> >and provide commented, minimal, self-contained, reproducible code. >> >> __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 clear R memory in a for loop
Jeff, here is what I do with each file using library(tuneR): b<-readMP3("cairnomount.mp3") myrange<-range(b@left) write.table(myrange,"x myrange.txt",sep="\t") Would you like me to attach a bunch of large mp3 files? I don't feel I have the right to clog people's inboxes with large files. Thanks! On Mon, Oct 20, 2014 at 11:40 AM, Jeff Newmiller wrote: > You don't say what processing you are doing.. the answer to your question > is very likely there. To communicate effectively on this mailing list, > self-contained examples are needed. And in order to not corrupt the example > you will need to post in plain text. > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. Live > Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski < > dimitri.liakhovit...@gmail.com> wrote: > >Dear Rers, > > > >I am trying to run a for-loop in R. > >During each iteration I read in an mp3 file and do some basic > >processing. > >If I do what I need to do for each file one by one - it works fine. > >But once I start running a loop, it soon runs out of memory and says: > >can't > >allocate a vector of size... > >In each iteration of my loop I always overwrite the previously created > >object and do gc(). > > > >Any hints on how to fight this? > > > >Thanks a lot! > > > > [[alternative HTML version deleted]] > > > >__ > >R-help@r-project.org mailing list > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide > >http://www.R-project.org/posting-guide.html > >and provide commented, minimal, self-contained, reproducible code. > > -- Dimitri Liakhovitski [[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 clear R memory in a for loop
You don't say what processing you are doing.. the answer to your question is very likely there. To communicate effectively on this mailing list, self-contained examples are needed. And in order to not corrupt the example you will need to post in plain text. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On October 20, 2014 8:30:21 AM PDT, Dimitri Liakhovitski wrote: >Dear Rers, > >I am trying to run a for-loop in R. >During each iteration I read in an mp3 file and do some basic >processing. >If I do what I need to do for each file one by one - it works fine. >But once I start running a loop, it soon runs out of memory and says: >can't >allocate a vector of size... >In each iteration of my loop I always overwrite the previously created >object and do gc(). > >Any hints on how to fight this? > >Thanks a lot! > > [[alternative HTML version deleted]] > >__ >R-help@r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 clear R memory in a for loop
Dear Rers, I am trying to run a for-loop in R. During each iteration I read in an mp3 file and do some basic processing. If I do what I need to do for each file one by one - it works fine. But once I start running a loop, it soon runs out of memory and says: can't allocate a vector of size... In each iteration of my loop I always overwrite the previously created object and do gc(). Any hints on how to fight this? Thanks a lot! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] making a plot
Enrico, This may help you: text(locator(1), "*", cex=1.5,adj=0.5 and text(locator(1), "º", cex=1.5,adj=0.5 Draw your plot, then write the code, locate the cursor on your plot, put the symbols where you want itl and click. Regards, Andrés PS ?locator 2014-10-20 9:46 GMT-05:00 Enrico Colosimo : > Dear all, > > I am struggling to make a plot for my survival analysis > class. > > This is my script > > > labels<-c('1','2','3','4','5','6') > ano<-c(2001,2002,2003,2004,2006,2008) > ranges<-c(6,3,4,5,4,2) > dotchart(ano, labels=labels, xlab='ano', > ylab='Pacientes',pch=20,xlim=c(min(ano), max(ano+ranges))) > segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4) > > I need to put an asterix (failure) by the end of the three first lines and > a small circle (censoring) > by the end of the last three. > > Someone can help me? > > Thanks, > Enrico. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] making a plot
Dear all, I am struggling to make a plot for my survival analysis class. This is my script labels<-c('1','2','3','4','5','6') ano<-c(2001,2002,2003,2004,2006,2008) ranges<-c(6,3,4,5,4,2) dotchart(ano, labels=labels, xlab='ano', ylab='Pacientes',pch=20,xlim=c(min(ano), max(ano+ranges))) segments(ano,1:6,ano+ranges,1:6,pch=25,lty=1,lend=4) I need to put an asterix (failure) by the end of the three first lines and a small circle (censoring) by the end of the last three. Someone can help me? Thanks, Enrico. [[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] how to predict scores after varimax rotation (using prcomp() and varimax())?
Hello. I ran a PCA analysis on a dataset with 5 variables and retained two components. I rotated them and now I want to predict the scores in a new data set for which the original variables are available. I normally use the predict.prcomp() function to predict using a prcomp object. For example.. PC1=predict(data.pca, new.data)[,1] ...will predict the first component in the new dataset. But how to do it with the rotated components/loadings, since after varimax() we don't have a prcomp object anymore? Thanks in advance! David [[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] strange loadings matrix after varimax rotation: PCA with prcomp in R
Hello. I ran a PCA analysis on a dataset with 5 variables and retained two components. I rotated them and now I want to predict the scores in a new data set for which the original variables are available. I normally use the predict.prcomp() function to predict using a prcomp object. For example.. PC1=predict(data.pca, new.data)[,1] ...will predict the first component in the new dataset. But how to do it with the rotated components/loadings, since after varimax() we don't have a prcomp object anymore? Thanks in advance! David [[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] matching genes to a list of gene groups an built binary data frame
Dear All, I have a gene list Genes <- c("ACACA", "BAX" , "BCL2", "BID", "BAX", "MAPK9") and a list of group of genes ListGroup <- list(group1=c("ACACA" ,"AHSA1" ,"AIMP2", "AKR1B1", "AKT1", "AKT1S1"), group2=c("ANXA1" , "AR" , "ARID1A" , "ATM" , "BAK1" , "BAX" ), group3=c("BCL2" ,"BCL2L1" , "BCL2L11" , "BECN1" ,"BID" , "BIRC2")) ListGroup $group1 [1] "ACACA" "AHSA1" "AIMP2" "AKR1B1" "AKT1" "AKT1S1" $group2 [1] "ANXA1" "AR" "ARID1A" "ATM""BAK1" "BAX" $group3 [1] "BCL2""BCL2L1" "BCL2L11" "BECN1" "BID" "BIRC2" I would like to built a data frame as: ACACA BAX BCL2 BID BAX MAPK9 group11 00 0 0 0 group20 1 0 0 1 0 group30 01 1 0 0 Many thanks, Karim [[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 judge a virable is a integer?
> 3. all.equal(a, as.integer(a)) Closer, but be aware that all.equal will not always return TRUE or FALSE and - more importantly - as.integer truncates towards zero and does NOT generally round to the nearest integer. a <- 4 - sqrt(2)^2 #Analytically 2 all.equal(a, as.integer(a)) # [1] "Mean relative difference: 0.5" #because as.integer(a) # [1] 1 To return FALSE from all.equal, wrap it in something like if(all.equal(a, round(a))==TRUE) TRUE else FALSE S *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 judge a virable is a integer?
> It's due to that, 1 is a numeric, 1.2 is a numeric, though it's true. but > deeply, > when i want to know 1 is an integer, there seems no easy way to get the > answer. > So, is there anyone happen to know it? First, you are not being as clear as you may think when you say " when i want to know 1 is an integer". It isn't. 1L is an integer. 1 is floating point. Do you want to know whether something is _stored as_ integer (eg 2L), whether it is a floating point number with exactly no nonzero digits after the point (eg 2.0), or whether it is something which would normally be expected to be integer if represented to infinite precision but is not exactly represented because of finite machine precision (eg sqrt(2)^2)? Once you've sorted out which of those you want - I think the last of the three - please read the posts you’re replying to. all.equal() was the suggested answer and is likely to be the nearest to a reliable answer you will get. Almost anything else will at least sometimes fail; for example sqrt(4.0) == 2L # [1] TRUE #But sqrt(2)^2 == 2L #[1] FALSE #whereas all.equal(sqrt(2)^2, 2L) #[1] TRUE Thus, all.equal can be used to test for something that would normally be considered an integer within machine precision, for example using nearly.integer <- function(x) all.equal(x, round(x)) You may make the comparison closer to a 'within machine precision' comparison by amending the tol argument to all.equal, which is documented on the help page you were referred to. S Ellison *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] format negative numbers
Hi Thanks to all who responded. My input string is rather clumsy. Actually it can have leading or trailing empty space too, it can be mixture of positive and negative numbers. In the meantime I made small function which just strips of - sign and make numbers from factors, find numbers which have - sign and change numbers which shall be negative to negative. Not as elegant as your solution but works even when there are leading or trailing spaces. zapor <- function(x) { num<-as.numeric(gsub("(-)", "", x)) zap<- grep("-", x) num[zap]<- num[zap] * (-1) num} > x <- as.factor( c(" 123.4- " , " 123 ")) > zapor(x) [1] -123.4 123.0 > I just thought that there is some reason for presenting negative numbers with minus sign behind the number in finance community and therefore somebody already invented clever way how to deal with such numbers. Cheers Petr > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Marc Girondot > Sent: Monday, October 20, 2014 12:53 PM > To: r-help@r-project.org > Subject: Re: [R] format negative numbers > > Is it what you want? > > > st <- "0.123-" > > gsub("(.+)(-)", "\\2\\1", st) > [1] "-0.123" > > st <- "0.123" > > gsub("(.+)(-)", "\\2\\1", st) > [1] "0.123" > > Sincerely > Marc > > Le 20/10/2014 09:03, PIKAL Petr a écrit : > > Dear all. > > > > Before I start fishing in (for me) murky regular expression waters I > try to ask community about changing format of negative numbers. > > > > For some reason I get a file with negative numbers formatted with > negative sign at end of number. > > > > something like > > > > 0.123- > > > > It is imported as factors and I need to convert it to numbers again. > Before converting I need to change it to "correct" format > > > > -0.123 > > > > Does anybody know some simple way? > > > > Cheers > > Petr > > > > > > > > Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a > jsou určeny pouze jeho adresátům. > > Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě > neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho > kopie vymažte ze svého systému. > > Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento > email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. > > Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou > modifikacemi či zpožděním přenosu e-mailu. > > > > V případě, že je tento e-mail součástí obchodního jednání: > > - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření > smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. > > - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně > přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky > ze strany příjemce s dodatkem či odchylkou. > > - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve > výslovným dosažením shody na všech jejích náležitostech. > > - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za > společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně > zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly > adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, > předloženy nebo jejich existence je adresátovi či osobě jím zastoupené > známá. > > > > This e-mail and any documents attached to it may be confidential and > are intended only for its intended recipients. > > If you received this e-mail by mistake, please immediately inform its > sender. Delete the contents of this e-mail with all attachments and its > copies from your system. > > If you are not the intended recipient of this e-mail, you are not > authorized to use, disseminate, copy or disclose this e-mail in any > manner. > > The sender of this e-mail shall not be liable for any possible damage > caused by modifications of the e-mail or by delay with transfer of the > email. > > > > In case that this e-mail forms part of business dealings: > > - the sender reserves the right to end negotiations about entering > into a contract in any time, for any reason, and without stating any > reasoning. > > - if the e-mail contains an offer, the recipient is entitled to > immediately accept such offer; The sender of this e-mail (offer) > excludes any acceptance of the offer on the part of the recipient > containing any amendment or variation. > > - the sender insists on that the respective contract is concluded > only upon an express mutual agreement on all its aspects. > > - the sender of this e-mail informs that he/she is not authorized to > enter into any contracts on behalf of the company except for cases in > which he/she is expressly authorized to do so in writing, and such > authorization or power of attorney is submitted to the recipient or the > person represented by the recipient, or the existence of such > authorization is known to the recipient of the person represented by > the recipient. > > __
[R] create vector objects by recurrence equation function
Subscribers, A spreadsheet contains (what appears to a low aptitude mathematician!) a recurrence equation: cellb1=2cellc1=0.1 celld1=5 cella2=1/(k1*cellb1)cellb2=cellb1+cellc1+celld1 cellc2=cella2*cellb2 celld2=cellb2*k2 where k are constants. Could someone please direct to a relevant function name in the manual, to create a vector (e.g. length 10) for subsequent values that would be in equivalent spreadsheet cells cellc3, celld3, cellc4, celld4, etc.? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] format negative numbers
Is it what you want? > st <- "0.123-" > gsub("(.+)(-)", "\\2\\1", st) [1] "-0.123" > st <- "0.123" > gsub("(.+)(-)", "\\2\\1", st) [1] "0.123" Sincerely Marc Le 20/10/2014 09:03, PIKAL Petr a écrit : Dear all. Before I start fishing in (for me) murky regular expression waters I try to ask community about changing format of negative numbers. For some reason I get a file with negative numbers formatted with negative sign at end of number. something like 0.123- It is imported as factors and I need to convert it to numbers again. Before converting I need to change it to "correct" format -0.123 Does anybody know some simple way? Cheers Petr Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] format negative numbers
Maybe not the most elegant way but at least works: library( stringr ) x <- as.factor( "123.4-" ) x <- -as.numeric( str_replace( as.character( x ), "-", "" ) ) x [1] -123.4 On Monday 20 October 2014 09:03:36 PIKAL Petr wrote: > Dear all. > > Before I start fishing in (for me) murky regular expression waters I try to > ask community about changing format of negative numbers. > > For some reason I get a file with negative numbers formatted with negative > sign at end of number. > > something like > > 0.123- > > It is imported as factors and I need to convert it to numbers again. Before > converting I need to change it to "correct" format > > -0.123 > > Does anybody know some simple way? > > Cheers > Petr . > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/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] dbHasCompleted() always returns TRUE for POSTGRES Database with RJDBC?
Hello Simon, Hello everyone, I have a problem with retrieving database-queries chunkwise. In my query (Postgresql-Database, Postgres-Version 9.1) dbHasCompleted seems to always return TRUE. dbGetQuery works for smaller tables, but not for the whole query, since then a Heap-Overflow-Error will occur (and a Error: "java.lang.OutOfMemoryError: GC overhead limit exceeded" when trying to set a larger size). Does anybody else have or had this problem? All the best Julian adapted Example from help (?dbHasCompleted ), Works ### require("RSQLite") con <- dbConnect(RSQLite::SQLite(), ":memory:") dbWriteTable(con, "mtcars", mtcars) # Fetch all results res <- dbSendQuery(con, "SELECT * FROM mtcars WHERE cyl = 4") dbFetch(res) dbClearResult(res) # Fetch in chunks res <- dbSendQuery(con, "SELECT * FROM mtcars") dbHasCompleted(res) ## RETURNS FALSE !!! while (!dbHasCompleted(res)) { chunk <- fetch(res, 10) print(nrow(chunk)) } dbClearResult(res) dbDisconnect(con) ## My Code, lamentably not reproducible because of needed Postgres-Server, not working # # Connect to Postgres-Database res2 <- dbSendQuery(Postgres_con, "select id from mytable limit 1000;" ) dbHasCompleted(res2) ##RETURNS TRUE! while (!dbHasCompleted(res2)) { chunk <- fetch(res2, 10 ) rbind(dk, chunk) } try({ dbClearResult(res2) rm(chunk,res2) }) [[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] saving parameters as a variable
Hi; In the simulation studies we need to save some measure in the output as a variable to do some calculation on them, how we can do that? For example: the p-value , t-value, in t-test ( t.test( ) ) or The estimated parameters in some models,(Ex: IRT model: graded response model) in ltm package: (see grm model in attachment file) grm(data, constrained = FALSE, *IRT.param* = TRUE, ...) *IRT.param:* bij: difficulty parameter for item i and category j) ai : discriminant parameter for item i) thata(k) : ability parameter for person k Note that this package does not give theta(k) even in output! How can i load theta parameters? Thanks in advanse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] distance from fitted line
Thankyou very much Joachim. Actually I already know the residual() command. I only wanted to know that is there a way to account for the fitted lines? its more of a criosity rather than a problem. :) Thankyou very much once again. Eliza To: eliza_bo...@hotmail.com Subject: Re: [R] distance from fitted line From: joachim.audena...@pcsierteelt.be Date: Mon, 20 Oct 2014 11:11:21 +0200 Hello Eliza, I'm quite new to R, but I use the residuals function to calculate the distance from my data points to the fitted line of my nls (non linear least squares model). residuals(name of your fitted model) I would check for a model that fits your datapoints and then calculate the residuals of the model to your data. Why do you fit the generalized Extreme Value distribution to your points in stead of a regression model? Met vriendelijke groeten/Kind Regards, Joachim Audenaert onderzoeker gewasbescherming PCS | proefcentrum voor sierteelt Schaessestraat 18, 9070 Destelbergen, Belgi� T: +32 (0)9 353 94 71 | F: +32 (0)9 353 94 95 E: joachim.audena...@pcsierteelt.be | W: www.pcsierteelt.be >> KEN JIJ DE 8 BASISPRINCIPES VAN IPM? MEER INFO OP WWW.PCSIERTEELT.BE From: eliza botto To: "r-help@r-project.org" Date: 19/10/2014 22:08 Subject: [R] distance from fitted line Sent by: r-help-boun...@r-project.org Dear useRs, I have the following dataset. > dput(EB) c(77.724, 76.708, 84.836, 85.09, 118.11, 65.024, 121.412, 63.5, 102.87, 81.3, 108.7, 110.7, 71.9, 42.2, 101, 151.4, 94, 112, 48, 73.4, 76.6, 62.2, 59.4, 114.3, 214.3, 110.5, 46, 84.7, 128.1, 45.2, 109.5, 102.3, 77.5, 61, 97.3, 78, 142, 88.2, 54, 91.4, 54.1, 96, 143.3, 153.7, 101.5, 95.8, 101, 131, 140, 189.4) I fitted generalized Extreme Value distribution on it by using following codes library(nsRFA) q=EB lmom=Lmoments(q) pr = par.GEV (lambda1=lmom["l1"], lambda2=lmom["l2"], tau3=lmom["lca"]) RP = c(1.01,2, 10, 20, 50, 100, 200, 500) quant = invF.GEV (1-1/RP, pr$xi, pr$alfa, pr$k) qs = sort(q) pp = 1:length(qs)/(length(qs)+1) RPpp = 1/(1-pp) plot(RP, quant, type="l", log="x",col="black",ylim=c(0,500),xlim=c(0.1,500)) points(RPpp, qs) What I want to do now is to calculate the distance of all the points from the "fitted line" and ultimately calculating RMSE of the data. Is there a way of doing it? Thankyou very much in advance Eliza [[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. PCS-proeven leiden tot nieuwe erkenningen in de sierteelt | Het PCS op LinkedIn Disclaimer\ | Please consider the environment before pri...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Dry Spell Problem.
Hi, Did you have a look at the "dw.spell" function from the "RMRAINGEN" package? It might be a starting point for you. Regards, Pascal On Mon, Oct 20, 2014 at 4:47 PM, Frederic Ntirenganya wrote: > Dear All, > > I want to solve the following problem on a climatic dataset. It contains > Year, Day and Rain as Columns names. > > Ex: > head(Samaru56) > Year Day Rain > 1 1928 10 > 2 1928 20 > 3 1928 30 > 4 1928 40 > 5 1928 50 > 6 1928 60 > > The first day from April 01 that gets more than 20 mm on a single day, or > totalled > over 2 consecutive days with the additional condition that there is no 10 > day (or longer) dry spell in the next 30 days. > > Any help is appreciated. Thanks!!! > > Regards, > Frederic. > -- > Frederic Ntirenganya > Maseno University, > Kenya. > Mobile:(+254)718492836 > Email: fr...@aims.ac.za > https://sites.google.com/a/aims.ac.za/fredo/ > > [[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. -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] need help for predictive analytics part
Hello sir, Actually, I 'm novice to R programming and currently working on prediction part for CPU usage log file (attached with mail). My task is to predict next hour CPU usage by taking "Time" as response and %user%nice %system %iowait%steal %idle, either all or one as predictor(s). Please help me out. I have attached CPU usage log file with mail. Please find attachment. Thank You in advance. This code is not working # cpu <- read.table(file = "D:/Swapnil/Data/cpu.txt", header = FALSE, col.names = c("Time","CPU","user","Nice","System","Iowait","Steal","Idle") ) #cpu user <- rep(cpu$user) Time <- c(cpu$Time) Time Time <- c(cpu$Time) user <- rep(cpu$user) user plot(cpu$user, xaxt="n", ylab="USER", xlab="") axis(1, labels=paste(cpu$user), at=1:11) cor(user, Time) fit <- lm(Time ~ user) fit attributes(fit) fit$coefficients residuals(fit) summary(fit) plot(fit) #prdiction part Time2hr <- data.frame(user=2.00) user2hr <-predict(fit, newdata=Time2hr) user2hr <-predict(fit, newdata=Time2hr) style <- c(rep(1,11)) plot(c(Time, user2hr), xaxt="n", ylab="TIME", xlab="", pch=style, col=style) axis(1, at=1:11,labels=c(paste(cpu$user,sep="Q"), "2011Q1", "2011Q2", "2011Q3", # Regards, Swapnil Khobragade Larsen & Toubro Infotech Ltd. Bldg. No.5&6, 1st Floor, Airoli, Navi Mumbai - 400708. e-mail ID: swapnil.khobrag...@lntinfotech.com Tel: @@@(Direct) | +91 9503043368 (M) The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and using or disseminating the information, and must notify the sender and delete it from their system. L&T Infotech will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in this e-mail" __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] FW: need help for predictive analytics part
Hello sir, Actually, I 'm novice to R programming and currently working on prediction part for CPU usage log file (attached with mail). My task is to predict next hour CPU usage by taking "Time" as response and %user%nice %system %iowait%steal %idle, either all or one as predictor(s). Please help me out. I have attached CPU usage log file with mail. Please find attachment. Thank You in advance. This code is not working # cpu <- read.table(file = "D:/Swapnil/Data/cpu.txt", header = FALSE, col.names = c("Time","CPU","user","Nice","System","Iowait","Steal","Idle") ) #cpu user <- rep(cpu$user) Time <- c(cpu$Time) Time Time <- c(cpu$Time) user <- rep(cpu$user) user plot(cpu$user, xaxt="n", ylab="USER", xlab="") axis(1, labels=paste(cpu$user), at=1:11) cor(user, Time) fit <- lm(Time ~ user) fit attributes(fit) fit$coefficients residuals(fit) summary(fit) plot(fit) #prdiction part Time2hr <- data.frame(user=2.00) user2hr <-predict(fit, newdata=Time2hr) user2hr <-predict(fit, newdata=Time2hr) style <- c(rep(1,11)) plot(c(Time, user2hr), xaxt="n", ylab="TIME", xlab="", pch=style, col=style) axis(1, at=1:11,labels=c(paste(cpu$user,sep="Q"), "2011Q1", "2011Q2", "2011Q3", # Regards, Swapnil Khobragade Larsen & Toubro Infotech Ltd. Bldg. No.5&6, 1st Floor, Airoli, Navi Mumbai - 400708. e-mail ID: swapnil.khobrag...@lntinfotech.com Tel: @@@(Direct) | +91 9503043368 (M) The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and using or disseminating the information, and must notify the sender and delete it from their system. L&T Infotech will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in this e-mail" Linux 3.2.0-23-generic (cldx-1311-1183) 02/25/14_x86_64_ (2 CPU) 20:47:14CPU %user %nice %system %iowait%steal %idle 20:47:15all 5.05 0.00 2.02 0.51 0.00 92.42 20:47:16all 4.02 0.00 2.01 0.00 0.00 93.97 20:47:17all 5.61 0.00 2.55 0.00 0.00 91.84 20:47:18all 3.55 0.00 1.52 0.00 0.00 94.92 20:47:19all 5.58 0.00 2.03 0.00 0.00 92.39 20:47:20all 2.05 0.00 3.08 0.00 0.00 94.87 20:47:21all 3.55 0.00 1.52 0.00 0.00 94.92 20:47:22all 5.64 0.00 2.56 0.00 0.00 91.79 20:47:23all 3.02 0.00 2.51 0.00 0.00 94.47 20:47:24all 3.08 0.00 2.05 0.00 0.00 94.87 20:47:25all 4.06 0.00 2.54 0.00 0.00 93.40 20:47:26all 4.06 0.00 1.52 0.00 0.00 94.42 21:47:12all 13.64 0.00 3.54 0.00 0.00 82.83 21:47:13all 6.19 0.00 2.06 0.00 0.00 91.75 21:47:14all 6.19 0.00 2.58 0.00 0.00 91.24 Average:all 5.71 0.00 2.31 0.41 0.00 91.57 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Dry Spell Problem.
Dear All, I want to solve the following problem on a climatic dataset. It contains Year, Day and Rain as Columns names. Ex: > head(Samaru56) Year Day Rain 1 1928 10 2 1928 20 3 1928 30 4 1928 40 5 1928 50 6 1928 60 The first day from April 01 that gets more than 20 mm on a single day, or totalled over 2 consecutive days with the additional condition that there is no 10 day (or longer) dry spell in the next 30 days. Any help is appreciated. Thanks!!! Regards, Frederic. -- Frederic Ntirenganya Maseno University, Kenya. Mobile:(+254)718492836 Email: fr...@aims.ac.za https://sites.google.com/a/aims.ac.za/fredo/ [[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] need help for predictive analytics part
Hello sir, Actually, I 'm novice to R programming and currently working on prediction part for CPU usage log file (attached with mail). My task is to predict next hour CPU usage by taking "Time" as response and %user%nice %system %iowait%steal %idle, either all or one as predictor(s). Please help me out. I have attached CPU usage log file with mail. Please find attachment. Thank You in advance. Regards, Swapnil Khobragade Larsen & Toubro Infotech Ltd. Bldg. No.5&6, 1st Floor, Airoli, Navi Mumbai - 400708. e-mail ID: swapnil.khobrag...@lntinfotech.com Tel: @@@(Direct) | +91 9503043368 (M) The contents of this e-mail and any attachment(s) may contain confidential or privileged information for the intended recipient(s). Unintended recipients are prohibited from taking action on the basis of information in this e-mail and using or disseminating the information, and must notify the sender and delete it from their system. L&T Infotech will not accept responsibility or liability for the accuracy or completeness of, or the presence of any virus or disabling code in this e-mail" Linux 3.2.0-23-generic (cldx-1311-1183) 02/25/14_x86_64_ (2 CPU) 20:47:14CPU %user %nice %system %iowait%steal %idle 20:47:15all 5.05 0.00 2.02 0.51 0.00 92.42 20:47:16all 4.02 0.00 2.01 0.00 0.00 93.97 20:47:17all 5.61 0.00 2.55 0.00 0.00 91.84 20:47:18all 3.55 0.00 1.52 0.00 0.00 94.92 20:47:19all 5.58 0.00 2.03 0.00 0.00 92.39 20:47:20all 2.05 0.00 3.08 0.00 0.00 94.87 20:47:21all 3.55 0.00 1.52 0.00 0.00 94.92 20:47:22all 5.64 0.00 2.56 0.00 0.00 91.79 20:47:23all 3.02 0.00 2.51 0.00 0.00 94.47 20:47:24all 3.08 0.00 2.05 0.00 0.00 94.87 20:47:25all 4.06 0.00 2.54 0.00 0.00 93.40 20:47:26all 4.06 0.00 1.52 0.00 0.00 94.42 21:47:12all 13.64 0.00 3.54 0.00 0.00 82.83 21:47:13all 6.19 0.00 2.06 0.00 0.00 91.75 21:47:14all 6.19 0.00 2.58 0.00 0.00 91.24 Average:all 5.71 0.00 2.31 0.41 0.00 91.57 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] format negative numbers
Dear all. Before I start fishing in (for me) murky regular expression waters I try to ask community about changing format of negative numbers. For some reason I get a file with negative numbers formatted with negative sign at end of number. something like 0.123- It is imported as factors and I need to convert it to numbers again. Before converting I need to change it to "correct" format -0.123 Does anybody know some simple way? Cheers Petr Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 2 missing observation of LSD analysis in R
I guess you can use na.string="1st missing value " then data[data==second missing value]<-NA. On Mon, Oct 20, 2014 at 9:21 AM, Jomy Jose wrote: > How to deal with the analysis of 2 missing observations in case of Latin > square design > > [[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. > -- Frederic Ntirenganya Maseno University, Kenya. Mobile:(+254)718492836 Email: fr...@aims.ac.za https://sites.google.com/a/aims.ac.za/fredo/ [[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.