[R] Multiple xyplots
Hi everyone, I'm hoping you can give me some pointers. I have a requirement to draw multiple (103) xy line plots onto one output device. Ideally the plots should be displayed in a hexagonal grid (example at www.maladmin.com/example.jpg). I can calculate the locations for each waveform but am wondering how to create multiple plotting areas. I have come accross references to a package grid (which doesn't seem to be in my CRAN mirror probability.ca) and lattice but I'm not sure if I'm on the correct lines. Any advice gratefully received. Thanks Tom -- --Tom Wright | Contact me: | | Skype: 0121 288 0756tomwright01) | | MSN: [EMAIL PROTECTED]| | Jabber: [EMAIL PROTECTED] | | ICQ: 423913453| |___| Ever since prehistoric times, wise men have tried to understand what, exactly, make people laugh. That's why they were called wise men. All the other prehistoric people were out puncturing each other with spears, and the wise men were back in the cave saying: How about: Would you please take my wife? No. How about: Here is my wife, please take her right now. No How about: Would you like to take something? My wife is available. No. How about ... -- Dave Barry, Why Humor is Funny __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] X11 device
Marius, Not quite what your asking but try ?bitmap. This can create png images without requiring X On Wed, 2006-31-05 at 20:55 +0200, Marius Hofert wrote: Hi, I am working with R on a Mac Powerbook G4. As described a couple of days ago, I would like to create an animation consisting of - say - 1000 plots (lattice: xyplot, wireframe etc.). Everything works perfectly fine (thanks to all of you for the suggestions and ideas), but before I am able to plot (.png's in a for-loop), I have to start a X11 device. I was wondering if it is possible to start the X11 device from the R console (as it is tedious to click the X11-button in the GUI). Searching through the web, I found the command X11(), but that _only_ works, if the X11-button in the GUI was pressed before... otherwise, I get an error message that it wasn't possible to start the X11 device and I get an additional warning saying that the connection to the X11 display couldn't be opened. Does it work to start such an device from the console? If so, what's the command to use? Thanks very much in advance. marius __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html script src=http://fragments.irrepressible.info/js/fragment-180.js; type=text/javascript /script [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] understanding DWT
Can someone please help me understand the examples given in the dwt function of the waveslim library library(waveslim) ?dwt I'm having a problem understanding these lines. I assume they are required because of how the algorythm deals with the signal bounderies. Am I correct in thinking that for wavelets of scale 1 and 2, the coefiecints need to be shifted by 2 places, for scale 3 and 4 shift by 3 places, therefore for scales 5 and 6 do i require a 4 place shift, similarly for scales 7 and 8 a 5 place shift? ie more generally should the shift be ceiling(scale/2)+1 Many thanks tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Newbie to R: would like to solve a problem
I often use R to create graphs for my web applications which are normally developed in PHP. I use the PHP command exec to shell out to the R script, passing any parameters on the command line. The params are then available in R using the commandArgs function. How to get the data back is another problem, when creating graphs its no biggy, I just create the graph as a file (using bitmap(type='png254') as the output device since png() wont function without an X environment). For simpler numeric data I guess at the worst you could write that to a text file then parse that but there may be better ways. On Fri, 2006-12-05 at 12:39 -0700, Shawn Mikula wrote: Using R for this would be a bit bone-headed since it is not ideally suited for web apps. Look at an active scripting language like PHP. I'm not sure if Geocities provides for server-side active scripting languages, in which case you will have to host your site elsewhere. - Original Message - From: percy tiglao [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Friday, May 12, 2006 11:07 AM Subject: [R] Newbie to R: would like to solve a problem Hello, I am very new to R (read the introduction a few hours ago), but experianced in several other languages (including Scheme, C, ObjC and C++, Java and Javascript) and I was wondering how to approach this problem: I am making a training calculator for a Video Game I play. Basically, I want to calculate the probability of killing an enemy within x hits, to help determine which is the best monster to train on in this game. The current implementation (http://geocities.com/dragontamer5788/maple2.html) uses the normal curve to estimate just about everything. Not necessarily a bad idea for when it takes 10 or 15 hits to destroy a single enemy, Central Limit Theorm kicks in and normal curve is probably a good idea, but my gut feeling is that it is not accurate for estimating kills in 1 or 2 shots (which happens in the majority of training monsters), or the probability of Knockback (which is always determined by a single shot). The (simplified) function to represent the damage would be: sdmg - function(min, max, skill){ if(runif(1) .4) (runif(1) * (max-min) + min) * skill else (runif(1) * (max-min) + min) * (skill+1) } total_damage - function(min, max, skill, num_attacks){ total - 0 for(i in 1:num_attacks){ total - total + sdmg(min, max, skill) } total } The above is how damage is calculated. So the probability distribution looks like 2 rectangles next to each other, one with height .6 and the other with height .4. Sdmg is a helper function, because some attacks attack 2 or 4 times in a single turn. Though, I dont want the simulation (what I'm doing with the runif here). I'd like to calculate the probability distribution of total_damage, total_damage + total damage (the convolution, representing 2 hits), and so on till about 5-8 hits (then I can just use normal curve in the web-calculator I'm making), then have a polynomial function estimate the probability distributions based on min, max, and skill. (So I can make my online calculator estimate the probability of killing enemies) Erm, I know it is a lot to ask for, but how would I go about making this in R? And if R isn't the right tool for this, is there any other tool you'd reccomend? Cause doing convolutions by hand sucks. Thanks a lot for reading this long message :) And thanks in advance for your help. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problems with optimize (again)
Can someone please explain what the $minimum result of the optimize function actually is? I'm trying to optimize the function: fitIT-function(ampFac,ts_wave1,ts_template){ template-stretchWaveTime(ts_template,ampFac) fit-calcFit(ts_wave1,template) return(fit) } with optimize(f=fitIT,interval=c(0.5,4),ts_wave1=test.data[,1],ts_template=test.data[,1]) $minimum [1] 3.764685 $objective [1] 1.037864 however when I run calcFit(test.data[,1],stretchWaveTime(test.data[,1],1.037864)) [1] 0.3059954 I thought $minimum and the result of the calcFit function should be the same. As a further question I'm going to need to nest optimize functions so I can optimize over two variables. How can I get the minimum and objective back from the nested function f, as well as the value to be minimised? I hope this makes sense and I apologise for the lack of reproducible code. If it will help I can include that in a further e-mail. Thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] matrix indexing
Can someone please give me a pointer here. I have two matrices matA A B C 1 5 2 4 2 2 4 3 3 1 2 4 matB A B C 1 TRUEFALSE TRUE 2 FALSE TRUETRUE 3 FALSE FALSE FALSE how do I extract all the values from matA where the coresponding entry in matB == TRUE (or FALSE), perferably in vector form. Many thanks tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] matrix indexing
Thanks everyone. Obvious when you think about it, and you check that both the matrices your trying it with are actually matrices... instead of one being a list. On Wed, 2006-15-03 at 06:03 -0500, tom wright wrote: Can someone please give me a pointer here. I have two matrices matA A B C 1 5 2 4 2 2 4 3 3 1 2 4 matB A B C 1 TRUEFALSE TRUE 2 FALSE TRUETRUE 3 FALSE FALSE FALSE how do I extract all the values from matA where the coresponding entry in matB == TRUE (or FALSE), perferably in vector form. Many thanks tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] help with optimize statement
Can some help me spot what I'm doing wrong here. I have two equations, one a michalis-menton eqn and one a straight line. I need to work out where they cross. I created the function: solveEqn-function(x,vals){ Vmax-vals[1] Ks-vals[2] m-vals[3] c-vals[4] diff-0 mmVal-exp(Vmax+x/(Ks+x)) slVal-x*m+c diff-mmVal-slVal return(diff) } optim(c(200,500),solveEqn,vals=c(2.4591201,-0.4015233,5.924e-5,3.437)) Error in optim(c(200, 500), solveEqn, vals = c(2.4591201, -0.4015233, : objective function in optim evaluates to length 2 not 1 If i replace return(diff) with sum(diff) then the optim function runs but returns the wrong value (which should be about 290). Many thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] exponent confusion
please excuse me if this ones a basic error y-c(-0.7,-0.6,-0.5) -0.7^1.22 [1] -0.6471718 y^1.22 [1] NaN NaN NaN am I missing something important in my basic math? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] New user: Custom probability distribution
rbinom(50,5,c(0.48,0.24,0.16,0.12)) On Thu, 2006-09-02 at 20:02 +0100, Jan Danielsson wrote: Hello, Given a probability function: p(x) = 12 / (25(x+1)) , x=0, 1, 2, 3 we generate the following values: C1 C2 0 0.48 1 0.24 2 0.16 3 0.12 Now, I'm supposed to create 50 random values using this table. In MiniTab, I simply selected Calc - Random Data - Discrete, and selected the columns, and it created 50 random values in a new column.[1] How do I do the same thing in R? [1] You may be wondering why I'm telling you this. Well, it's because if I were in your shoes, I'd think Oh, someone wants me to solve his homework.. I have already solved it using MiniTab, but I want to be able to use R instead (since I prefer NetBSD). __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] all.equal() and which()
Please excuse the lack of a complete dataset here, if its needed I'll be happy to provide it. Can anyone show me how to rewrite this? Browse[1] time(data)[24210:24220] [1] 24.209 24.210 24.211 24.212 24.213 24.214 24.215 24.216 24.217 [10] 24.218 24.219 Browse[1] which(time(data)==24.211) numeric(0) I'm assuming its an eps fault but which(all.equal(time(data),24.211)) dosnt seem to work __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] For each element in vector do...
a-c(0,1,2,3,0,4,5) b-vector(length=length(a)) b[a0]-a[a0]+1 b[a=0]-a[a=0] b [1] 0 2 3 4 0 5 6 On Tue, 2006-17-01 at 15:30 +0100, Andrej Kastrin wrote: Dear R useRs, I have a vector with positive and negative numbers: A=c(0,1,2,3,0,4,5) Now if i-th element in vector A is 0, then i-th element in vector B is a+1 else i-th element in vector b=a (or 0) vector A: 0 1 2 3 0 4 5 vector B: 0 2 3 4 0 5 6 What's the right way to do this. I still have some problems with for and if statements... Cheers, Andrej __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] data aquistion cards
Another year another project. Does anyone have any experience / pointers in obtaining data from an analog / digital converter hardware such as a National Instruments data aquisition card using R? I really need to obtain and process this data in a real time enviroment and I'm hoping that R already has packages to help me with this. If anyone has any experience with this I'd love to hear about it. Many thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] data collection with R
Another year another project. Does anyone have any experience / pointers in obtaining data from an analog / digital converter hardware such as a National Instruments data aquisition card using R? I really need to obtain and process this data in a real time enviroment and I'm hoping that R already has packages to help me with this. If anyone has any experience with this I'd love to hear about it. Many thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] use of tapply?
I'm still learning how to program with R and I was hoping someone could take the time to show me how I can rewrite this code? Many thanks Tom data.intersects-data.frame( x=c(0.230,0.411,0.477,0.241,0.552,0.230), y=c(0.119,0.515,0.261,0.431,0.304,0.389), angle=vector(length=6), length=vector(length=6), row.names=c('tbr','trg','dbr','dbg','pbr','pbg')) calcDist-function(x,y){ #calcualates distance from origin (C) origin-data.frame(x=0.34,y=0.36) dx-origin$x-x dy-origin$y-y length-sqrt(dx^2+dy^2) angle-asin(dy/length) return(list('length'=length,'angle'=angle)) } for(iLoc in 1:length(data.intersects[,1])){ result-calcDist(data.intersects[iLoc,]$x,data.intersects[iLoc,]$y) data.intersects[iLoc,]$angle-result$angle data.intersects[iLoc,]$length-result$length } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] HTML search Firefox
I have a similar problem here: /tmp/RtmpgRyAdm/.R/doc/manual/R-exts.html the folder structure exists just no files in it. There are subfolders with files and symlinks in so I doubt its a permissions problem. R.Version() $platform [1] x86_64-pc-linux-gnu $arch [1] x86_64 $os [1] linux-gnu $system [1] x86_64, linux-gnu $status [1] $major [1] 2 $minor [1] 1.0 $year [1] 2005 $month [1] 04 $day [1] 18 $language [1] R On Fri, 2005-09-12 at 11:40 +0100, Philippe Grosjean wrote: Hello, Sorry if this question was already asked (I though it was... but did not found the exact answer in the archives). I use R 2.2.0 and just updated to Firefox 1.5 (note that I already got the same result with Firefox 1.x.x) under Win XP sp2 US (full details of my config hereunder). When I try to use the HTML help search page, I can make a search: the message 'Applet SearchEngine started' appears in the statusbar and I got a result page, but that result page points to incorrect links like: 'file:///library/stats/html/ave.html' Obviously, that link should have been something like: 'file:///c:/Program%20Files/R/R-2.2.0/library/stats/html/ave.html' Any idea why the first part of the link is missing in the result page? On the same machine, using IE 6, it works like a charm (but I don't want to use that damn IE!!!). R.Version() $platform [1] i386-pc-mingw32 $arch [1] i386 $os [1] mingw32 $system [1] i386, mingw32 $status [1] $major [1] 2 $minor [1] 2.0 $year [1] 2005 $month [1] 10 $day [1] 06 $svn rev [1] 35749 $language [1] R and in Firefox 1.5, about:plugins, retuns me: Installed plug-ins ... Java(TM) 2 Platform Standard Edition 5.0 Update 4 with a lot of corresponding extensions installed, including: MIME Type Description Suffixes Enabled application/x-java-vm Java Yes Best regards, Philippe Grosjean __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] reg peak detection
Having missed last months thread I reinvented the wheel. I thought I'd post my code here for fun and feedback. getDerivation-function(v_dataset){ #setup a vector to hold derivations v_deriv-vector(length=length(v_dataset)-1) for(iLoc in 2:length(v_dataset)){ v_deriv[iLoc-1]-v_dataset[iLoc]-v_dataset[iLoc-1] } return(v_deriv) } getPeaks-function(v_deriv){ v_deriv-sign(as.numeric(v_deriv)) v_temp-vector(length=length(v_deriv)-1) for(iLoc in 1:length(v_deriv)-1){ v_temp[iLoc]-v_deriv[iLoc]+v_deriv[iLoc+1] } v_peaks-which(abs(v_temp)=1)+1 return(v_peaks) } set.seed(2) x - round(rnorm(100), 2) y - cumsum(x) system.time(deriv-getDerivation(y)) [1] 9.61 0.03 9.90 0.00 0.00 system.time(peaks-getPeaks(deriv)) [1] 8.76 0.12 9.11 0.00 0.00 (Times shown are on an AMD64 3400+) Regards Tom **An hour in the library is worth 8 in the lab** On Thu, 2005-08-12 at 14:25 -0800, Jim Porzak wrote: Ram, See excelent thread here last month. Search for finding peaks On 12/8/05, SHRIRAM R SAMPAT [EMAIL PROTECTED] wrote: Hallo everybody, I am doing a thesis in video extensometry and one my approaches requires peak detection in a two dimensional data. If would be grateful if anyone can throw some light on this for me by giving me some hints on how to do it or give me some links for it. thank very much in advance. Ram __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- HTH, Jim Porzak Loyalty Matrix Inc. San Francisco, CA [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] scoping issues?
Can anyone please help me understand whats happening here? Thanks Tom getAmpRatio-function(v_amps){ #calculates the amplitude ratios between the 3 largest amps and the rest bigamp-0 map-rep(TRUE,length(v_amps)) for(iLoc in 1:3){ bigamp-bigamp+max(v_amps) map[which.max(v_amps)]-FALSE v_amps-v_amps[map] map-rep(TRUE,length(v_amps)) } browser() return(bigamp/mean(v_amps)) } amps-c(1,2,3,3,3,2,1) getAmpRatio(amps) Browse[1] v_amps [1] 1 1 2 2 1 Browse[1] c(amps[1],amps[2],amps[3],amps[7],amps[8]) [1] 1 1 2 2 1 Browse[1] mean(v_amps) [1] 1.4 Browse[1] mean(amps[1],amps[2],amps[3],amps[7],amps[8]) [1] 1 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] scoping issues?
Thanks for the answers, yup the missing c() was what was throwing me. And thanks Barry for the slighly more elegant code, I'm a bit post christmas party here and not thinking as straight as I should be. On Thu, 2005-08-12 at 06:47 -0500, tom wright wrote: Can anyone please help me understand whats happening here? Thanks Tom getAmpRatio-function(v_amps){ #calculates the amplitude ratios between the 3 largest amps and the rest bigamp-0 map-rep(TRUE,length(v_amps)) for(iLoc in 1:3){ bigamp-bigamp+max(v_amps) map[which.max(v_amps)]-FALSE v_amps-v_amps[map] map-rep(TRUE,length(v_amps)) } browser() return(bigamp/mean(v_amps)) } amps-c(1,2,3,3,3,2,1) getAmpRatio(amps) Browse[1] v_amps [1] 1 1 2 2 1 Browse[1] c(amps[1],amps[2],amps[3],amps[7],amps[8]) [1] 1 1 2 2 1 Browse[1] mean(v_amps) [1] 1.4 Browse[1] mean(amps[1],amps[2],amps[3],amps[7],amps[8]) [1] 1 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] plot and factors
Your first question seems relatively simple: data.fall-subset(data,semester=='fall') data.spring-subset(data,semester=='spring') data.summer-subset(data,semester=='summer') plot(x=year,y=value1,data=data.fall) lines(x=year,y=value1,data=data.spring) lines(x=year,y=value1,data=data.summer) As for the second question perhaps the paste command is the way to go datayearsem-paste(data$year,data$semester,sep='.') On Fri, 2005-02-12 at 06:40 -0600, Jason Miller wrote: Read R-helpers, I'm relatively new to R and trying to jump in feet first. I've been able to learn a lot from on-line and printed documentation, but here's one question to which I can't find an answer. Well, it's a question with a couple parts. Thanks in advance for any direction (partial or complete) that anyone can provide. I have a data frame with three columns: Year, Semester, value1. I want to treat Year and Semester as factors; there are many years, and there are three semesters (Fall, Spring, Summer). First, I would like to be able to plot the data in this frame as Year v. value with one curve for each factor. I have been unable to do this. Is there any built-in R functionality that makes this easy, or do I need to build this by hand (e.g., using the techniques in FAQ 5.11 or 5.29)? Second, I would like to be able to plot the values against a doubly labeled axis that uses Year and Semester (three Semester ticks per Year). Is there a relatively straightforward way to do this? (What's happening, of course, is that I'd like to treat Year+Semester as a single factor for the purpose of marking the axis, but I'm not sure how to do that, either.) Again, thanks for whatever pointers people can share. Jason Jason E. Miller, Ph.D. Associate Professor of Mathematics Truman State University Kirksville, MO http://pyrite.truman.edu/~millerj/ 660.785.7430 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] cant get colAUC to plot
Sorry perhaps I should have posted again. It wasnt a package error instead it was my misunderstanding of what the package was asking for. For future information the colAUC function requires a dataframe with at least two datasets as well as an outcome set. It can be 'tricked' into drawing an ROC curve for one set simply by duplicating the data. On Thu, 2005-01-12 at 08:35 +0100, Uwe Ligges wrote: tom wright wrote: Can someone please explain why this wont plot. The cats example given for the colAUC function will plot. Please report bugs in packages to the package maintainer rather than to R-help. Uwe Ligges Many thanks again tom # library(caTools) a-rnorm(100) b-rbinom(100,1,0.7) colAUC(a,b,plotROC=TRUE) colAUC(a,b,plotROC=TRUE) Error in strwidth(legend, units = user, cex = cex) : argument legend is missing, with no default R.Version() $platform [1] x86_64-pc-linux-gnu $arch [1] x86_64 $os [1] linux-gnu $system [1] x86_64, linux-gnu $status [1] $major [1] 2 $minor [1] 1.0 $year [1] 2005 $month [1] 04 $day [1] 18 $language [1] R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] OT: Statistics question
I apologise for asking this question here but I am hoping that someone can either give me direct guidance and/or point me to a better group for this type of disucssion. I have what I feel should be a fairly simple problem but which my limited stats knowledge can't answer. I have two overlapping distributions (both normal) and I want to answer the question how do I calculate the cut-off value so I can be 95% sure that samples = than the cut off fall in the right hand distribution? A while ago I did a bayesian statistics course that I think answered this very question but in the absence of any course notes or recent practice Ihave forgotten how to go about this. Many thanks for your time Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] cant get colAUC to plot
Can someone please explain why this wont plot. The cats example given for the colAUC function will plot. Many thanks again tom # library(caTools) a-rnorm(100) b-rbinom(100,1,0.7) colAUC(a,b,plotROC=TRUE) colAUC(a,b,plotROC=TRUE) Error in strwidth(legend, units = user, cex = cex) : argument legend is missing, with no default R.Version() $platform [1] x86_64-pc-linux-gnu $arch [1] x86_64 $os [1] linux-gnu $system [1] x86_64, linux-gnu $status [1] $major [1] 2 $minor [1] 1.0 $year [1] 2005 $month [1] 04 $day [1] 18 $language [1] R __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] TryCatch() with read.csv(http://...)
How are you trying to break the loop? The next statement should move to the next in the sequence (from the Introduction To R manual) On Wed, 2005-23-11 at 11:57 -0500, David L. Van Brunt, Ph.D. wrote: Hi, folks! I'm trying to pull in data using read.csv(my URL goes here), and it really works fantastically. Amazing to pull in live data right off the internet, into RAM, and get busy... however... occasionally there is a server problem, or the data are not up yet, and instead of pushing through a nice CSV file, the server sends a 404 Not Found page... Since the read is inside a FOR loop, (pulling in and analyzing different data each time) I've been trying to use TryCatch() to pull in the file if it's OK, but to jump out to the next iteration of the loop otherwise (using next). I don't want to exit the script, I just want to skip this iteration and move on. This seems like it should be obvious, but I've read through the ? files and tried everything my smooth little brain can come up with... no luck. I still end up jumping out of the entire script if I hit an error page. Does anyone have some example syntax that I might examine or try out? I'm feeling pretty thick here... -- --- David L. Van Brunt, Ph.D. mailto:[EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] help on list
the dwt function returns an object with 'slots' dwt$d1 dwt$d2 ... which contain the partial wave coefficients and dwt$s1 which contains the leftover factors Please excuse my terminology here, I know what I'm talking about.. On Wed, 2005-23-11 at 16:11 +0100, both jean-pierre wrote: Hi, New to R, having done a wavelet analysis i got a result as list. The problem I have is : how can I acces to a given element of the list. here is what I get from my variable scale_d28 typeof(scale_d28) [1] list length(scale_d28) [1] 1 and scale_d28 is a list of 10 double values? Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] graphing help
a-c(1:10) plot(a,ylim=c(10,1)) On Tue, 2005-22-11 at 15:03 -0500, Anthony Pitts wrote: Hello all, Does anyone know how to make R graph the x-axis in descending order? I am all set in creating a vertical bar chart using either the plot or the xychart (in lattice), but I need the x-axis in descending order. I have tried resorting the data but apparently R automatically graphs the x-axis in ascending order. I have multiplied the data used for the x-axis by -1 and this works but now the tick-mark labels are negative. So does anyone know how to 1) make R graph the x-axis in descending order or 2) change the tick labels so I can get rid of the negative signs? Thanks in advance for your help Tony [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] PNG-import into R
Hi, I dont think you can import PNG images into R directly (although I may be wrong). I use ImageMagick (available for most operating systems) and the system() function to do my image conversions. convertImage-function(dirname,srcname,targetname){ strSrcName-shQuote(paste(dirname,srcname,sep='/')) strTrgName-shQuote(paste(dirname,targetname,sep='/')) filelist-system(paste('ls',strSrcName,sep=' '),TRUE,TRUE) if(length(filelist)1){ stop(Source Image Not Found) } filelist-system(paste('ls',strTrgName,sep=' '),TRUE,TRUE) if(length(filelist)1){ strcmd-paste('convert',strSrcName,strTrgName,sep=' ') system(strcmd) } } On Mon, 2005-21-11 at 11:36 +0100, Sydler, Dominik wrote: Hi there I'm looking for a function to read PNG-bitmap-images from a file into R. I only found: - the pixmap-package which cannot import png or similar formats - the rimage-package which can only import lossy jpeg-images (the convertion from png to jpeg modifies the data!) Is there any possibility to read PNG-files? Thanks for any help Dominic Sydler __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Warning message help
Shouldnt that be effort[Gear==300]-(DIST_TOW*7412) I think we're going to need to see some sample datasets to tell you any more. On Mon, 2005-21-11 at 10:44 -0500, Guenther, Cameron wrote: I am trying to great a new column of effort data from an existing vector of gears used. It is a simple code where effort[Gear==300]=(DIST_TOW*7412) effort[Gear==301]=(DIST_TOW*7412) The code appears to work for some of the data but fails for others and inserts a NA value I also get this warning message Warning message: number of items to replace is not a multiple of replacement length Can anybody tell me what this means. thanks Cameron Guenther Associate Research Scientist FWC/FWRI, Marine Fisheries Research 100 8th Avenue S.E. St. Petersburg, FL 33701 (727)896-8626 Ext. 4305 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Image display in R
This peice of very useful getcell() function was posted for me on this list by Duncan Murdoch (Thanks again Duncan). It allows the identification of a particular plot in a matrix of plots. All you need to do then is use this information to identify the original plot which you can then re-plot. ## Start Function ## getcell - function(pts = locator()) { usr - par(usr) plt - par(plt) mfg - par(mfg) x - pts$x y - pts$y # convert to 0-1 plot coordinates px - (x-usr[1])/(usr[2]-usr[1]) py - (y-usr[3])/(usr[4]-usr[3]) # convert to 0-1 frame coordinates fx - plt[1] + px*(plt[2]-plt[1]) fy - plt[3] + py*(plt[4]-plt[3]) # convert to a relative cell position cx - floor(fx) cy - floor(fy) # return the absolute cell position list(row = -cy+mfg[1],col = cx+mfg[2]) } ### End Function ### #For example Dset1-1:10 Dset2-rnorm(10) oldpar-par(mfrow=c(2,1)) plot(Dset1) plot(Dset2) cell-getcell(locator(1)) if((cell$row*cell$col)2){ par(mfrow=c(1,1)) plot(Dset1) } else { par(mfrow=c(1,1)) plot(Dset2) } I hope this gives you something to work with. Tom On Fri, 2005-18-11 at 09:46 -0500, Vasundhara Akkineni wrote: Hi all, I am trying to display a matrix of plots(images), for example a 3*3 matrix of 9 image plots, such that when a user clicks on a image i can show the enlarged plot. I tried the multiple graphic device(using mfcol=c(3,3) and mfg), but it creates multiple plots in a single image file. So, i won't be able to highlight a particular plot when the user clicks on it. To be more clear, can i display images in the form of a matrix in R. Are there any grids available? Please let me know. Thanks, Vasu. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] RODBC and Very long field lengths
I'm having a small problem using RODBC. I'm trying to retrieve a string from a very long memo field (512*20*9=9360 characters = 74880 bytes) in an MSAccess database. It appears that RODBC set a maximum buffer size for a single column of 65535 bytes. ## cut from RODBC.c ## } else { /* transfer as character */ int datalen = thisHandle-ColData[i].ColSize; if (datalen = 0 || datalen COLMAX) datalen = COLMAX; /* sanity check as the reports are sometimes unreliable */ if (datalen 65535) datalen = 65535; ## Can I increase this by just changeing the value in RODBC.c? If so how do I get R to re-compile the package? Thanks for your advice Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] strsplit
I'm stuck on what I feel should be a minor problem. I have a dataseries obtained from a MS Access database that consists of a series of numbers seperated by carridge returns (\r) Currently this data is in R as mode numeric??? I want to separate this into a vector of the componant numbers. Perhaps a little code will help describe what I've got here!! library(rodbc) s_sql-'SELECT Data from table where id=1' #only one record returned oWave-sqlQuery(oConn,s_sql) wave.data-oWave$data mode(data) [1] numeric Any clues will be much appreciated thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strsplit
Peter, Your correct I did mean to say mode(wave.data) but mode is still numeric??? I've made some changes so I can show you a trucated value for the data, please see the following code... getWave-function(connection,id=NULL){ if(is.null(id)){ stop('Must supply record#') } s_sql1-'SELECT Samplerate,Sampleswave,Prestimbaseline,Numberaveraged,LEFT(Data,100) as wavedata' s_sql2-'FROM [Patient Information]' s_sql3-paste('WHERE [Record#]=',id,sep='') s_sql-paste(s_sql1,s_sql2,s_sql3) wave-sqlQuery(connection,s_sql) return(wave) } owave-getWave(oConn,89) owave$wavedata [1] 161.1328\r158.6914\r162.3535\r159.9121\r158.6914\r159.9121\r153.8086 \r151.3672\r146.4844\r142.8223\r140.3809\r1 Levels: 161.1328\r158.6914\r162.3535\r159.9121\r158.6914\r159.9121 \r153.8086\r151.3672\r146.4844\r142.8223\r140.3809\r1 mode(owave$wavedata) [1] numeric On Tue, 2005-15-11 at 18:03 +0100, Peter Dalgaard wrote: tom wright [EMAIL PROTECTED] writes: I'm stuck on what I feel should be a minor problem. I have a dataseries obtained from a MS Access database that consists of a series of numbers seperated by carridge returns (\r) Currently this data is in R as mode numeric??? I want to separate this into a vector of the componant numbers. Perhaps a little code will help describe what I've got here!! library(rodbc) s_sql-'SELECT Data from table where id=1' #only one record returned oWave-sqlQuery(oConn,s_sql) wave.data-oWave$data mode(data) [1] numeric Any clues will be much appreciated Er, did you mean to say mode(wave.data)? Anyways, you say that you want to obtain a vector of numbers, and you got an object of mode numeric, which means that it is a vector of numbers. So what was the problem in the first place? If you had data with carriage returns inside, then you should have them as mode character. So there seems to be something that you're not telling us... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] changing the value of a variable from inside a function
Michael, I feel sure people are going to come up with other better suggestions here but does - work for you? test - matrix(NA,nrow=4,ncol=3) test[1,] - c(1,2,3) blah - function(i){ test[i,] - c(0,1,2) + i return(test) } On Tue, 2005-15-11 at 12:22 -0500, Michael Wolosin wrote: test - matrix(NA,nrow=4,ncol=3) test[1,] - c(1,2,3) blah - function(i){ test[i,] - c(0,1,2) + i return(test) } test blah(2) test __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] strsplit
Thanks everyone Using the sqlQuery line wave-sqlQuery(connection,s_sql,as.is=c(TRUE,TRUE,TRUE,TRUE,TRUE)) Then using strsplit(data,'\r') instead of split() seems to give what I need On Tue, 2005-15-11 at 17:29 +, Prof Brian Ripley wrote: On Tue, 15 Nov 2005, Peter Dalgaard wrote: tom wright [EMAIL PROTECTED] writes: I'm stuck on what I feel should be a minor problem. I have a dataseries obtained from a MS Access database that consists of a series of numbers seperated by carridge returns (\r) Currently this data is in R as mode numeric??? I want to separate this into a vector of the componant numbers. Perhaps a little code will help describe what I've got here!! library(rodbc) s_sql-'SELECT Data from table where id=1' #only one record returned oWave-sqlQuery(oConn,s_sql) wave.data-oWave$data mode(data) [1] numeric Any clues will be much appreciated Er, did you mean to say mode(wave.data)? Anyways, you say that you want to obtain a vector of numbers, and you got an object of mode numeric, which means that it is a vector of numbers. So what was the problem in the first place? If you had data with carriage returns inside, then you should have them as mode character. So there seems to be something that you're not telling us... or Access is not telling R. One possibility is that Access is reporting this field as numeric: use sqlColumns() to find out. If so, you need to sort this out in Access. If not, you can use the as.is argument: see ?sqlGetResults referenced from ?sqlQuery (although I would be surprised if type.convert was getting confused). __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Subtracting timeseries objects
Sorry to keep posting but I want to do this right and I'm hoping for some pointers I now have two time series objects which I need to subtract. Unfortunatly the two series dont have the same sample rates. When I try to subtract them avgSub-avg1-avg2 The time series object is clever enough to object. So I guess I need to write a function for subtraction of the time series objects which will need to interpolate the samples to the same sampling time (this linear interpolation should be ok here) I would like to make this function the default one to be used when a ts subtractin is attempted. Unfortunatly I dont really have much idea where to start with this. If someone could point me in the direction of some good reading I'll be grateful. Many thanks (again) Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] curve fitting question
I'd appreciate some direction here. I have a model for a system with two independant variables (i1,i2) and one dependant variable (d). I have experimental data recorded at multiple levels of the dependant variable (x). I need to work out the values for the independant variables that best fit the experimental data recorded for all the dependant variables. I assume I'm going to need the glm() function but I'd really appreciate some pointers in how to actually do this. Do I need to calculate the fits for a range of values of i1 and i2 for each value of d and then look to see what values of i1 and i2 give the best fit over all the experimental data or is there a way of doing this automatically? Please feel free to point me at other reading sources. Many thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem in waveslim library?
This code consistenly segfaults for me. Can someone please take a look and tell me if the problem is due to something I am doing or is there a problems with the dwt (idwt) functions in the waveslim library. Thanks tom library(waveslim) data-c(936.944,936.944,936.944,936.944,936.944,936.944,936.944,936.944,936.944,936.944,936.944,936.944,936.944,916.9947,909.592,941.8,961.9333,987.8,969.2,934.8667,912.8,913.2667,928.2,949.5333,933.4,948.5333,929.8667,935.2,937,934.6667,923.7333,911.8,937.0667,921.1333,914.6,941.9333,961.9333,950.,925.6,921.0667,916.2,927.2667,921.2667,938.0667,927.1333,949.8667,938.5333,934.9333,945.8,962.4667,967.2667,965,935.5333,935,927.9333,919.7333,930.4667,948,945.7333,972.9333,942.0667,921.5333,921.2,920.4,956.,945.6667,971.4,980,965.6,964.1333,960.0667,963,932.8667,952.4667,938.8,924.8,925.4667,949.4,931.4667,924.0667,926.8667,931.1333,! 937.2667,961.,952.2,958.1333,964,941.7333,936.1333,936.2,955.8667,964.6,962.,946.8667,971.5333,952.6667,954.9333,959.8667,969.2,970.2667,954.8,974.2667,947.1333,941.4667,949.0667,974.,943,929.,933.6667,926.6667,939.9333,936.6,952.4,954.6,947.4667,945.5333,948.7333,950.0667,941.6667,926.4667,934.,948.9333,946.7333,933.2667,913.2667,924.4667,937.8667,980.6,975.6,954.2667,943.2667,954,948.1333,947.0667,915,924.9333,938.2,942.6667,941.2667,956.0667,964.0667,958.6667,947.0667,940.4,926.1333,931.0667,940.9333,956.4667,958.2,941.8667,941.4,935.0667,943.! 9333,939,948.6667,964.1333,996.5333,95 7.4667,945.7333,922.5333,919.2,931.7333,952.2,921.0667,933.4667,948.6667,950.8,954,958.,942.6,936.2667,936.8,938.2667,943.6667,936.5333,920.1333,902.2667,933,948.7333,924.8667,941.8667,943.8,961.5333,968.,984.4667,949.4,933.2667,931.2667,934.5333,937.0667,959.5333,942.4,953.2667,975.8667,983.6,966.2,953.8667,938.0667,936.6667,931.7333,926.8667,965.8,970.1333,944.6,956.8,937.2667,933.0667,947.,935.7333,944.9333,946,943.6,969.7333,965.8,979.2,973.5333,970.6667,960.5333,939.2667,929.8,919.2667,925.,913.,924.2667,927.6667,936.6,919.0667,919.,936.2,954,938.066! 7,947.2667,945.0667,943.8,941.7333,942.1333,935.8,940.0667,942.4667,950.6,932.6,923.8667,920.2,916.6,939.8667,922.2,941.0667,927.4667,916.6,914.4,924.5333,958.5333,960.,932.7333,937,971.7333,981.8667,966.6667,949.,930.7333,918.9333,917.5333,948.1333,941.0667,952.8,966.5333,971.,962.8667,948.,970.0667,952.,937.2,951.9333,928.1333,937,948.0667,944.0667,963.7333,960.5333,931.2667,958.9333,971.4,969.2,963.1333,963.9333,965.1333,963,962.0667,938.6,945.7333,938.9333,936.8,954.2,961.1333,973.4667,989.9333,959.4,946.8667,959.7333,953.6667,953.8,945.4667,954.5333! ,957.6,951.5333,954.6,959.7333,943.4667,93
Re: [R] RODBC error
On Wed, 2005-02-11 at 07:55 +1000, Evan Sergeant wrote: Hi, I hope that someone can help me with the following problem with RODBC connection to a MySQL database I am running R version 2.2.0 on windows XP, and have the MySQL database registered in Windows ODBC. I have set up a web interface on my personal ISS web server using PhP to accept input values and then call Rterm with an R script to access the database and return a summary of the analysed data. This works perfectly if I run it from Rgui, or if I run Rterm from the dos prompt using the same command line arguments, but returns an RODBC error (below) when calling Rterm from the web interface 1: [RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified There appears to be some problem with recognising the database when called from the web page, even though it is not a problem at any other times. Does anyone have any suggestions as to what I can do to overcome this error Thanks for your help cheers Evan Sergeant Evan, It sounds like your problem is occuring when you try to access the database as a different user than yourself. Its been a while since I've been familiar with ms systems but IRC pws runs as its own user (ISUSR_...???). At the very least you will have to ensure that the datasource is registered as a system DSN not a user DSN. Appart from that you may run into other issues with access privileges. good luck tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] tree widget question
I'm trying to create an app using TclTk and R Can someone please explain how I bind a click event to the tree widget (http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/TreeWidget.html) Ideally I'd like to bind to particular elements in the tree but tkbind doesnt seem to work. thanks tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] locator
I'm trying to use the locator function on a drawing area with multiple graphs par(mfrow=c(1,2)) Is it possible to identify which graph has been clicked? thanks tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] locator
Perfect, thankyou On Fri, 2005-21-10 at 15:46 -0400, Duncan Murdoch wrote: On 10/21/2005 11:23 AM, tom wright wrote: I'm trying to use the locator function on a drawing area with multiple graphs par(mfrow=c(1,2)) Is it possible to identify which graph has been clicked? locator() will return coordinates based on the active graph (typically the last one you drew), so you can work it out from that. That is, convert from user coordinates to screen coordinates, and then work out the position from there: getcell - function(pts = locator()) { usr - par(usr) plt - par(plt) mfg - par(mfg) x - pts$x y - pts$y # convert to 0-1 plot coordinates px - (x-usr[1])/(usr[2]-usr[1]) py - (y-usr[3])/(usr[4]-usr[3]) # convert to 0-1 frame coordinates fx - plt[1] + px*(plt[2]-plt[1]) fy - plt[3] + py*(plt[4]-plt[3]) # convert to a relative cell position cx - floor(fx) cy - floor(fy) # return the absolute cell position list(row = -cy+mfg[1],col = cx+mfg[2]) } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Filter design in R?
On Wed, 2005-19-10 at 17:49 -0400, Israel Christie wrote: Dr. Williams, I ran across your inquiry on one of the R-help mailing lists regarding digital filter design and implementation. I found no response to your email in the archives and was wondering if you were able to find anything. Thanks, Israel I'm not Dr Williams, but I've been doing some work on filter design recently. I'm also no expert in this area but I found some very useful resources, primarily the online book The scientist and engineers guide to digital signal processing http://www.dspguide.com I came up with some code for generating simple highpass; low pass and bandpass filters, the filters can be applied using the filter() function Since I'm no expert here I'd really appreciate any comment from people who know more than me about these techniques. Regards Tom == BEGIN USAGE CODE== t-c(1:1000)/1000 #timeline 1KHz s1-sin(2*pi*t*3) #3Hz waveform s2-sin(2*pi*t*5) #5Hz waveform s3-sin(2*pi*t*10)#10Hz waveform stot-s1+s2+s3#complex waveform plot(stot,type='l') #create the filter, the longer it is the better cutoff #length must be an even number f-calcbpfilt(length=900,samplerate=1000,lowfreq=7,highfreq=4) sfilt-filter(stot,f,circular=TRUE) #apply the filter lines(sfilt,type='l',col='red') #only the 5Hz freq should be let through == END USAGE CODE== ==BEGIN CODE= calclpfilt-function(length,fc){ t-c(0:length+1) for (val in t){ if(val-length/2==0){ f[val]-as.numeric(2*pi*fc) }else{ f[val]-as.numeric(sin(2*pi*fc*(val-length/2))/(val-length/2)) } f[val]=as.numeric(f[val])*(0.54-0.46*cos(2*pi*val/length)) } #f-convolve(f,f) #normalise filter filt.total-sum(as.numeric(f)) f-as.numeric(f)/filt.total } calcbpfilt-function(length,samplerate,lowfreq,highfreq){ f.low-list() f.high-list() fc.low-1/(samplerate/lowfreq) fc.high-1/(samplerate/highfreq) t-c(0:length+1) #calculate the lowpass filter for (val in t){ if(val-length/2==0){ f.low[val]-as.numeric(2*pi*fc.low) }else{ f.low[val]-as.numeric(sin(2*pi*fc.low*(val-length/2))/(val-length/2)) } f.low[val]=as.numeric(f.low[val])*(0.54-0.46*cos(2*pi*val/length)) } #f-convolve(f,f) #normalise filter filt.total-sum(as.numeric(f.low)) f.low-as.numeric(f.low)/filt.total #calculate the second filter for (val in t){ if(val-length/2==0){ f.high[val]-as.numeric(2*pi*fc.high) }else{ f.high[val]-as.numeric(sin(2*pi*fc.high*(val-length/2))/(val-length/2)) } f.high[val]=as.numeric(f.high[val])*(0.54-0.46*cos(2*pi*val/length)) } #f-convolve(f,f) #normalise filter filt.total-sum(as.numeric(f.high)) f.high-as.numeric(f.high)/filt.total #invert the high filter to make it high pass f.high-0-f.high f.high[length/2]-f.high[length/2]+1 #add lowpass filterkernal and highpass filter kernel #makes band reject filter f.bandreject-f.low+f.high #make band pass by spectral inversion f.bandpass-0-f.bandreject f.bandpass[length/2]-f.bandpass[length/2]+1 f.bandpass } ==END CODE= __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Getting eps into Word documents.
On Mon, 2005-03-10 at 16:31 -0300, Rolf Turner wrote: A student in one of my courses has asked me about getting R graphics output (under Linux) into a Word document. I.e. she wants to do her R thing under Linux, but then do her word processing using Word. Scanning around the r-help archives I encountered an inquiry about this topic --- eps into Word documents --- from Paul Johnson but found no replies to it. I tried contacting him but the email address in the archives appeared not to be valid. Does anyone know a satisfactory solution to the problem of including a graphic which exists in the form of a *.eps (encapsulated postscript) file into a Word document. If so, would you be willing to share it with me and my student? If so, please be gentle in your explanation. I am not myself (repeat ***NOT***) a user of Word! Thanks. cheers, Rolf Turner [EMAIL PROTECTED] R can also create more generic image formats such as png, i just use these when I'm forced to insert graphics for presentations ?png __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] dynamic lists (data frames?)
Can someone please show me what I need to get something like this to work for(a in c(1:5)){ data$a-c(a:10) } so that i end up with a structure data$1-[1,2,3,4,5,6,7,8,9,10] data$2-[2,3,4,5,67,8,9,10] data$3-[3,4,5,67,8,9,10] data$4-[4,5,67,8,9,10] data$5-[5,67,8,9,10] thanks loads Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dynamic lists (data frames?)
Hmm my bad, Thanks for your replies but I think my example was a little to simple the actual code I'm using is: f_haardisolve-function(v_dataset){ #pad data to make length a power of 2 v_dataset-f_paddata(v_dataset) l_cooef-list() #holder for cooefficents i_count-1 #identity counter while(length(v_dataset)0){ #seperate odd and even points v_dataset-f_splitpoints(v_dataset) v_dataset-f_haarpredict(v_dataset) v_dataset-f_haaruplift(v_dataset) str_idx-paste('c',i_count,sep='') l_cooef $str_idx-v_dataset[c((length(v_dataset)/2)+1:(length(v_dataset)/2))] #should be no wrap on the previous line v_dataset-v_dataset[c(1:length(v_dataset)/2)] i_count-i_count+1 } l_cooef } In this particular case I could probably calculate the number of iterations and use l_cooef-names() but more is there a more generic method for adding another column of data? On Tue, 2005-27-09 at 10:39 -0400, tom wright wrote: Can someone please show me what I need to get something like this to work for(a in c(1:5)){ data$a-c(a:10) } so that i end up with a structure data$1-[1,2,3,4,5,6,7,8,9,10] data$2-[2,3,4,5,67,8,9,10] data$3-[3,4,5,67,8,9,10] data$4-[4,5,67,8,9,10] data$5-[5,67,8,9,10] thanks loads Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] dynamic lists (data frames?)
Got it thanks the trick was to create a variable with the new name str_idx-paste('c',i,sep='') then use double square brackets l_cooef[str_idx]]-whatever() f_haardisolve-function(v_dataset){ #pad data to make length a power of 2 v_dataset-f_paddata(v_dataset) l_cooef-list() #holder for cooefficents i_count-1 #identity counter while(length(v_dataset)0){ #seperate odd and even points v_dataset-f_splitpoints(v_dataset) v_dataset-f_haarpredict(v_dataset) v_dataset-f_haaruplift(v_dataset) str_idx-paste('c',i_count,sep='') l_cooef[[str_idx]]-list() l_cooef[[str_idx]]-v_dataset[c((length(v_dataset)/2)+1:(length(v_dataset)/2))] v_dataset-v_dataset[c(1:length(v_dataset)/2)] i_count-i_count+1 } l_cooef } On Tue, 2005-27-09 at 10:39 -0400, tom wright wrote: Can someone please show me what I need to get something like this to work for(a in c(1:5)){ data$a-c(a:10) } so that i end up with a structure data$1-[1,2,3,4,5,6,7,8,9,10] data$2-[2,3,4,5,67,8,9,10] data$3-[3,4,5,67,8,9,10] data$4-[4,5,67,8,9,10] data$5-[5,67,8,9,10] thanks loads Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] waveform filtering
On Mon, 2005-19-09 at 10:36 -0400, tom wright wrote: I'm not an engineer so I hope I'm using the correct terminology here. I have a recorded waveform that I want to apply low and high pass filters too, are tehre already R functions existing to do this or am I going to have to program my own? thanks for any pointers tom Thanks for the answers to this, after a little reading I realised that what sounded so simple wasnt quite. However chapters 15-18 of http://www.dspguide.com has been very useful. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] waveform filtering
I'm not an engineer so I hope I'm using the correct terminology here. I have a recorded waveform that I want to apply low and high pass filters too, are tehre already R functions existing to do this or am I going to have to program my own? thanks for any pointers tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] newbie question
Can someone tell me how I create a vector of numbers where the step isn't 1? i.e. x-(0.0,0.5,1.0,1.5) Thanks tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] interpolation function
On Fri, 2005-05-08 at 12:12 +, 吴 昊 wrote: Hi, I have a sparse matrix.I want to fill values into the entries whose value is 0.The new generated values should come from the interpolation of the values have existed.Does R provide such interpolation functions which operate on Matrix, for example ,such a matrix below 0 0 0 0 2.3 0 0 0 0 0 0 3.1 0 0 0 0 1.4 0 0 0 0 0 0 0 0 0 0 1.1 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 3 0 0 0 0 6 0 0 0 0 0 0 9 0 0 0 0 thanks a lot hao wu Does this look like an answer? If anyone knows a better way please tell me. d-c(0,2,3,2,0,3,4,0,0,0,0,0) d.mat-matrix(data=d,nrow=4,ncol=3,byrow=TRUE) for(i in 1:length(d.mat[1,])){ + d.mat[,i][d.mat[,i]==0]-mean(d.mat[,i][d.mat[,i]0]) + } Thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] use of NA's
Can someone please explain why this works: d-c(0,2,3,2,0,3,4,0,0,0,0,0) d.mat-matrix(data=d,nrow=4,ncol=3,byrow=TRUE) for(i in 1:length(d.mat[1,])){ + d.mat[,i][d.mat[,i]==0]-mean(d.mat[,i][d.mat[,i]0]) + } Whereas: d-c(0,2,3,2,0,3,4,0,0,0,0,0) d.mat-matrix(data=d,nrow=4,ncol=3,byrow=TRUE) d.mat[d.mat==0]-NA for(i in 1:length(d.mat[1,])){ + d.mat[,i][d.mat[,i]==NA]-mean(d.mat[,i],na.rm=TRUE) + } dosnt Thanks Tom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] problem with an IF statement?
Can somebody please take a look at this and tell me whats going wrong? It seems to be parsing wronly around the 'if' statement and gives me a directory listing. Thanks in advance Tom N.B. datan is an invented dataset xvals-c(1,0.4,0.2) datan-data.frame(s1=c(3,4,5),s2=c(5,5,5),s3=c(21,55,34),s4=c(5,3,2)) datan$sint-NA datan$sgrad-NA for(icount in 1:dim(datan)[1]) { yvals-c(datan[icount,4],datan[icount,3],datan[icount,2]) if((is.na(yvals[1]) + is.na(yvals[2]) + is.na(yvals[3]))2) { g-lm(yvals~xvals) datan$sint[icount]-g$coef[1] datan$sgrad[icount]-g$coef[2] } } __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html