Re: [R] how to read this data file into R?
On Tue, Feb 2, 2010 at 11:40 PM, David Winsemius dwinsem...@comcast.net wrote: The real solution is to grab the miscreant sender by the throat , er, tactfully discuss with your valued customer ,,, and shake out a machine readable form that has all of one row in a row. Indeed. But you might get away with something else... It is composed of blocks of (header + 25 data) rows - so using read.table with skip= set to N*26 and nrows=25 would let you read each block, and then use cbind to make up a big matrix. # Here's my test example, which I did with 26 rows just to make sure you understand it and don't just blindly cut n paste (or maybe I can't count): # test - create a matrix and dump it in this format to /tmp/m.txt: m=matrix(sample(26*40),26,40) m sink(/tmp/m.txt) m sink() # now read the second chunk: read.table(/tmp/m.txt,skip=27,nrows=26,sep=) # how to do the whole thing: # gotta have something to bind on to for starters: mm=matrix(0,nrow=26,ncol=1) for(i in 0:3){ + mm = cbind(mm,read.table(/tmp/m.txt,skip=i*27,nrows=26,sep=)) + } # get rid of that first column: mm=mm[,-1] # and now all(mm==m) [1] TRUE Recovery! But yes, if someone gave you this file then they done wrong, but sometimes all you have is an R transcript from the distant past (or possibly even an old S-plus transcript with an S-plus .Data that you can't read any more). Barry -- blog: http://geospaced.blogspot.com/ web: http://www.maths.lancs.ac.uk/~rowlings web: http://www.rowlingson.com/ twitter: http://twitter.com/geospacedman pics: http://www.flickr.com/photos/spacedman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Interactively editing point labels in a graph
Dear experts, I would like to be able to interactively (if possible, with mouse and clik) edit point labels in graphs, particularly in multivariate graphs, such as the biplots you get after a correspondence analysis (with, for example, package ca), where labels tend to overlap. The graph aspect ratio is relevant (it needs to be mantained). And I'm working with Windows XP. In this kind of graphs points in the graph are identified with labels, generally long (see, for example: http://www.white-history.com/Greece_files/hlafreq.jpg), and sometimes -as in the example- it is good to group certain points within ellipses. Do you know if exists some package able to do this task? Thanks in advance, Hug __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sqlUpdate RODBC
Dear all, I using R version 2.9.0 on Windows XP and want to insert data from a data frame in R into a oracle database via sqlUpdate with the package RODBC. My example is the following: TEST0-data.frame(NR=c(1,2,600),NAME=c(JK,TR,AR), DATUM=c(2009-01-01,2010-01-02,2010-06-09)) If I create the table in the database with sqlSave all is okay. sqlUpdate works fine and the update happens, but DATUM is VARCHAR2. Is there a possibility with RODBC to adjust the format according to my preferences? In my opinion the problem is the format of the variable DATUM. If I create the table manually in the oracle database and define data type DATE for DATUM, I receive a error message after starting sqlUpdate and R shuts down. There must be problem with the date format. So I try the following: sqlQuery(channel,alter session set NLS_DATE_FORMAT='-MM-DD') Unfortunately without sucess. I tried a lot of variations with the format. In R I worked with as.Date or strptime, too. The error message is the following: Failed exec in Update 22007...Fehler in Parameter 2: Überlauf im Datetime-Feld I don't know, if the error is a driver problem, a problem of the database or a problem of R. Has anyone experiences with this problem? Thank you very much in advance, Jens. -- View this message in context: http://n4.nabble.com/sqlUpdate-RODBC-tp1460867p1460867.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] What are Type II or III contrast? (contrast() in contrast package)
Le mercredi 03 février 2010 à 00:01 -0500, David Winsemius a écrit : On Feb 2, 2010, at 11:38 PM, Peng Yu wrote: ?contrast in the contrast package gives me the following description. However, I have no idea what Type II and III contrasts are. Could somebody explain it to me? And what does 'type' mean here? *‘type’*: set ‘type=average’ to average the individual contrasts (e.g., to obtain a Type II or III contrast) In no particular order: http://courses.washington.edu/b570/handouts/type3ss.pdf http://core.ecu.edu/psyc/wuenschk/SAS/SS1234.doc http://n4.nabble.com/a-kinder-view-of-Type-III-SS-td847282.html Don't expect any follow-up questions to be answered or further citations offered. This is really more in the realm of statistics education than an R specific question. Nonwhistanding David Winsemius' closing remark, I'd like to add something that should be requested reading (and maybe hinted at in lm()'s help page) : http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf (BTW, despite is age, MASS *is* requested reading, and Bill Venables' exegeses should be part of it). HTH, -- Emmanuel Charpentier, DDS, MsC :-) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] I need your help
hello, I have to do some work about information. and I want to do it with R software. The main problem is how to plot using R language. Could you give me help? I need some material about it. if you have some good material ,Could ihave i ? my email is cailix...@genomics.org.cn THX. -- View this message in context: http://n4.nabble.com/I-need-your-help-tp1460875p1460875.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Memory Problem
On 02/02/2010 09:33 PM, Meenakshi wrote: Hi, When I run the repeat loop in R for large dataset, I got Memory problem. How can I solve these problem. 1) Wait 2^m years, where m is the power of 2 that approximates the multiple of your current amount of RAM that would accommodate your problem (Moore, 1965). 2) Post some code that will give us an inkling of your problem (Plate, 2006). Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3D plot of following data
On 02/02/2010 11:01 PM, walter.dju...@chello.at wrote: Hello R-experts, I am having difficulties with 3D plotting (i.e. the evolution of various forward curves through time). I have two comma seperated files both ordered by date (in the first column) one containing contracts (meaning forward delivery months from YEAR_ Letter F ... January through letter Z ... December) and the other holding the closing price of the respective contract on the day also defined in the first column (see attachments). What I would like to do is plot a three dimensional figure with trade day (date) on the X-axis, contract on the Y-axis and the price of the forward contract being the z-value. I am quite a newbie and did not manage to merge these two files in a logic way, so that R could do a 3D plot. Has anyone tried to program Hans Rosling's time evolution graphs in R? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tapply for function taking of 1 argument?
Hi r-help-boun...@r-project.org napsal dne 02.02.2010 22:16:06: 'fraid not :-(( tapply( data, groups, weighted.mean, weights) tapply(seq(along=lll), rrr, function(i, x, w) weighted.mean(x[i], w[i]), x=lll, w=ttt) If you want to subset more than one thing, subset the index vector. The above help I obtained from Prof.Ripley several years ago so (untested) tapply( seq(along=data), groups, function (i, x, w) weighted.mean(x[i], w[i]), x=data, w=weights) I believe it shall still work. Regards Petr won't work because the *entire* weights vector is passed as the 2nd arg to weighted.means. But weighted.mean needs 'weights' to be split in the same way as 'data' -- the first and 2nd args need to correspond. Jorge Ivan Velez wrote: Hi sjaffem, You were almost there: tapply( yourdata, groups, weighted.mean, weights) See ?tapply for more information. HTH, Jorge -- View this message in context: http://n4.nabble.com/tapply-for-function-taking- of-1-argument-tp1460392p1460419.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lattice key inside panel
On Wed, Feb 3, 2010 at 10:50 AM, Santosh santosh2...@gmail.com wrote: Dear R-experts.. I am trying to generate legend inside panels of lattice barplots.. Following is a sample dataset.. Sno DN EP Y1 Y2 1 1 D1 A20 19 19 2 1 D1 A50 8 9 3 1 D1 A70 3 4 4 2 D2 A20 22 22 5 2 D2 A50 13 14 6 2 D2 A70 6 7 7 3 D2 A20 23 23 8 3 D2 A50 12 13 9 4 D1 A20 19 19 10 4 D1 A50 10 10 11 4 D1 A70 3 4 12 5 D1 A20 28 28 13 5 D1 A50 16 16 14 5 D1 A70 7 7 15 5 D3 A20 24 24 16 5 D3 A50 14 14 17 5 D3 A70 6 6 18 6 D4 A20 15 15 19 6 D4 A50 7 8 20 6 D4 A70 3 3 21 7 D5 A20 19 20 22 7 D5 A50 5 6 23 7 D5 A70 3 3 24 8 D6 A20 26 26 25 8 D6 A50 10 10 26 9 D7 A20 30 30 27 9 D7 A50 10 9 28 10 D7 A20 21 22 29 10 D7 A50 10 10 30 10 D7 A70 4 4 I am trying to generate barplot with legend inside each panel..where the rectangular colors indicate the values for DN. I have not been successful in generating labels inside.. what am I missing? You should have draw.key(list( rectangles=list(col=rainbow(6)), text=list(lab='DN')), draw = TRUE, vp = viewport(x = unit(0.5, npc), y = unit(0.5, npc))) whereas you had draw.key(list( rectangles=list(col=rainbow(6)), text=list(lab='DN'), draw = TRUE, vp = viewport(x = unit(0.5, npc), y = unit(0.5, npc -Deepayan barchart(Y1~factor(as.character(EP))|Sno, groups=DN, orgin=0, subscripts=T, panel = function(x,y,groups=groups, ...) { require(grid) panel.barchart(x,y,groups=groups,...) #panel.text(...) draw.key(list( rectangles=list(col=rainbow(6)), text=list(lab='DN'), draw = TRUE, vp = viewport(x = unit(0.5, npc), y = unit(0.5, npc}, data=x1, distribute.type=T, layout=c(3,3), scales=list(rot=45,relation=free)) Thanks, Santosh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] create an object in a loop (v3)
Hi! Looks like get() doesn't work. Here is what I do and what I get (still in the loop): names(get(paste(names(file)[3], name.num, sep=_)))- levels(factor(file[[3]])) Error in names(get(paste(names(file)[3], name.num, sep = _)))- levels(factor(file[[3]])) : could not find function get- print(names(get(paste(names(file)[3], name.num, sep=_ #4 iterations; I wanted to test this part NULL NULL NULL NULL Does anyone has an idea about it? Thanks Ivan Le 2/2/2010 19:38, Chris Campbell a écrit : On Tue, Feb 2, 2010 at 11:44, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Hi David, Thanks for your answer. But I don't really see how I can extend it with my real data. The thing is that I have more than 3 names and 1 value for each name. Moreover, each is different from one run to another. That is why I was trying with a modification of names(). Also to be noted is that I simplified the name in assign(); I actually have 2 other variables that will be pasted to create the name. Here is my code (I kept only what is important for that part): library(WRS) seq.num- seq(7,10,1)#column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction } Sounds like a job for 'get'. Try this (untested): names(get(paste(names(file)[3], name.num, sep=_))) Good luck Thanks in advance for your help. Regards, Ivan Le 2/1/2010 18:47, David Winsemius a écrit : On Feb 1, 2010, at 12:33 PM, Ivan Calandra wrote: I have a follow-up question: I use assign() to store some value in my paste()-created object as suggested: for (i in 1:3) { assign(paste(object, i, sep=), c(a, b, c)) } Then I would like to change the names of the elements of that object within the loop. Since it is all in a loop, I cannot give the name of the object manually by doing something like: names(object1)- c(tooth, bone, species). The only thing I can give to names() is paste(object, i, sep=), which doesn't work. Any idea of how to do it? for (i in paste(object, 1:3, sep=)) { + assign(i, c(tooth=a, bone=b, species=c) ) + } object1 toothbone species a b c Thanks in advance Ivan Le 2/1/2010 17:14, David Winsemius a écrit : Upon reading it yesterday, it appeared as it would have required some serious testing and there was no data on which to do any work. You were clearly not taking the time to isolate the problem and construct a dataset. But who knows? When you say What I want to do is. ... ,I would like the name of the list to be created in the loop too, maybe all you needed was to be pointed to was: ?assign But if that were the case, then you lost most of your audience along the way with a bunch of unneeded and obscure code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Institut und Museum Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Subset and plot
Hi r-help-boun...@r-project.org napsal dne 03.02.2010 02:54:46: Let's look at your data frame: str(daily.sub1) 'data.frame': 9 obs. of 4 variables: $ Trial: Factor w/ 1 level 2: 1 1 1 1 1 1 1 1 1 $ Tanks: Factor w/ 3 levels a4,c4,h4: 1 1 1 2 2 2 3 3 3 $ Day : Factor w/ 9 levels 10,11,12,..: 4 5 6 7 8 9 1 2 3 $ Wgt : Factor w/ 9 levels 16,17,18,..: 1 2 3 4 5 6 7 8 9 When you did the cbind to get daily, it converted the matrix to character; therefore, when you coerced it to a data frame, everything was read as a factor. What you needed to do was daily - data.frame(Trial = rep(c(1,2),each=12), Tanks=rep(rep(c(a3,a4,c4,h4),each=3),2), Day=rep(c(1:12),2), Wgt=c(1:24)) str(daily) 'data.frame': 24 obs. of 4 variables: $ Trial: num 1 1 1 1 1 1 1 1 1 1 ... $ Tanks: Factor w/ 4 levels a3,a4,c4,..: 1 1 1 2 2 2 3 3 3 4 ... $ Day : int 1 2 3 4 5 6 7 8 9 10 ... $ Wgt : int 1 2 3 4 5 6 7 8 9 10 ... Then... daily.sub-subset(daily, subset=Trial==2 Tanks==a4|Trial==2 Tanks==c4|Trial==2 Tanks==h4) str(daily.sub) 'data.frame': 9 obs. of 4 variables: $ Trial: num 2 2 2 2 2 2 2 2 2 $ Tanks: Factor w/ 4 levels a3,a4,c4,..: 2 2 2 3 3 3 4 4 4 $ Day : int 4 5 6 7 8 9 10 11 12 $ Wgt : int 16 17 18 19 20 21 22 23 24 But you're still not done because Tanks is a factor and subscripts have to be numeric, so daily.sub$tanks - as.numeric(as.character(daily.sub$Tanks)) Shouldn't it be daily.sub$tanks - as.numeric(daily.sub$Tanks) Regards Petr and *now* your plot will work... plot(Wgt ~ Day, data = daily.sub, pch=c(2,19,21)[tanks]) the choice of plotting character being determined by the value of tanks. HTH, Dennis On Tue, Feb 2, 2010 at 5:19 PM, Marlin Keith Cox marlink...@gmail.comwrote: I tried the following and still could not get it to work. I understand your logic, but cannot get this to work. rm(list=ls()) Trial-rep(c(1,2),each=12) Tanks=rep(c(a3,a4,c4,h4),each=3,2) Day=rep(c(1:12),2) Wgt=c(1:24) daily-cbind(Trial, Tanks, Day, Wgt) daily daily.sub-subset(daily, subset=Trial==2 Tanks==a4|Trial==2 Tanks==c4|Trial==2 Tanks==h4) daily.sub1-as.data.frame(daily.sub) x11() plot(Day, Wgt, pch=c(2,19,21)[Tanks]) with(daily.sub1,c(2,19,21)[Tanks]) On Tue, Feb 2, 2010 at 1:05 PM, Jeff Laake jeff.la...@noaa.gov wrote: The problem is with attach. You should have seen an error that the objects are aliased. You have Tanks in your workspace and in the attached dataframe. It is using the one in your workspace which is not a factor variable. Try: c(2,19,21)[Tanks] with(daily.sub1,c(2,19,21)[Tanks]) Avoid attach and use with which is a temporary attach that won't be subject to that problem. --jeff On 2/2/2010 11:51 AM, Marlin Keith Cox wrote: Here is a runable program. When I plot Day and Wgt, it graphs all the data points. All I need is daily.sub1 plotted. I also need each Tanks to have its own col or pch. When I run it with the line with pch, it gives me nothing. rm(list=ls()) Trial-rep(c(1,2),each=12) Tanks=rep(c(a3,a4,c4,h4),each=3,2) Day=rep(c(1:12),2) Wgt=c(1:24) daily-cbind(Trial, Tanks, Day, Wgt) daily daily.sub-subset(daily, subset=Trial==2 Tanks==a4|Trial==2 Tanks==c4|Trial==2 Tanks==h4) daily.sub1-as.data.frame(daily.sub) attach(daily.sub1) daily.sub1 x11() plot(Day, Wgt) #plot(Day, Wgt, pch=c(2,19,21)[Tanks]) detach(daily.sub1) -- M. Keith Cox, Ph.D. Alaska NOAA Fisheries, National Marine Fisheries Service Auke Bay Laboratories 17109 Pt. Lena Loop Rd. Juneau, AK 99801 keith@noaa.gov marlink...@gmail.com U.S. (907) 789-6603 [[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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] merging columns
Yes. data.df[,wcol,drop=FALSE] For an explanation of drop see ?[.data.frame Chuck White chuckwhi...@charter.net wrote in message news:20100202212800.o8xbu.681696.r...@mp11... Additional clarification: the problem only comes when you have one column selected from the original dataframe. You need to make the following modification to the original example: data.df - data.frame(aa=c(1,1,0), cc=c(1,0,0), aab=c(0,1,0), aac=c(0,0,1), bb=c(1,0,1)) And, the following seems to work: data.frame(sapply(col2.uniq, function(col) { wcol - which(col==col2) as.numeric(rowSums(data.frame(data.df[,wcol]))0) })) I had to wrap data.df[,wcol] in another data.frame to handle situations where wcol had one element. Is there a better approach? Chuck White chuckwhi...@charter.net wrote: Hello -- I am trying to merge columns in a dataframe based on substring matches in colnames. I would appreciate if somebody can suggest a faster/cleaner approach (eg. I would have really liked to avoid the if-else piece but rowSums does not like that). Thanks. data.df - data.frame(aa=c(1,1,0), bbcc=c(1,0,0), aab=c(0,1,0), aac=c(0,0,1), bbk=c(1,0,1)) col2 - substr(colnames(data.df),1,2) col2.uniq - unique(col2) names(col2.uniq) - col2.uniq data.frame(sapply(col2.uniq, function(col) { wcol - which(col==col2) if(length(wcol)1) { tmp - rowSums(data.df[,wcol]) } else { tmp - data.df[,wcol] } as.numeric(tmp0) })) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: I need your help
Hi r-help-boun...@r-project.org napsal dne 03.02.2010 09:19:59: hello, I have to do some work about information. and I want to do it with R software. If you have working connection to internet try to search http://www.r-project.org/index.html documentation section (either for manuals or contributed documentation ). If you are there, you could install on your computer latest appropriate version of R software. The main problem is how to plot using R language. If this was the **only** main problem it would be a wonderful world. Regards Petr Could you give me help? I need some material about it. if you have some good material ,Could ihave i ? my email is cailix...@genomics.org.cn THX. -- View this message in context: http://n4.nabble.com/I-need-your-help- tp1460875p1460875.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plm package index
Dear all, i just wonder if there´s a way to use a two column time index field in plm package. the manual says the following concerning data indexing: a character vector of length two containing the names of the individual and the time index, What would y´all do with a quarterly dataset that contains one column for the period and one for the year. Do I have to convert it to one single date field first ? thx in advance matt [[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] Build a matrix from another matrix by specifying the indexes
Hi r-help-boun...@r-project.org napsal dne 02.02.2010 21:32:16: ke te pehea koe Peter? I don't see how I could do this with a merge to be honest... mat-matrix(sample(letters[1:3], 24, replace=T),6,4) mat [,1] [,2] [,3] [,4] [1,] b c b c [2,] b a a c [3,] c b c a [4,] b b a a [5,] a a a a [6,] a c b c mat2-matrix(sample(letters[1:5], 24, replace=T),6,4) mat2 [,1] [,2] [,3] [,4] [1,] c a d c [2,] c b c b [3,] c c a d [4,] c b d c [5,] e c c e [6,] a b d c df1-data.frame(mat) df2-data.frame(mat2) merge(df1, df2, all=T) X1 X2 X3 X4 1 a a a a 2 a b d c 3 a c b c 4 b a a c 5 b b a a 6 b c b c 7 c a d c 8 c b c a 9 c b c b 10 c b d c 11 c c a d 12 e c c e merge(df1, df2, by=c(X1, X2), all=T) X1 X2 X3.x X4.x X3.y X4.y 1 a aaa NA NA 2 a b NA NAdc 3 a cbc NA NA 4 b aac NA NA 5 b baa NA NA 6 b cbc NA NA 7 c a NA NAdc 8 c bcacb 9 c bcadc 10 c c NA NAad 11 e c NA NAce Is this what you want? Regards Petr - Anna Lippel -- View this message in context: http://n4.nabble.com/Build-a-matrix-from- another-matrix-by-specifying-the-indexes-tp1460326p1460355.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] color blending and transparency
I am using ggplot and posted this question at that helplist. It was suggested that I try a more general R-help list for a possible solution to this problem. Within ggplot, I am using geom_area with red and blue and expect where they overlap should be purple. But instead, it's dark red. Playing with alpha and with different colors doesn't seem to solve the problem. Here's a very simple reproducible example R --arch x86_64 library(ggplot2) x-c(24,55,69,73) y-c(44,56,12,90) z-c(1,2,3,4) a-data.frame(pos=z, y=y, x=x) ex- ggplot(data=a, aes(pos)) + geom_area(aes(y = y),fill=navyblue, alpha = 0.7, position=identity) + geom_area(aes(y = x), fill= darkred, alpha = 0.7,position=identity ) + opts(panel.background = theme_rect(fill = white)) ex Likewise, with blue and yellow, I would expect overlap to be green. Are there any solutions to this that would allow color overlaps to lead to the expected color? Thank you. sessionInfo() R version 2.10.0 (2009-10-26) x86_64-apple-darwin9.8.0 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods [8] base other attached packages: [1] ggplot2_0.8.3 reshape_0.8.3 plyr_0.1.9proto_0.3-8 [[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] Interactively editing point labels in a graph
Hello On 2/3/10, trece por ciento el13porcie...@yahoo.com wrote: Dear experts, I would like to be able to interactively (if possible, with mouse and clik) edit point labels in graphs, Try playwith. Liviu particularly in multivariate graphs, such as the biplots you get after a correspondence analysis (with, for example, package ca), where labels tend to overlap. The graph aspect ratio is relevant (it needs to be mantained). And I'm working with Windows XP. In this kind of graphs points in the graph are identified with labels, generally long (see, for example: http://www.white-history.com/Greece_files/hlafreq.jpg), and sometimes -as in the example- it is good to group certain points within ellipses. Do you know if exists some package able to do this task? Thanks in advance, Hug __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#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] create an object in a loop (v4)
Hi everybody, I have just thought that it might help if I would provide a sample data set. I have attached it as a txt file (tab separated). Here is the modified code to fit this data set. library(WRS) file - read.table(file=file.choose(), header=T, sep=\t) seq.num- c(4,5)#column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction, } #I couldn't make it work with get() either Desired output (I named it manually): TO_POS_Asfc.median $M1 [1] 143.2065 180.0317 121.6397 175.0321 196.7545 208.3876 $M2 [1] 83.76985 190.26124 35.94771 158.67638 228.32178 247.06147 53.97887 [8] 218.60500 210.73514 167.37230 311.49512 $M3 [1] 316.37916 238.75643 277.44513 142.00038 242.58559 285.64139 61.01016 [8] 353.16336 150.75096 300.15989 298.4 74.33973 $P3 [1] 140.9876 207.7029 $P4 [1] 316.71972 120.76090 85.56545 135.87049 290.98684 160.52683 TO_POS_Smc.median $M1 [1] 6.411332 31.347971 5.649655 8.954671 8.279096 10.385299 $M2 [1] 9.358691 18.657771 3.033461 11.193338 10.385299 11.233078 2.417496 [8] 10.021019 10.100497 19.796975 19.459188 $M3 [1] 27.691922 13.895635 26.824272 17.909342 19.128024 21.730973 6.206010 [8] 24.214702 11.531125 13.617458 19.717496 9.305704 $P3 [1] 9.669985 18.392840 $P4 [1] 18.346478 10.504518 8.967917 4.291884 23.380168 9.014280 Thanks in advance Ivan Le 2/3/2010 10:22, Ivan Calandra a écrit : Hi! Looks like get() doesn't work. Here is what I do and what I get (still in the loop): names(get(paste(names(file)[3], name.num, sep=_)))- levels(factor(file[[3]])) Error in names(get(paste(names(file)[3], name.num, sep = _)))- levels(factor(file[[3]])) : could not find function get- print(names(get(paste(names(file)[3], name.num, sep=_ #4 iterations; I wanted to test this part NULL NULL NULL NULL Does anyone has an idea about it? Thanks Ivan Le 2/2/2010 19:38, Chris Campbell a écrit : On Tue, Feb 2, 2010 at 11:44, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Hi David, Thanks for your answer. But I don't really see how I can extend it with my real data. The thing is that I have more than 3 names and 1 value for each name. Moreover, each is different from one run to another. That is why I was trying with a modification of names(). Also to be noted is that I simplified the name in assign(); I actually have 2 other variables that will be pasted to create the name. Here is my code (I kept only what is important for that part): library(WRS) seq.num- seq(7,10,1)#column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction } Sounds like a job for 'get'. Try this (untested): names(get(paste(names(file)[3], name.num, sep=_))) Good luck Thanks in advance for your help. Regards, Ivan Le 2/1/2010 18:47, David Winsemius a écrit : On Feb 1, 2010, at 12:33 PM, Ivan Calandra wrote: I have a follow-up question: I use assign() to store some value in my paste()-created object as suggested: for (i in 1:3) { assign(paste(object, i, sep=), c(a, b, c)) } Then I would like to change the names of the elements of that object within the loop. Since it is all in a loop, I cannot give the name of the object manually by doing something like: names(object1)- c(tooth, bone, species). The only thing I can give to names() is paste(object, i, sep=), which doesn't work. Any idea of how to do it? for (i in paste(object, 1:3, sep=)) { + assign(i, c(tooth=a, bone=b, species=c) ) + } object1 toothbone species a b c Thanks in advance Ivan Le 2/1/2010 17:14, David Winsemius a écrit : Upon reading it yesterday, it appeared as it would have required some serious testing and there was no data on which to do any work. You were clearly not taking the time to isolate the problem and construct a dataset. But who knows? When you say What I want to do is. ... ,I would like the name of the list to be created in the loop too, maybe all you needed was to be pointed to was: ?assign But if that were the case, then you lost most of your audience along the way with a bunch of
Re: [R] color blending and transparency
On 02/03/2010 08:43 PM, bluecuttlefish wrote: I am using ggplot and posted this question at that helplist. It was suggested that I try a more general R-help list for a possible solution to this problem. Within ggplot, I am using geom_area with red and blue and expect where they overlap should be purple. But instead, it's dark red. Playing with alpha and with different colors doesn't seem to solve the problem. Here's a very simple reproducible example R --arch x86_64 library(ggplot2) x-c(24,55,69,73) y-c(44,56,12,90) z-c(1,2,3,4) a-data.frame(pos=z, y=y, x=x) ex- ggplot(data=a, aes(pos)) + geom_area(aes(y = y),fill=navyblue, alpha = 0.7, position=identity) + geom_area(aes(y = x), fill= darkred, alpha = 0.7,position=identity ) + opts(panel.background = theme_rect(fill = white)) ex Likewise, with blue and yellow, I would expect overlap to be green. Are there any solutions to this that would allow color overlaps to lead to the expected color? Hi bluecuttlefish, Think ink - should be easy. Only certain devices support transparency. Have you tried this on the pdf device? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] contour function: changing colour according to different levels
Hi everybody, I am using the contour function to draw isobares. And i would like to to bold contours for an interval of 500m and weak contour for an interval of 100m. Can someone help me with this? Thanks a lot Karine _ [[elided Hotmail spam]] [[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] contour function: changing colour according to different levels
karine heerah wrote: Hi everybody, I am using the contour function to draw isobares. And i would like to to bold contours for an interval of 500m and weak contour for an interval of 100m. Can someone help me with this? Thanks a lot Karine _ [[elided Hotmail spam]] [[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. Please read the posting guide and provide a small working example of your problem. My guess would be to look at the col= argument. cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~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.
[R] Boundary problem
Hello, I have to vectors high and low on a time scale as follows time - 1:5 low - c(1, 2, 3, 4, 5) high - c(5, 4, 3, 4, 4) Now I'm searching for an elegant solution to know if a data point in time is inside the boundaries but not only on the predefined time points but continuous (e.g. time=2.5). For this the boundary points should be interpolated linearly. InBoundaries(t=2, y=1) = FALSE (too low) InBoundaries(t=2, y=2) = TRUE (on lower boundary) InBoundaries(t=2.5, y=3) = TRUE (between interpolation lines) InBoundaries(t=2.5, y=3.5) = TRUE (on upper interpolation line InBoundaries(t=2.5, y=3.51) = FALSE (above upper interpolation line) Thanks in advance for your ideas. Kind regards Martin [[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] sqlUpdate RODBC
Update - The first problem is solved: sqlQuery(channel, create table TEST3 (NR NUMBER, NAME VARCHAR2(55),TAG DATE)) -- View this message in context: http://n4.nabble.com/sqlUpdate-RODBC-tp1460867p1460899.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading these datasets
Amy, It would help if you told us what you did, and what warnings you received. For instance, what happens with mydata - read.table(triazines.txt, sep=\t, header=TRUE) You probably also need to delete off those initial blank lines, or use skip=3 in the previous statement (or however many there actually are). Sarah 2010/2/3 Amy Hessen amy_4_5...@hotmail.com: Hi, I receive too many warnings when I try to read the attached datasets. Could you please tell me where the problem in them? Cheers, Amy -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading these datasets
On 02/03/2010 10:39 PM, Amy Hessen wrote: Hi, I receive too many warnings when I try to read the attached datasets. Could you please tell me where the problem in them? Hi Amy, triazines-read.table(triazines.txt,header=TRUE) pyrim-read.table(pyrim.txt,header=TRUE) Both work fine for me. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to change output 'csv' file
Dear R helpers After executing the R code, where the last few lines of the code are something like given below. ## Part of my R code n = 20 . final_output = data.frame(Numbers = numbers, ABC = data1, XYZ = data2, PQR = data3) write.csv(data.frame(Scenario = paste(Sc_, 1:n, sep = ), final_output'), 'result.csv', row.names = FALSE) ## End of code When I open the 'result.csv' file, my output is like Scenario Numbers ABC XYZ PQR Sc_11 22 18 6 Sc_22 24 16.5 11 SC_3 3 38 41 38 Sc_20 20 15 27.5 74 ## MY REQUIEMENT I wish to have output like given below. Scenario Numbers Names Values Sc_1 1 ABC 22 Sc_11 XYZ 18 Sc_1 1 PQR 6 Sc_22 ABC 24 Sc_22 XYZ 16.5 Sc_2 2 PQR 11 . Sc_20 20 ABC 15 Sc_20 20 XYZ 27.5 Sc_20 20 PQR 74 Please guide how this can be achieved? Regards and thanks in advance Amelia [[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] Boundary problem
On Feb 3, 2010, at 6:25 AM, Martin Kappler wrote: Hello, I have to vectors high and low on a time scale as follows time - 1:5 low - c(1, 2, 3, 4, 5) high - c(5, 4, 3, 4, 4) Now I'm searching for an elegant solution to know if a data point in time is inside the boundaries but not only on the predefined time points but continuous (e.g. time=2.5). For this the boundary points should be interpolated linearly. InBoundaries(t=2, y=1) = FALSE (too low) InBoundaries(t=2, y=2) = TRUE (on lower boundary) InBoundaries(t=2.5, y=3) = TRUE (between interpolation lines) InBoundaries(t=2.5, y=3.5) = TRUE (on upper interpolation line InBoundaries(t=2.5, y=3.51) = FALSE (above upper interpolation line) ?approxfun lowaprx - approxfun(low) hiaprx - approxfun(high) InBoundaries - function(t,y) y = lowaprx(t) y = hiaprx(t) InBoundaries(2,1) [1] FALSE InBoundaries(2,2) [1] TRUE InBoundaries(t=2.5, y=3) ; InBoundaries(t=2.5, y=3.5) [1] TRUE [1] TRUE InBoundaries(t=2.5, y=3.51) [1] FALSE -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] About Markov Random Filed
Hello!! Does there any packages can simulation data from Markov Random Field? Thanks much Ming Hung Chen [[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 change output 'csv' file
On Feb 3, 2010, at 7:09 AM, Amelia Livington wrote: Dear R helpers After executing the R code, where the last few lines of the code are something like given below. ## Part of my R code n = 20 . final_output = data.frame(Numbers = numbers, ABC = data1, XYZ = data2, PQR = data3) write.csv(data.frame(Scenario = paste(Sc_, 1:n, sep = ), final_output'), 'result.csv', row.names = FALSE) ## End of code When I open the 'result.csv' file, my output is like Scenario Numbers ABC XYZ PQR Sc_11 22 18 6 Sc_22 24 16.5 11 SC_3 3 38 41 38 Sc_2020 15 27.5 74 This is done for the first three lines of data provided, but should obviously be modified to accomadate different lengths of data. f2 - stack(final_output) #You can rename the columns to suit your needs; by default they are ind and values. f2$Numbers -rep(1:3,1) # should be rep(1:20, 3) in final solution f2$Scenario - paste(Sc_, f2$Numbers, sep=) f2 values ind Numbers Scenario 1 22.0 ABC 1 Sc_1 2 24.0 ABC 2 Sc_2 3 38.0 ABC 3 Sc_3 4 18.0 XYZ 1 Sc_1 5 16.5 XYZ 2 Sc_2 6 41.0 XYZ 3 Sc_3 76.0 PQR 1 Sc_1 8 11.0 PQR 2 Sc_2 9 38.0 PQR 3 Sc_3 f2 - f2[order(f2$Numbers), ] f2 values ind Numbers Scenario 1 22.0 ABC 1 Sc_1 4 18.0 XYZ 1 Sc_1 76.0 PQR 1 Sc_1 2 24.0 ABC 2 Sc_2 5 16.5 XYZ 2 Sc_2 8 11.0 PQR 2 Sc_2 3 38.0 ABC 3 Sc_3 6 41.0 XYZ 3 Sc_3 9 38.0 PQR 3 Sc_3 write.csv( f2[ , c(4,3,2,1) ], file='result.csv', row.names=FALSE) (Or write.csv( f2[ , c(Scenario,Numbers,ind,values) ], file='result.csv', row.names=FALSE) Scenario,Numbers,ind,values Sc_1,1,ABC,22 Sc_1,1,XYZ,18 Sc_1,1,PQR,6 Sc_2,2,ABC,24 Sc_2,2,XYZ,16.5 Sc_2,2,PQR,11 Sc_3,3,ABC,38 Sc_3,3,XYZ,41 Sc_3,3,PQR,38 You said to use write.csv which does put the commas in despite yuor example htat was comma-less. ## MY REQUIEMENT I wish to have output like given below. Scenario Numbers Names Values Sc_11 ABC 22 Sc_11 XYZ 18 Sc_11 PQR 6 Sc_22 ABC 24 Sc_22 XYZ 16.5 Sc_22 PQR 11 . Sc_20 20 ABC 15 Sc_20 20 XYZ27.5 Sc_20 20 PQR 74 Please guide how this can be achieved? Regards and thanks in advance Amelia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] About Markov Random Filed
On Feb 3, 2010, at 7:50 AM, 陳明宏 wrote: Hello!! Does there any packages can simulation data from Markov Random Field? Ming Hung Chen, meet the searching function. The answer appeared in the 8 hits. You should search first, post second. RSiteSearch(Markov Random Field) -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] hvcluster() with distance method from vegdist(), package = vegan
Kay Cichini Kay.Cichini at uibk.ac.at writes: hello, i'd be happy if someone could provide help with the following problem: i have a dist.matrix that comes from vegdist() function of the vegan package. the used method = horn is not accepted as argument in hvcluster(...,dist.method=...). is there a way to incorporate the method horn in hvcluster()? (This concerns function pvclust in the pvclust package, like probably was intended in the message.) No, there is no way of incorporating vegan::vegdist() methods in pvclust::pvclust(). At least not according to the documentation of pvclust which clearly says that the first argument is a data structure (not a 'dist' object), and dissimilarities are found either with the internal pvclust methods or using dist() function of the base R. Neither vegan function nor input of dissimiliraties are allowed in pvclust(). You must edit pvclust() to make it work with your choice of dissimilarity methods and other dissimilarity functions. Best wishes, Jari Oksanen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 change output 'csv' file
Hi: You can also use the melt() function in the reshape package: using a small snippet of your data as a test case, library(reshape) df Scenario Numbers ABC XYZ PQR 1 Sc_1 1 22 18.0 6 2 Sc_2 2 24 16.5 11 melt(df, id = c('Scenario', 'Numbers')) Scenario Numbers variable value 1 Sc_1 1 ABC 22.0 2 Sc_2 2 ABC 24.0 3 Sc_1 1 XYZ 18.0 4 Sc_2 2 XYZ 16.5 5 Sc_1 1 PQR 6.0 6 Sc_2 2 PQR 11.0 Change the name of variable to Names and you should be set. HTH, Dennis On Wed, Feb 3, 2010 at 4:09 AM, Amelia Livington amelia_living...@yahoo.com wrote: Dear R helpers After executing the R code, where the last few lines of the code are something like given below. ## Part of my R code n = 20 . final_output = data.frame(Numbers = numbers, ABC = data1, XYZ = data2, PQR = data3) write.csv(data.frame(Scenario = paste(Sc_, 1:n, sep = ), final_output'), 'result.csv', row.names = FALSE) ## End of code When I open the 'result.csv' file, my output is like Scenario Numbers ABC XYZ PQR Sc_11 22 18 6 Sc_22 24 16.5 11 SC_3 3 38 41 38 Sc_2020 15 27.5 74 ## MY REQUIEMENT I wish to have output like given below. Scenario Numbers Names Values Sc_11 ABC 22 Sc_11 XYZ 18 Sc_11 PQR 6 Sc_22 ABC 24 Sc_22 XYZ 16.5 Sc_22 PQR 11 . Sc_20 20 ABC 15 Sc_20 20 XYZ27.5 Sc_20 20 PQR 74 Please guide how this can be achieved? Regards and thanks in advance Amelia [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] create an object in a loop (v4)
For adding the 'names', put the data in a temporary first: for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] temp - fac2list(file[,k], file[3]) names(temp) - levels(factor(file[[3]])) assign(paste(names(file)[3], name.num, sep=_), temp) } #I couldn't make it work with get() either On Wed, Feb 3, 2010 at 5:09 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Hi everybody, I have just thought that it might help if I would provide a sample data set. I have attached it as a txt file (tab separated). Here is the modified code to fit this data set. library(WRS) file - read.table(file=file.choose(), header=T, sep=\t) seq.num- c(4,5) #column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction, } #I couldn't make it work with get() either Desired output (I named it manually): TO_POS_Asfc.median $M1 [1] 143.2065 180.0317 121.6397 175.0321 196.7545 208.3876 $M2 [1] 83.76985 190.26124 35.94771 158.67638 228.32178 247.06147 53.97887 [8] 218.60500 210.73514 167.37230 311.49512 $M3 [1] 316.37916 238.75643 277.44513 142.00038 242.58559 285.64139 61.01016 [8] 353.16336 150.75096 300.15989 298.4 74.33973 $P3 [1] 140.9876 207.7029 $P4 [1] 316.71972 120.76090 85.56545 135.87049 290.98684 160.52683 TO_POS_Smc.median $M1 [1] 6.411332 31.347971 5.649655 8.954671 8.279096 10.385299 $M2 [1] 9.358691 18.657771 3.033461 11.193338 10.385299 11.233078 2.417496 [8] 10.021019 10.100497 19.796975 19.459188 $M3 [1] 27.691922 13.895635 26.824272 17.909342 19.128024 21.730973 6.206010 [8] 24.214702 11.531125 13.617458 19.717496 9.305704 $P3 [1] 9.669985 18.392840 $P4 [1] 18.346478 10.504518 8.967917 4.291884 23.380168 9.014280 Thanks in advance Ivan Le 2/3/2010 10:22, Ivan Calandra a écrit : Hi! Looks like get() doesn't work. Here is what I do and what I get (still in the loop): names(get(paste(names(file)[3], name.num, sep=_)))- levels(factor(file[[3]])) Error in names(get(paste(names(file)[3], name.num, sep = _)))- levels(factor(file[[3]])) : could not find function get- print(names(get(paste(names(file)[3], name.num, sep=_ #4 iterations; I wanted to test this part NULL NULL NULL NULL Does anyone has an idea about it? Thanks Ivan Le 2/2/2010 19:38, Chris Campbell a écrit : On Tue, Feb 2, 2010 at 11:44, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Hi David, Thanks for your answer. But I don't really see how I can extend it with my real data. The thing is that I have more than 3 names and 1 value for each name. Moreover, each is different from one run to another. That is why I was trying with a modification of names(). Also to be noted is that I simplified the name in assign(); I actually have 2 other variables that will be pasted to create the name. Here is my code (I kept only what is important for that part): library(WRS) seq.num- seq(7,10,1) #column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction } Sounds like a job for 'get'. Try this (untested): names(get(paste(names(file)[3], name.num, sep=_))) Good luck Thanks in advance for your help. Regards, Ivan Le 2/1/2010 18:47, David Winsemius a écrit : On Feb 1, 2010, at 12:33 PM, Ivan Calandra wrote: I have a follow-up question: I use assign() to store some value in my paste()-created object as suggested: for (i in 1:3) { assign(paste(object, i, sep=), c(a, b, c)) } Then I would like to change the names of the elements of that object within the loop. Since it is all in a loop, I cannot give the name of the object manually by doing something like: names(object1)- c(tooth, bone, species). The only thing I can give to names() is paste(object, i, sep=), which doesn't work. Any idea of how to do it? for (i in paste(object, 1:3, sep=)) { + assign(i, c(tooth=a, bone=b, species=c) ) + } object1 tooth bone species a b c Thanks in advance Ivan Le 2/1/2010 17:14, David Winsemius a écrit : Upon reading it yesterday, it appeared as it
[R] to convert a character string in time
hi, I have my data time expressed in character string exple 5:20 (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: balise07$Hour - as.POSXIct(balise07$Hour) but it didn't work. Do you know why? Do you know how i can convert my string character in a real time? Thanks Karine HEERAH Master 2 mention océanographie et environnements marins, parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 _ [[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] create an object in a loop (v4)
Great, thanks a lot! But I feel stupid... I didn't think about that easy solution. I wanted to change the names after... Anyway, it now works! Regards, Ivan Le 2/3/2010 14:22, jim holtman a écrit : For adding the 'names', put the data in a temporary first: for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] temp- fac2list(file[,k], file[3]) names(temp)- levels(factor(file[[3]])) assign(paste(names(file)[3], name.num, sep=_), temp) } #I couldn't make it work with get() either On Wed, Feb 3, 2010 at 5:09 AM, Ivan Calandra ivan.calan...@uni-hamburg.de wrote: Hi everybody, I have just thought that it might help if I would provide a sample data set. I have attached it as a txt file (tab separated). Here is the modified code to fit this data set. library(WRS) file- read.table(file=file.choose(), header=T, sep=\t) seq.num- c(4,5)#column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction, } #I couldn't make it work with get() either Desired output (I named it manually): TO_POS_Asfc.median $M1 [1] 143.2065 180.0317 121.6397 175.0321 196.7545 208.3876 $M2 [1] 83.76985 190.26124 35.94771 158.67638 228.32178 247.06147 53.97887 [8] 218.60500 210.73514 167.37230 311.49512 $M3 [1] 316.37916 238.75643 277.44513 142.00038 242.58559 285.64139 61.01016 [8] 353.16336 150.75096 300.15989 298.4 74.33973 $P3 [1] 140.9876 207.7029 $P4 [1] 316.71972 120.76090 85.56545 135.87049 290.98684 160.52683 TO_POS_Smc.median $M1 [1] 6.411332 31.347971 5.649655 8.954671 8.279096 10.385299 $M2 [1] 9.358691 18.657771 3.033461 11.193338 10.385299 11.233078 2.417496 [8] 10.021019 10.100497 19.796975 19.459188 $M3 [1] 27.691922 13.895635 26.824272 17.909342 19.128024 21.730973 6.206010 [8] 24.214702 11.531125 13.617458 19.717496 9.305704 $P3 [1] 9.669985 18.392840 $P4 [1] 18.346478 10.504518 8.967917 4.291884 23.380168 9.014280 Thanks in advance Ivan Le 2/3/2010 10:22, Ivan Calandra a écrit : Hi! Looks like get() doesn't work. Here is what I do and what I get (still in the loop): names(get(paste(names(file)[3], name.num, sep=_)))- levels(factor(file[[3]])) Error in names(get(paste(names(file)[3], name.num, sep = _)))- levels(factor(file[[3]])) : could not find function get- print(names(get(paste(names(file)[3], name.num, sep=_ #4 iterations; I wanted to test this part NULL NULL NULL NULL Does anyone has an idea about it? Thanks Ivan Le 2/2/2010 19:38, Chris Campbell a écrit : On Tue, Feb 2, 2010 at 11:44, Ivan Calandra ivan.calan...@uni-hamburg.dewrote: Hi David, Thanks for your answer. But I don't really see how I can extend it with my real data. The thing is that I have more than 3 names and 1 value for each name. Moreover, each is different from one run to another. That is why I was trying with a modification of names(). Also to be noted is that I simplified the name in assign(); I actually have 2 other variables that will be pasted to create the name. Here is my code (I kept only what is important for that part): library(WRS) seq.num- seq(7,10,1)#column (variable) indexes to be used as numerical variables # fac2list() separates the data from file[,k] into groups from levels in file[3] and store into list mode. for(i in 1:length(seq.num)) { k- seq.num[i] name.num- names(file)[k] assign(paste(names(file)[3], name.num, sep=_), fac2list(file[,k], file[3])) names(paste(names(file)[3], name.num, sep=_))- levels(factor(file[[3]])) #that line doesn't work, but I would like something in this direction } Sounds like a job for 'get'. Try this (untested): names(get(paste(names(file)[3], name.num, sep=_))) Good luck Thanks in advance for your help. Regards, Ivan Le 2/1/2010 18:47, David Winsemius a écrit : On Feb 1, 2010, at 12:33 PM, Ivan Calandra wrote: I have a follow-up question: I use assign() to store some value in my paste()-created object as suggested: for (i in 1:3) { assign(paste(object, i, sep=), c(a, b, c)) } Then I would like to change the names of the elements of that object within the loop. Since it is all in a loop, I cannot give the name of the object manually by doing something like: names(object1)- c(tooth, bone, species). The only thing I can give to names() is paste(object, i, sep=), which doesn't work. Any idea of how to do it? for (i
[R] FW: to convert a character string in time
hi, I have my data time expressed in character string exple 5:20 (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: balise07$Hour - as.POSIXct(balise07$Hour) but it didn't work. Do you know why? Do you know how i can convert my string character in a real time? Thanks Karine HEERAH Master 2 mention océanographie et environnements marins, parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 _ [[alternative HTML version deleted]] _ [[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] pvclust() with distance method from vegdist(), package = vegan
thank you for the information. would be great to have the possibility to check significance of clusters coming from other distance-measures, too - but i'll be satisified with what pvclust() can do. yours, kay -- View this message in context: http://n4.nabble.com/hvcluster-with-distance-method-from-vegdist-package-vegan-tp1459859p1461160.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] color blending and transparency
Hi, Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two layers the overlap region is either purple or dark red. I have no idea why. png(testingOrder.png) plot.new() # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) dev.off() Best, baptiste On 3 February 2010 11:15, Jim Lemon j...@bitwrit.com.au wrote: On 02/03/2010 08:43 PM, bluecuttlefish wrote: I am using ggplot and posted this question at that helplist. It was suggested that I try a more general R-help list for a possible solution to this problem. Within ggplot, I am using geom_area with red and blue and expect where they overlap should be purple. But instead, it's dark red. Playing with alpha and with different colors doesn't seem to solve the problem. Here's a very simple reproducible example R --arch x86_64 library(ggplot2) x-c(24,55,69,73) y-c(44,56,12,90) z-c(1,2,3,4) a-data.frame(pos=z, y=y, x=x) ex- ggplot(data=a, aes(pos)) + geom_area(aes(y = y),fill=navyblue, alpha = 0.7, position=identity) + geom_area(aes(y = x), fill= darkred, alpha = 0.7,position=identity ) + opts(panel.background = theme_rect(fill = white)) ex Likewise, with blue and yellow, I would expect overlap to be green. Are there any solutions to this that would allow color overlaps to lead to the expected color? Hi bluecuttlefish, Think ink - should be easy. Only certain devices support transparency. Have you tried this on the pdf device? Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] color blending and transparency
baptiste auguie baptiste.auguie at googlemail.com writes: Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two layers the overlap region is either purple or dark red. I have no idea why. png(testingOrder.png) plot.new() # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) dev.off() I would expect overlaid transparencies to act like filters and multiply, producing so-called subtractive color mixing, so blue and yellow gives green. Interestingly, however, overlaying filters is not necessarily a commutative operation, since a transparent filter can yield an additive component (through scatter, for example) though I suspect that the non-commutativity comes about in R because these rules apply to physical lights, filters and surfaces and in R, it is some uncalibrated combination of frame buffer values that is being used. Best, baptiste Ken -- Ken Knoblauch Inserm U846 Stem-cell and Brain Research Institute Department of Integrative Neurosciences 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr/members/kenneth-knoblauch.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] group factor levels
Dear list, I cannot find an elegant solution to this problem. I have a factor f containing several levels (5) and I wish to create a new factor of the same length with fewer levels (2). This new factor should therefore group together some levels of the original data. Ideally this grouping would be at random, i.e I would not group together the first 2 levels of f, then the following 3, etc. Below is a minimal example (my real problem has more levels, otherwise I would do the operation manually...) f - factor(rep(sample(letters[1:5], 20, repl=TRUE), each=10)) # permute the levels in random order disorder - sample(levels(f), length(levels(f))) # new levels matching the old ones new.lev - rep(LETTERS[1:2], length=length(disorder)) # associate old levels to new ones groups - split(disorder, new.lev) # test each element of f for its new category test - lapply(groups, function(g) f %in% g) # f2 is the new factor, initialized with f f2 - as.character(f) # recursively modify f2 sapply(seq_along(test), function(ii) f2[test[[ii]]] - names(test[ii])) # make it a factor f2 - factor(f2) Any suggestions are very welcome, I must have missed something more obvious! Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Positioning the y label in scatterplot3d
Is there a way of repositioning the y label in scatterplot3d so that it is parallel with the y axis? Many thanks Richard __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] to convert a character string in time
Try this: as.POSIXct(5:30, format=%H:%M) [1] 2010-02-03 05:30:00 EST On Wed, Feb 3, 2010 at 8:27 AM, karine heerah karine.hee...@hotmail.fr wrote: hi, I have my data time expressed in character string exple 5:20 (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: balise07$Hour - as.POSXIct(balise07$Hour) but it didn't work. Do you know why? Do you know how i can convert my string character in a real time? Thanks Karine HEERAH Master 2 mention océanographie et environnements marins, parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 _ [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: group factor levels
Hi r-help-boun...@r-project.org napsal dne 03.02.2010 14:52:02: Dear list, I cannot find an elegant solution to this problem. I have a factor f containing several levels (5) and I wish to create a new factor of the same length with fewer levels (2). This new factor should therefore group together some levels of the original data. Ideally this grouping would be at random, i.e I would not group together the first 2 levels of f, then the following 3, etc. Below is a minimal example (my real problem has more levels, otherwise I would do the operation manually...) f - factor(rep(sample(letters[1:5], 20, repl=TRUE), each=10)) # permute the levels in random order disorder - sample(levels(f), length(levels(f))) # new levels matching the old ones new.lev - rep(LETTERS[1:2], length=length(disorder)) # associate old levels to new ones groups - split(disorder, new.lev) # test each element of f for its new category test - lapply(groups, function(g) f %in% g) # f2 is the new factor, initialized with f f2 - as.character(f) # recursively modify f2 sapply(seq_along(test), function(ii) f2[test[[ii]]] - names(test[ii])) # make it a factor f2 - factor(f2) Any suggestions are very welcome, I must have missed something more obvious! # order levels f.t-factor(f, levels=disorder) # change levels levels(f.t) - new.lev all.equal(f.t,f2) [1] TRUE Regards Petr Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Positioning the y label in scatterplot3d
On 03.02.2010 15:02, RICHARD PITMAN wrote: Is there a way of repositioning the y label in scatterplot3d so that it is parallel with the y axis? Short answer: No. Long answer: You could hack the code and add some angle argument to the text() calls that label the y axis, but it is hard to guess the correct angle that highly depends on the current projection. If you find a way how to do that appropriately (other than rewriting scatterplot3d to use grid), I am very interested. Best, Uwe Ligges Many thanks Richard __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Positioning the y label in scatterplot3d
Thanks Uwe, much appreciated Regards Richard --- On Wed, 3/2/10, Uwe Ligges lig...@statistik.tu-dortmund.de wrote: From: Uwe Ligges lig...@statistik.tu-dortmund.de Subject: Re: [R] Positioning the y label in scatterplot3d To: RICHARD PITMAN richard.pitm...@btopenworld.com Cc: r-help@r-project.org Date: Wednesday, 3 February, 2010, 14:07 On 03.02.2010 15:02, RICHARD PITMAN wrote: Is there a way of repositioning the y label in scatterplot3d so that it is parallel with the y axis? Short answer: No. Long answer: You could hack the code and add some angle argument to the text() calls that label the y axis, but it is hard to guess the correct angle that highly depends on the current projection. If you find a way how to do that appropriately (other than rewriting scatterplot3d to use grid), I am very interested. Best, Uwe Ligges Many thanks Richard __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] color blending and transparency
On 03/02/2010 8:50 AM, Ken Knoblauch wrote: baptiste auguie baptiste.auguie at googlemail.com writes: Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two layers the overlap region is either purple or dark red. I have no idea why. png(testingOrder.png) plot.new() # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) I think it's a fairly simple calculation. In the first example: We are writing red (1,0,0) at alpha=0.5 onto white (1,1,1), so we get a mixture of half existing and half new, i.e. (1,0.5,0.5). Then we write blue (0,0,1) at alpha 0.5 onto that, giving (0.5, 0.25, 0.75). In the second pair, the first write yields (0.5,0.5,1), and the second yields (0.75, 0.25, 0.5). So this is like mixing paints: you don't get the same colour if you mix equal parts red and white, then take equal parts of that mixture with blue, as you get if you put the blue in first. You've got less red in the first mixture than in the second. You would get the same color in both mixtures if you didn't mix the white in: # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=1)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=1)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) Duncan Murdoch dev.off() I would expect overlaid transparencies to act like filters and multiply, producing so-called subtractive color mixing, so blue and yellow gives green. Interestingly, however, overlaying filters is not necessarily a commutative operation, since a transparent filter can yield an additive component (through scatter, for example) though I suspect that the non-commutativity comes about in R because these rules apply to physical lights, filters and surfaces and in R, it is some uncalibrated combination of frame buffer values that is being used. Best, baptiste Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] group factor levels
As always the question seems silly after you've learned the answer! Thanks a lot, baptiste On 3 February 2010 15:06, Petr PIKAL petr.pi...@precheza.cz wrote: # order levels f.t-factor(f, levels=disorder) # change levels levels(f.t) - new.lev all.equal(f.t,f2) [1] TRUE Regards Petr Best regards, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Package plm heterogenous slopes
Dear r-helpers, I am working with plm package. I am trying to fit a fixed effects (or a 'within') model of the form y_it = a_i + b_i*t + e_it, i.e. a model with an individual-specific intercept and an individual- specific slope. Does plm support this directly? Thanks in advance! Otto Kassi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] typo in contrast package's vignettes
On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c' \lambda$, right? If I'm correct, could somebody notice the author to fix it? Do it yourself. What do you mean? I have two questions. I assume you are answering my second questions. Would you please make sure that your reply is complete to avoid any confusions? If you think there is an error, then you should contact the package maintainer. Simple (and complete) as that. If you don't want to check, then don't post with nonsense reply. Its the advice that you could and _should_ have read in the Posting Guide. I'm not clear how my original post violate the posting guide http://www.r-project.org/posting-guide.html. Would you please be specific which item I violated? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] to convert a character string in time
Try this (and see R News 4/1): library(chron) tt - times(paste(5:20, 00, sep = :)); tt [1] 05:20:00 tt + 12/24 # add 12 hours [1] 17:20:00 On Wed, Feb 3, 2010 at 8:27 AM, karine heerah karine.hee...@hotmail.fr wrote: hi, I have my data time expressed in character string exple 5:20 (hour:min) and i want to convert these in times recognized by R. I have tried the POSIXct function: balise07$Hour - as.POSXIct(balise07$Hour) but it didn't work. Do you know why? Do you know how i can convert my string character in a real time? Thanks Karine HEERAH Master 2 mention océanographie et environnements marins, parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 _ [[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] color blending and transparency
That makes perfect sense, thank you, except that I'm not sure where the white comes from when I set the background to transparent? png(testingOrder.png, bg = transparent) plot.new() par(bg=transparent) rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) dev.off() Still produces two different overlap colours, although I *think* only two colours are involved. What I have I missed here? Thanks, baptiste On 3 February 2010 15:17, Duncan Murdoch murd...@stats.uwo.ca wrote: On 03/02/2010 8:50 AM, Ken Knoblauch wrote: baptiste auguie baptiste.auguie at googlemail.com writes: Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two layers the overlap region is either purple or dark red. I have no idea why. png(testingOrder.png) plot.new() # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) I think it's a fairly simple calculation. In the first example: We are writing red (1,0,0) at alpha=0.5 onto white (1,1,1), so we get a mixture of half existing and half new, i.e. (1,0.5,0.5). Then we write blue (0,0,1) at alpha 0.5 onto that, giving (0.5, 0.25, 0.75). In the second pair, the first write yields (0.5,0.5,1), and the second yields (0.75, 0.25, 0.5). So this is like mixing paints: you don't get the same colour if you mix equal parts red and white, then take equal parts of that mixture with blue, as you get if you put the blue in first. You've got less red in the first mixture than in the second. You would get the same color in both mixtures if you didn't mix the white in: # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=1)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=1)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) Duncan Murdoch dev.off() I would expect overlaid transparencies to act like filters and multiply, producing so-called subtractive color mixing, so blue and yellow gives green. Interestingly, however, overlaying filters is not necessarily a commutative operation, since a transparent filter can yield an additive component (through scatter, for example) though I suspect that the non-commutativity comes about in R because these rules apply to physical lights, filters and surfaces and in R, it is some uncalibrated combination of frame buffer values that is being used. Best, baptiste Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] typo in contrast package's vignettes
On Feb 3, 2010, at 9:28 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c' \lambda$, right? If I'm correct, could somebody notice the author to fix it? Do it yourself. What do you mean? I have two questions. I assume you are answering my second questions. Would you please make sure that your reply is complete to avoid any confusions? If you think there is an error, then you should contact the package maintainer. Simple (and complete) as that. If you don't want to check, then don't post with nonsense reply. Its the advice that you could and _should_ have read in the Posting Guide. I'm not clear how my original post violate the posting guide http://www.r-project.org/posting-guide.html. Would you please be specific which item I violated? Your use of violated, not mine. For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R), ask questions on R-help. If the question relates to a contributed package , e.g., one downloaded from CRAN, try contacting the package maintainer first. Have you tried contacting the contrast package maintainer? -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error with R CMD check - Packages required but not available:
On 02.02.2010 22:52, Reena Bansal wrote: Apologies in advance if this is not the right email to post this question. I successfully created my first R package myPackage1. Now I want to create another R package myPackage2 which requires functions from myPackage1. However when I try R CMD check myPackage2 I get the following error Have you set the environment variable R_LIBS to include the library which myPackage1 has been installed into previously? Best, Uwe Ligges * checking for working pdflatex ... OK * using log directory '.../myPackage/myPackage2.Rcheck' * using R version 2.9.2 (2009-08-24) * using session charset: UTF-8 * checking for file 'myPackage2/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'myPackage2' version '1.0' * checking package dependencies ... ERROR Packages required but not available: myPackage1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to read this data file into R?
That's strange because I was able to read the file into R just fine --- On Tue, 2/2/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] how to read this data file into R? To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-help@r-project.org, song song rprojecth...@gmail.com Date: Tuesday, February 2, 2010, 3:40 PM On Feb 2, 2010, at 6:31 PM, Felipe Carrillo wrote: Convert the file into a csv file( myfile.csv), delete some of the unwanted rows before importing into R. Save the file on your working directory and then import into R: x - read.csv(myfile.csv) # Change column names names(x) - LETTERS[1:ncol(x)];x The problem with that solution is that there are an irregular number of numbers per row ranging from 8 to 6. You could read in as text with readLines but then need to extract by 25 lines at a time and then cbind the segments. Doable mind you, but I suspect faster with a spreadsheet intermediate solution. The real solution is to grab the miscreant sender by the throat , er, tactfully discuss with your valued customer ,,, and shake out a machine readable form that has all of one row in a row. -- David. Change your column names to whatever you want Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Tue, 2/2/10, song song rprojecth...@gmail.com wrote: From: song song rprojecth...@gmail.com Subject: [R] how to read this data file into R? To: r-help@r-project.org Date: Tuesday, February 2, 2010, 2:55 PM [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 2.010061 -5.223624 2.010061 2.010061 1.463336 1.463336 2.010061 2.010061 [2,] 2.057502 -5.101445 2.057502 2.057502 2.057502 2.057502 2.057502 2.057502 [3,] 2.011081 -5.227745 2.011081 2.011081 2.011081 2.011081 2.011081 2.011081 [4,] 2.031695 -5.147776 2.031695 2.031695 2.031695 2.031695 2.031695 2.031695 [5,] 1.982144 -5.219977 2.578551 1.982144 1.982144 1.982144 1.982144 1.982144 [6,] 1.997830 -5.197152 1.997830 1.997830 1.997830 1.997830 1.229965 1.997830 [7,] 1.987102 -5.202288 1.987102 1.987102 1.987102 1.987102 1.987102 2.045108 [8,] 2.004351 -5.263740 2.004351 2.004351 2.004351 2.004351 2.004351 2.004351 [9,] 1.860640 -5.281771 1.947604 1.947604 1.947604 1.947604 1.947604 1.947604 [10,] 2.034417 -5.268606 1.917726 1.917726 1.917726 1.917726 1.917726 1.917726 [11,] 1.892761 -5.254092 1.892761 1.892761 1.892761 1.892761 1.892761 1.892761 [12,] 1.878266 -4.725234 1.878266 1.878266 2.265870 1.878266 1.878266 1.878266 [13,] 1.941847 -5.293714 1.941847 1.941847 1.941847 2.212040 1.941847 1.941847 [14,] 3.280856 -5.295412 1.891672 1.891672 1.891672 1.891672 2.295541 1.891672 [15,] 1.833538 -5.381407 2.417865 1.833538 1.833538 1.833538 1.833538 1.833538 [16,] 1.813212 -5.256472 1.813212 2.337103 1.813212 1.813212 1.813212 1.813212 [17,] 1.763356 -5.262836 1.763356 2.538904 3.202743 1.763356 1.763356 1.763356 [18,] 2.71 -5.269976 1.824456 1.824456 1.824456 1.824456 1.824456 1.824456 [19,] 1.868374 -5.237574 1.868374 1.868374 1.868374 1.868374 1.868374 1.868374 [20,] 1.879976 -5.195960 1.879976 1.879976 2.400419 1.879976 1.879976 1.879976 [21,] 1.897184 -5.195960 1.897184 1.897184 1.897184 1.897184 1.897184 1.897184 [22,] 1.946035 -5.195960 1.946035 1.946035 1.946035 1.946035 1.946035 1.946035 [23,] 1.531107 -5.195960 2.005964 2.005964 2.005964 2.005964 1.012178 2.005964 [24,] 1.966488 -5.195960 1.966488 3.300449 1.966488 1.966488 1.966488 1.966488 [25,] 1.922473 -5.132915 1.922473 1.922473 1.922473 1.922473 1.327156 1.922473 [,9] [,10] [,11] [,12] [,13] [,14] [,15] [1,] 2.0100609 -5.223624 2.0100609 2.01006088 2.0100609 2.010061 2.0100609 [2,] 2.0575018 -5.217940 2.0575018 2.05750183 2.0575018 2.057502 2.0575018 [3,] 2.0110810 -5.227745 2.0110810 1.25251992 1.1365329 2.011081 2.0110810 [4,] 2.0316951 -5.147776 2.0316951 0.53524458 2.0316951 2.031695 2.0316951 [5,] 1.9821437 -5.219977 1.9821437 1.98214375 1.9821437 1.982144 1.9821437 [6,] 1.9978302 -5.197152 1.9978302 1.99783017 1.9978302 1.997830 1.9978302 [7,] 1.4779031 -5.202288 1.9871021 1.98710207 1.9871021 1.477903 1.9871021 [8,] 2.0043512 -5.263740 2.0043512 2.00435118 2.0043512 2.004351 2.0043512 [9,] 1.9476036 -5.281771 1.9476036 1.86063972 1.9476036 1.947604 1.9476036 [10,] 2.0344169 -5.268606 2.0344169 1.91772554 1.9177255 2.034417 1.9177255 [11,] 1.8927610 -5.254092 2.2300986 1.89276104 1.8927610 1.892761 1.8927610 [12,] 2.2658697 -5.279645 1.8782663 1.87826632 0.9758728 1.878266 1.8782663 [13,]
[R] diagnostic plots
Dear all, does anybody ever encountered the problem with diagnostic plots? x-rnorm(100) y-rnorm(100) plot(lm(x~y)) It gives the following message Waiting to confirm page change... and nothing happens. 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] What are Type II or III contrast? (contrast() in contrast package)
On Wed, Feb 3, 2010 at 2:12 AM, Emmanuel Charpentier charp...@bacbuc.dyndns.org wrote: Le mercredi 03 février 2010 à 00:01 -0500, David Winsemius a écrit : On Feb 2, 2010, at 11:38 PM, Peng Yu wrote: ?contrast in the contrast package gives me the following description. However, I have no idea what Type II and III contrasts are. Could somebody explain it to me? And what does 'type' mean here? *‘type’*: set ‘type=average’ to average the individual contrasts (e.g., to obtain a Type II or III contrast) In no particular order: http://courses.washington.edu/b570/handouts/type3ss.pdf http://core.ecu.edu/psyc/wuenschk/SAS/SS1234.doc http://n4.nabble.com/a-kinder-view-of-Type-III-SS-td847282.html Don't expect any follow-up questions to be answered or further citations offered. This is really more in the realm of statistics education than an R specific question. Nonwhistanding David Winsemius' closing remark, I'd like to add something that should be requested reading (and maybe hinted at in lm()'s help page) : http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf (BTW, despite is age, MASS *is* requested reading, and Bill Venables' exegeses should be part of it). Do you by any means indicate that MASS describes Type I, II, III, IV contrast? Although MASS describes contrasts, but I don't think it describes Type I, II, III, IV contrast. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plm package index
Dear Matt, yes you have. 'plm' doesn't support multi-column time indices, but it should happily make do with any *single* time index whose order can be recognized by R, such as, e.g., a lexicographic ordering. So you will probably want to paste your indices along these lines: year - rep(2000:2001,times=c(4,4)) year [1] 2000 2000 2000 2000 2001 2001 2001 2001 quarter - rep(1:4,times=2) quarter [1] 1 2 3 4 1 2 3 4 myind - paste(year, quarter, sep=q) myind [1] 2000q1 2000q2 2000q3 2000q4 2001q1 2001q2 2001q3 2001q4 order(myind) [1] 1 2 3 4 5 6 7 8 (of course you must be careful with the double digits in case of months and so on). As all 'plm' uses is standard R ordering, please refer to the general documentation of the R system for any issues. Best wishes, Giovanni - original message - Message: 182 Date: Wed, 3 Feb 2010 10:37:13 +0100 From: Bunny, lautloscrew.com bu...@lautloscrew.com To: r-help@r-project.org Subject: [R] plm package index Message-ID: 9b6a22f4-5dd0-4fcd-9a6f-aee1e2108...@lautloscrew.com Content-Type: text/plain Dear all, i just wonder if there´s a way to use a two column time index field in plm package. the manual says the following concerning data indexing: a character vector of length two containing the names of the individual and the time index, What would y´all do with a quarterly dataset that contains one column for the period and one for the year. Do I have to convert it to one single date field first ? thx in advance matt [[alternative HTML version deleted]] - end original message --- Giovanni Millo Research Dept., Assicurazioni Generali SpA Via Machiavelli 4, 34132 Trieste (Italy) tel. +39 040 671184 fax +39 040 671160 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] What are Type II or III contrast? (contrast() in contrast package)
Thank you. I was already convinced of the value of MASS (drop a hat and I'll tell you my other list of musts for a stats library) but I didn't know about the Exegeses. On Wed, Feb 3, 2010 at 3:12 AM, Emmanuel Charpentier charp...@bacbuc.dyndns.org wrote: Le mercredi 03 février 2010 à 00:01 -0500, David Winsemius a écrit : On Feb 2, 2010, at 11:38 PM, Peng Yu wrote: ?contrast in the contrast package gives me the following description. However, I have no idea what Type II and III contrasts are. Could somebody explain it to me? And what does 'type' mean here? *‘type’*: set ‘type=average’ to average the individual contrasts (e.g., to obtain a Type II or III contrast) In no particular order: http://courses.washington.edu/b570/handouts/type3ss.pdf http://core.ecu.edu/psyc/wuenschk/SAS/SS1234.doc http://n4.nabble.com/a-kinder-view-of-Type-III-SS-td847282.html Don't expect any follow-up questions to be answered or further citations offered. This is really more in the realm of statistics education than an R specific question. Nonwhistanding David Winsemius' closing remark, I'd like to add something that should be requested reading (and maybe hinted at in lm()'s help page) : http://www.stats.ox.ac.uk/pub/MASS3/Exegeses.pdf (BTW, despite is age, MASS *is* requested reading, and Bill Venables' exegeses should be part of it). HTH, -- Emmanuel Charpentier, DDS, MsC :-) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] strange behaviour: recognition of decimal numbers by 'which'
Concise and perfect answer. Thanks! I'm surprised I never came across this issue before (4 years playing with R). Jose Quoting Erik Iverson er...@ccbr.umn.edu: FAQ 7.31 j.delashe...@ed.ac.uk wrote: It is a strange behaviour in that I did not expect it... but I am sure there is a simple explanation for it and it'll have to do with the way numbers are stored in R, but it's caught me by surprise and I don't find it obvious. Here's a simplified example reproducing the behaviour I encountered: I create an empty vector, and I fill it with a sequence of numbers: 0, 0.005, 0.01, 0.015, 0.02, etc... until 0.1. (In my real code this is just a way to store certain values when certain conditions are met etc etc) Then I ask which element contains teh value 0.01. Ok. Same with 0.02. But when I ask about 0.03 or above... the answer is none. But I can see 0.03 in my vector, it is there! This must be because of the value stored internally. Indeed, if I do: v-0.03, when I reach the value that appeared to contain 0.03, I don't obtain zero, but 3.47e-18 why is this? what is the recommended way to overcome this? Interestingly, if I store the values as character, then I can match them fine... Below is the code, and my sessionInfo() output. Thanks! Jose de las Heras code example: #v-vector(mode=character) v-c() i-0 while (i = 0.1) { v-c(v,i) i-i+0.005 } v which(v==0.01) which(v==0.02) which(v==0.03) sessionInfo() R version 2.10.0 (2009-10-26) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United Kingdom.1252 [2] LC_CTYPE=English_United Kingdom.1252 [3] LC_MONETARY=English_United Kingdom.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] biomaRt_2.2.0 loaded via a namespace (and not attached): [1] RCurl_1.3-1 tools_2.10.0 XML_2.6-0 -- Dr. Jose I. de las Heras Email: j.delashe...@ed.ac.uk The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374 Institute for Cell Molecular BiologyFax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK * NEW EMAIL from July'09: nach.mcn...@gmail.com * -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] color blending and transparency
On 03/02/2010 9:38 AM, baptiste auguie wrote: That makes perfect sense, thank you, except that I'm not sure where the white comes from when I set the background to transparent? You'd have to check the png device documentation or source code to find out what it does when you mix half red with half transparent. When I view a .png file in the default viewer in Windows 7, setting the background to transparent displays it as white, I don't see the things behind the window showing through. I don't know if it's the viewer or the file determining that. Duncan Murdoch png(testingOrder.png, bg = transparent) plot.new() par(bg=transparent) rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) dev.off() Still produces two different overlap colours, although I *think* only two colours are involved. What I have I missed here? Thanks, baptiste On 3 February 2010 15:17, Duncan Murdoch murd...@stats.uwo.ca wrote: On 03/02/2010 8:50 AM, Ken Knoblauch wrote: baptiste auguie baptiste.auguie at googlemail.com writes: Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two layers the overlap region is either purple or dark red. I have no idea why. png(testingOrder.png) plot.new() # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) I think it's a fairly simple calculation. In the first example: We are writing red (1,0,0) at alpha=0.5 onto white (1,1,1), so we get a mixture of half existing and half new, i.e. (1,0.5,0.5). Then we write blue (0,0,1) at alpha 0.5 onto that, giving (0.5, 0.25, 0.75). In the second pair, the first write yields (0.5,0.5,1), and the second yields (0.75, 0.25, 0.5). So this is like mixing paints: you don't get the same colour if you mix equal parts red and white, then take equal parts of that mixture with blue, as you get if you put the blue in first. You've got less red in the first mixture than in the second. You would get the same color in both mixtures if you didn't mix the white in: # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=1)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=1)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) Duncan Murdoch dev.off() I would expect overlaid transparencies to act like filters and multiply, producing so-called subtractive color mixing, so blue and yellow gives green. Interestingly, however, overlaying filters is not necessarily a commutative operation, since a transparent filter can yield an additive component (through scatter, for example) though I suspect that the non-commutativity comes about in R because these rules apply to physical lights, filters and surfaces and in R, it is some uncalibrated combination of frame buffer values that is being used. Best, baptiste Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error with R CMD check - Packages required but not available:
Yes, R_LIBS have been set to include the library where myPackage1 is installed. When I start R and do library(myPackage1) it loads just fine so it is definitely installed. But somehow it is not able to do the same when I do R CMD check myPackage2. -Original Message- From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de] Sent: Wednesday, February 03, 2010 09:55 AM To: Reena Bansal Cc: r-help@r-project.org Subject: Re: [R] Error with R CMD check - Packages required but not available: On 02.02.2010 22:52, Reena Bansal wrote: Apologies in advance if this is not the right email to post this question. I successfully created my first R package myPackage1. Now I want to create another R package myPackage2 which requires functions from myPackage1. However when I try R CMD check myPackage2 I get the following error Have you set the environment variable R_LIBS to include the library which myPackage1 has been installed into previously? Best, Uwe Ligges * checking for working pdflatex ... OK * using log directory '.../myPackage/myPackage2.Rcheck' * using R version 2.9.2 (2009-08-24) * using session charset: UTF-8 * checking for file 'myPackage2/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'myPackage2' version '1.0' * checking package dependencies ... ERROR Packages required but not available: myPackage1 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] selecting a group of points from a scatterplot?
Hi everyone, is there a way/package in R that would allow me to select a group of points from a scatterplot by drawing a circle around them or some such? I can use 'identify' to pick individual points, but that gets tedious if one has more than 10-20 spots. I can easily select spots within a rectangle defined by picking points using identify... but a simple rectangle sometimes will force me to pick points that I want to leave out. Many graph plotting programs allow you to pick a group of points directly from the graph by circling them with teh mouse cursor. Is that soemthing that I can do in R? Thanks! Jose -- Dr. Jose I. de las Heras Email: j.delashe...@ed.ac.uk The Wellcome Trust Centre for Cell BiologyPhone: +44 (0)131 6513374 Institute for Cell Molecular BiologyFax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK * NEW EMAIL from July'09: nach.mcn...@gmail.com * -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Can't compile R 2.10.1 on AIX
I'm trying to compile R 2.10.1 on AIX, and getting the following errors when it is trying to build the tools package: Error in read.dcf(file = descfile) : Line starting 'Package: tools ...' is malformed! Calls: makeLazyLoading ... code2LazyLoadDB - loadNamespace - parseNamespaceFile - read.dcf Execution halted make: *** [all] Error 1 My environment and configure settings look like this: export PATH=/usr/local/bin:/opt/freeware/bin:$PATH export OBJECT_MODE=64 export LIBICONV=/opt/freeware export CC=xlc_r -q64 export CFLAGS=-O -qstrict export CXX=xlC_r -q64 export CXXFLAGS=-O -qstrict export AR=ar -X64 export F77=xlf_r -q64 export CPPFLAGS=-I/afs/isis/pkg/libpng/include -I/usr/local/include -I$LIBICONV/include -I/usr/lpp/X11/include/X11 export LDFLAGS=-L/usr/local/lib -L$LIBICONV/lib -L/usr/lib -L/usr/X11R6/lib export CAIRO_CFLAGS=-I/opt/freeware/include/cairo -I/opt/freeware/include/freetype2 export CAIRO_LIBS=-L/opt/freeware/lib -lcairo export JAVA_HOME=/usr/java14_64 export JAVA_CPPFLAGS=-I/usr/java14_64/include export LDR_CNTRL=USERREGS ./configure --prefix=/afs/.isis/pkg/r-2.10.1 --with-tcltk=/usr/local/lib --with-tcl-config=/usr/local/lib/tclConfig.sh --with-tk-config=/usr/local/lib/tkConfig.sh I get the same error on both AIX 5.3 and AIX 6.1. I successfully compiled R 2.8.1 on AIX 5.3 with the same setup. Has anyone else seen this problem on AIX? Mike Waldron __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] typo in contrast package's vignettes
On Wed, Feb 3, 2010 at 8:41 AM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 9:28 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c' \lambda$, right? If I'm correct, could somebody notice the author to fix it? Do it yourself. What do you mean? I have two questions. I assume you are answering my second questions. Would you please make sure that your reply is complete to avoid any confusions? If you think there is an error, then you should contact the package maintainer. Simple (and complete) as that. If you don't want to check, then don't post with nonsense reply. Its the advice that you could and _should_ have read in the Posting Guide. I'm not clear how my original post violate the posting guide http://www.r-project.org/posting-guide.html. Would you please be specific which item I violated? Your use of violated, not mine. For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R), ask questions on R-help. I asked the questions because I'm not sure if I am a hundred percent correct. If I am wrong, then it is not a problem with the package. Therefore, it is perfectly OK to ask the question on r-help. If the question relates to a contributed package , e.g., one downloaded from CRAN, try contacting the package maintainer first. Have you tried contacting the contrast package maintainer? -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Delete missing value rows from a matrix
Hi everyone, I have a matrix with many Na's. Some rows contain some Na's and some others are entirely composed of Na's. I want to delete the rows that are entirely composed of Na's but not the other ones so I can't use a simple removeNA. Has any one an idea? - Anna Lippel -- View this message in context: http://n4.nabble.com/Delete-missing-value-rows-from-a-matrix-tp1461305p1461305.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to read this data file into R?
Did you actually look at what you got? I got 129 lines: str(x) 'data.frame': 129 obs. of 9 variables: $ A: Factor w/ 28 levels [,..: 4 5 6 7 8 9 10 11 12 13 ... $ B: Factor w/ 129 levels ] 0.7982354 -5.195960 2.0059635 2.00596350 2.0059635 2.005964 2.0059635,..: 119 123 120 121 115 117 116 118 105 122 ... $ C: Factor w/ 5 levels ,10] [,..: 1 1 1 1 1 1 1 1 1 1 ... $ D: Factor w/ 5 levels ,11] [,..: 1 1 1 1 1 1 1 1 1 1 ... $ E: Factor w/ 5 levels ,12] [,..: 1 1 1 1 1 1 1 1 1 1 ... $ F: Factor w/ 5 levels ,13][,..: 1 1 1 1 1 1 1 1 1 1 ... $ G: Factor w/ 5 levels ,14] [,..: 1 1 1 1 1 1 1 1 1 1 ... $ H: Factor w/ 4 levels ,15],22],..: 1 1 1 1 1 1 1 1 1 1 ... $ I: logi NA NA NA NA NA NA ... -- David. On Feb 3, 2010, at 10:13 AM, Felipe Carrillo wrote: That's strange because I was able to read the file into R just fine --- On Tue, 2/2/10, David Winsemius dwinsem...@comcast.net wrote: From: David Winsemius dwinsem...@comcast.net Subject: Re: [R] how to read this data file into R? To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-help@r-project.org, song song rprojecth...@gmail.com Date: Tuesday, February 2, 2010, 3:40 PM On Feb 2, 2010, at 6:31 PM, Felipe Carrillo wrote: Convert the file into a csv file( myfile.csv), delete some of the unwanted rows before importing into R. Save the file on your working directory and then import into R: x - read.csv(myfile.csv) # Change column names names(x) - LETTERS[1:ncol(x)];x The problem with that solution is that there are an irregular number of numbers per row ranging from 8 to 6. You could read in as text with readLines but then need to extract by 25 lines at a time and then cbind the segments. Doable mind you, but I suspect faster with a spreadsheet intermediate solution. The real solution is to grab the miscreant sender by the throat , er, tactfully discuss with your valued customer ,,, and shake out a machine readable form that has all of one row in a row. -- David. Change your column names to whatever you want Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA --- On Tue, 2/2/10, song song rprojecth...@gmail.com wrote: From: song song rprojecth...@gmail.com Subject: [R] how to read this data file into R? To: r-help@r-project.org Date: Tuesday, February 2, 2010, 2:55 PM [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [1,] 2.010061 -5.223624 2.010061 2.010061 1.463336 1.463336 2.010061 2.010061 [2,] 2.057502 -5.101445 2.057502 2.057502 2.057502 2.057502 2.057502 2.057502 [3,] 2.011081 -5.227745 2.011081 2.011081 2.011081 2.011081 2.011081 2.011081 [4,] 2.031695 -5.147776 2.031695 2.031695 2.031695 2.031695 2.031695 2.031695 [5,] 1.982144 -5.219977 2.578551 1.982144 1.982144 1.982144 1.982144 1.982144 [6,] 1.997830 -5.197152 1.997830 1.997830 1.997830 1.997830 1.229965 1.997830 [7,] 1.987102 -5.202288 1.987102 1.987102 1.987102 1.987102 1.987102 2.045108 [8,] 2.004351 -5.263740 2.004351 2.004351 2.004351 2.004351 2.004351 2.004351 [9,] 1.860640 -5.281771 1.947604 1.947604 1.947604 1.947604 1.947604 1.947604 [10,] 2.034417 -5.268606 1.917726 1.917726 1.917726 1.917726 1.917726 1.917726 [11,] 1.892761 -5.254092 1.892761 1.892761 1.892761 1.892761 1.892761 1.892761 [12,] 1.878266 -4.725234 1.878266 1.878266 2.265870 1.878266 1.878266 1.878266 [13,] 1.941847 -5.293714 1.941847 1.941847 1.941847 2.212040 1.941847 1.941847 [14,] 3.280856 -5.295412 1.891672 1.891672 1.891672 1.891672 2.295541 1.891672 [15,] 1.833538 -5.381407 2.417865 1.833538 1.833538 1.833538 1.833538 1.833538 [16,] 1.813212 -5.256472 1.813212 2.337103 1.813212 1.813212 1.813212 1.813212 [17,] 1.763356 -5.262836 1.763356 2.538904 3.202743 1.763356 1.763356 1.763356 [18,] 2.71 -5.269976 1.824456 1.824456 1.824456 1.824456 1.824456 1.824456 [19,] 1.868374 -5.237574 1.868374 1.868374 1.868374 1.868374 1.868374 1.868374 [20,] 1.879976 -5.195960 1.879976 1.879976 2.400419 1.879976 1.879976 1.879976 [21,] 1.897184 -5.195960 1.897184 1.897184 1.897184 1.897184 1.897184 1.897184 [22,] 1.946035 -5.195960 1.946035 1.946035 1.946035 1.946035 1.946035 1.946035 [23,] 1.531107 -5.195960 2.005964 2.005964 2.005964 2.005964 1.012178 2.005964 [24,] 1.966488 -5.195960 1.966488 3.300449 1.966488 1.966488 1.966488 1.966488 [25,] 1.922473 -5.132915 1.922473 1.922473 1.922473 1.922473 1.327156 1.922473 [,9] [,10] [,11] [,12] [,13][,14] [,15] [1,] 2.0100609 -5.223624 2.0100609 2.01006088 2.0100609 2.010061 2.0100609 [2,] 2.0575018 -5.217940 2.0575018 2.05750183 2.0575018 2.057502 2.0575018 [3,] 2.0110810 -5.227745 2.0110810 1.25251992 1.1365329 2.011081 2.0110810 [4,] 2.0316951 -5.147776 2.0316951 0.53524458 2.0316951 2.031695 2.0316951 [5,] 1.9821437 -5.219977 1.9821437 1.98214375 1.9821437 1.982144 1.9821437 [6,]
Re: [R] selecting a group of points from a scatterplot?
On 2/3/10, j.delashe...@ed.ac.uk j.delashe...@ed.ac.uk wrote: Many graph plotting programs allow you to pick a group of points directly from the graph by circling them with teh mouse cursor. Is that soemthing that I can do in R? I am not sure that they will do exactly what you need, but check playwith(), latticist() and ggobi(). Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] make a grid with longitude, latitude and bathymetry data
hi, i have a longitude vector (x) a latitude vector (y) and a matrix of bathymetry (z) with the dimensions (x,y). I have already succeeded in plotting it with the image.plot (package 'field') and the contour functions. But now, I want to make a grid in order to extract easily the bathymetry corresponding to a couple of longitude, latitude coordinates. Do you know a function or a package which can help me? Or do you know how to do it? (because i have already looked for it on the internet and i didn't find anything) Thanks a lot. Karine Faites une bonne action avec Bing Solidaire ! C'est ici ! _ [[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] color blending and transparency
On Wed, 3 Feb 2010, baptiste auguie wrote: That makes perfect sense, thank you, except that I'm not sure where the white comes from when I set the background to transparent? png(testingOrder.png, bg = transparent) plot.new() par(bg=transparent) rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) dev.off() Still produces two different overlap colours, although I *think* only two colours are involved. What I have I missed here? My mental model for this, which I haven't bothered to check against the actual algorithms, is that colors are composed of reflective/absorbing pigment particles and that alpha says how densely they are packed. Alpha=0 means all the light gets through to bounce of what ever is below, eventually to the white paper, and alpha=1 means that all the light is reflected from the top layer of paint. With 50% blue over 50% red, you reflect 50% of the blue light and absorb 50% of the red and green light in the top layer of paint. Of the remaining light, 50% of the red is reflected and 50% of the green and blue absorbed by the particles in the bottom layer of paint. Anything that makes it through will reflect off the white paper. There is the additional complication that a transparent background still behaves as if it had white paper behind it (it's drawn on an acetate sheet which you lay on paper to see it more clearly). -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to export the examples in help(something) to a file?
On Wed, Feb 3, 2010 at 10:01 AM, Peng Yu pengyu...@gmail.com wrote: Some examples in the help page are too long to be copied from screen. Could somebody let me know some easy way on how to extract the example to a file so that I can play with them? I forget to mention. I use a terminal version of R. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] hdf files
hello, I have a problem to open an hdf file. i have downloaded the package 'hdf5' as it was advised on R seek. But when i try to load the file, the R console sends me an eror message: setwd(C:/Documents and Settings/Karine/Bureau/data/) #install.packages('hdf5') library(hdf5) sea_ice - hdf5load(asi-s6250-20090704-v5i.hdf, load = TRUE, verbosity = 3, tidy = FALSE) Grid_ice - hdf5load(LongitudeLatitudeGrid-s6250-Antarctic.hdf, load = TRUE, verbosity = 3, tidy = FALSE) sea_ice - hdf5load(asi-s6250-20090704-v5i.hdf, load = TRUE, verbosity = 3, tidy = FALSE) hdf5_global_verbosity=3 load=1 Erreur dans hdf5load(asi-s6250-20090704-v5i.hdf, load = TRUE, verbosity = 3, : unable to open HDF file: asi-s6250-20090704-v5i.hdf Grid_ice - hdf5load(LongitudeLatitudeGrid-s6250-Antarctic.hdf, load = TRUE, verbosity = 3, tidy = FALSE) hdf5_global_verbosity=3 load=1 Erreur dans hdf5load(LongitudeLatitudeGrid-s6250-Antarctic.hdf, load = TRUE, : unable to open HDF file: LongitudeLatitudeGrid-s6250-Antarctic.hdf Thanks a lot, Karine HEERAH Master 2 mention océanographie et environnements marins, parcours océanique 42 rue Salvador Allende 92000 Nanterre 06.61.50.97.47 Faites une bonne action avec Bing Solidaire ! C'est ici ! Discute avec tes amis partout, grâce à Messenger sur ton mobile. Cliquez ici ! _ [[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] diagnostic plots
also do: plot(lm(x~y), ask=FALSE) On Wed, Feb 3, 2010 at 10:21 AM, Trafim Vanishek rdapam...@gmail.com wrote: Dear all, does anybody ever encountered the problem with diagnostic plots? x-rnorm(100) y-rnorm(100) plot(lm(x~y)) It gives the following message Waiting to confirm page change... and nothing happens. 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] diagnostic plots
Hit 'enter'. There are several plots and they are being presented with par(ask=TRUE) On Wed, Feb 3, 2010 at 10:21 AM, Trafim Vanishek rdapam...@gmail.com wrote: Dear all, does anybody ever encountered the problem with diagnostic plots? x-rnorm(100) y-rnorm(100) plot(lm(x~y)) It gives the following message Waiting to confirm page change... and nothing happens. 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] comparison of parameters for nonlinear regression
Hi, I have two series of data set (it's measurment of growth but under two different conditions). To model these data I use the same function which is : formula - y ~ Asym_inf + Asym_sup * ( (1 / (1 + (n1 * (exp( (tmid1-x) / scal1) )^(1/n1) ) ) ) - (1 / (1 + (n2 * (exp( (tmid2-x) / scal2) )^(1/n2) ) ) ) ) After the estimation of the parameters thanks to nls, I have 2 models. The idea is I want to compare this 2 models and particularly I want to know if the parameters are different are not beteween this 2 models. Is there a way to do it simply in R? Thanks in advance -- Nathalie YAUSCHEW-RAGUENES Ph.D Student Unité de Recherches Ecologie Fonctionnelle et Physique de l'Environnement (EPHYSE) INRA, Centre de Bordeaux - Aquitaine 71 Av Edouard Bourlaux 33883 Villenave d'Ornon Cedex France Tél : +33 (0)5 57 12 24 31 Fax : +33 (0)5 57 12 24 20 e-mail : nathalie.yauschew-rague...@bordeaux.inra.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] color blending and transparency
On MacOSX I can tell Preview or Photoshop not to use a white background yet the mixing still shows a difference (with either pdf or png for that matter). So I guess it's something to do with mixing colours with the transparent channel as you say. I'll try to find the reason in the source code later (I haven't found any documentation on this so far). Thanks, baptiste On 3 February 2010 16:38, Duncan Murdoch murd...@stats.uwo.ca wrote: On 03/02/2010 9:38 AM, baptiste auguie wrote: That makes perfect sense, thank you, except that I'm not sure where the white comes from when I set the background to transparent? You'd have to check the png device documentation or source code to find out what it does when you mix half red with half transparent. When I view a .png file in the default viewer in Windows 7, setting the background to transparent displays it as white, I don't see the things behind the window showing through. I don't know if it's the viewer or the file determining that. Duncan Murdoch png(testingOrder.png, bg = transparent) plot.new() par(bg=transparent) rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) dev.off() Still produces two different overlap colours, although I *think* only two colours are involved. What I have I missed here? Thanks, baptiste On 3 February 2010 15:17, Duncan Murdoch murd...@stats.uwo.ca wrote: On 03/02/2010 8:50 AM, Ken Knoblauch wrote: baptiste auguie baptiste.auguie at googlemail.com writes: Adding two semi-transparent colours results in non-intuitive colour mixing (a mystery for me anyway). Is it additive (light), substractive (paint), or something else? Consider the following example, depending on the order of the two layers the overlap region is either purple or dark red. I have no idea why. png(testingOrder.png) plot.new() # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=0.5)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=0.5)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) I think it's a fairly simple calculation. In the first example: We are writing red (1,0,0) at alpha=0.5 onto white (1,1,1), so we get a mixture of half existing and half new, i.e. (1,0.5,0.5). Then we write blue (0,0,1) at alpha 0.5 onto that, giving (0.5, 0.25, 0.75). In the second pair, the first write yields (0.5,0.5,1), and the second yields (0.75, 0.25, 0.5). So this is like mixing paints: you don't get the same colour if you mix equal parts red and white, then take equal parts of that mixture with blue, as you get if you put the blue in first. You've got less red in the first mixture than in the second. You would get the same color in both mixtures if you didn't mix the white in: # Red below rect(0.3, 0.5, 1, 1, col=rgb(1, 0, 0, alpha=1)) rect(0, 0.5, 0.7, 1, col=rgb(0, 0, 1, alpha=0.5)) # Blue below rect(0, 0, 0.7, 0.5, col=rgb(0, 0, 1, alpha=1)) rect(0.3, 0, 1, 0.5, col=rgb(1, 0, 0, alpha=0.5)) Duncan Murdoch dev.off() I would expect overlaid transparencies to act like filters and multiply, producing so-called subtractive color mixing, so blue and yellow gives green. Interestingly, however, overlaying filters is not necessarily a commutative operation, since a transparent filter can yield an additive component (through scatter, for example) though I suspect that the non-commutativity comes about in R because these rules apply to physical lights, filters and surfaces and in R, it is some uncalibrated combination of frame buffer values that is being used. Best, baptiste Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] typo in contrast package's vignettes
Peng Yu wrote: On Wed, Feb 3, 2010 at 8:41 AM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 9:28 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c' \lambda$, right? If I'm correct, could somebody notice the author to fix it? Do it yourself. What do you mean? I have two questions. I assume you are answering my second questions. Would you please make sure that your reply is complete to avoid any confusions? If you think there is an error, then you should contact the package maintainer. Simple (and complete) as that. If you don't want to check, then don't post with nonsense reply. Its the advice that you could and _should_ have read in the Posting Guide. I'm not clear how my original post violate the posting guide http://www.r-project.org/posting-guide.html. Would you please be specific which item I violated? Your use of violated, not mine. For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R), ask questions on R-help. I asked the questions because I'm not sure if I am a hundred percent correct. If I am wrong, then it is not a problem with the package. Therefore, it is perfectly OK to ask the question on r-help. Really? Where exactly is the loophole in 'If the question relates to a contributed package ... try contacting the package maintainer first.'? I don't see an addendum that states 'But if you are not 100% sure that you are correct about your question then you should ask on R-help first, because of course those people know WAY more about the package and its contents than the maintainer, who is really just tangentially involved with the package and probably couldn't clear up any misunderstandings you may have.' But I could be mistaken. I am not good at reading between the lines... If the question relates to a contributed package , e.g., one downloaded from CRAN, try contacting the package maintainer first. Have you tried contacting the contrast package maintainer? -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- James W. MacDonald, M.S. Biostatistician Douglas Lab University of Michigan Department of Human Genetics 5912 Buhl 1241 E. Catherine St. Ann Arbor MI 48109-5618 734-615-7826 ** Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Mix Distribution Fit
Dear all, I want to ask if there is mix distribution fit toolbox, which is friendly to use in R. Which one should I choose? Thanks. Best, Jiang __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Delete missing value rows from a matrix
Hello, You can run a row-wise all( is.na( ) ). You will then detect rows consisting of NAs only. Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com anna wrote: Hi everyone, I have a matrix with many Na's. Some rows contain some Na's and some others are entirely composed of Na's. I want to delete the rows that are entirely composed of Na's but not the other ones so I can't use a simple removeNA. Has any one an idea? - Anna Lippel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tapply for function taking of 1 argument?
Yes, this is clearly the key to working with subsets. Thanks -Original Message- From: Petr PIKAL [mailto:petr.pi...@precheza.cz] Sent: Wednesday, February 03, 2010 4:16 AM To: Steve Jaffe Cc: r-help@r-project.org Subject: Re: [R] tapply for function taking of 1 argument? Hi r-help-boun...@r-project.org napsal dne 02.02.2010 22:16:06: 'fraid not :-(( tapply( data, groups, weighted.mean, weights) tapply(seq(along=lll), rrr, function(i, x, w) weighted.mean(x[i], w[i]), x=lll, w=ttt) If you want to subset more than one thing, subset the index vector. The above help I obtained from Prof.Ripley several years ago so (untested) tapply( seq(along=data), groups, function (i, x, w) weighted.mean(x[i], w[i]), x=data, w=weights) I believe it shall still work. Regards Petr won't work because the *entire* weights vector is passed as the 2nd arg to weighted.means. But weighted.mean needs 'weights' to be split in the same way as 'data' -- the first and 2nd args need to correspond. Jorge Ivan Velez wrote: Hi sjaffem, You were almost there: tapply( yourdata, groups, weighted.mean, weights) See ?tapply for more information. HTH, Jorge -- View this message in context: http://n4.nabble.com/tapply-for-function-taking- of-1-argument-tp1460392p1460419.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to export the examples in help(something) to a file?
Some examples in the help page are too long to be copied from screen. Could somebody let me know some easy way on how to extract the example to a file so that I can play with them? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tapply for function taking of 1 argument?
also, library(plyr) ddply(d,~grp,function(df) weighted.mean(df$x,df$w)) -- View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1461428.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] typo in contrast package's vignettes
Really? Where exactly is the loophole in 'If the question relates to a contributed package ... try contacting the package maintainer first.'? How about the general R philosophy that if you dare to mistakenly submit a bug report that turns out to be a feature, not a bug, you shall be well and truly chastised? Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to export the examples in help(something) to a file?
Hi Peng, May be this is not the best way to do what you want, but it works for my proposes: sink('example_lm.txt') example(lm) Hit Return to see next plot: sink() Then, I just look at the file example_lm.txt on my working directory. HTH, Jorge On Wed, Feb 3, 2010 at 11:01 AM, Peng Yu wrote: Some examples in the help page are too long to be copied from screen. Could somebody let me know some easy way on how to extract the example to a file so that I can play with them? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: Delete missing value rows from a matrix
Hi r-help-boun...@r-project.org napsal dne 03.02.2010 16:53:20: Hi everyone, I have a matrix with many Na's. Some rows contain some Na's and some others are entirely composed of Na's. I want to delete the rows that are entirely composed of Na's but not the other ones so I can't use a simple removeNA. Has any one an idea? Untested data[rowSums(is.na(data))ncol(data),] Regards Petr - Anna Lippel -- View this message in context: http://n4.nabble.com/Delete-missing-value-rows- from-a-matrix-tp1461305p1461305.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to combine 2 3d scatterplots in R
hi, I am new to R and i have managed to create 2 3d scatterplots with R and Iwaswondering if there is a way to connect them. I was also wondering how i can add arrows to the plot similar to the 2d comment arrows()? -- View this message in context: http://n4.nabble.com/how-to-combine-2-3d-scatterplots-in-R-tp1461485p1461485.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tapply for function taking of 1 argument?
On Wed, Feb 3, 2010 at 11:06 AM, David Freedman 3.14da...@gmail.com wrote: also, library(plyr) ddply(d,~grp,function(df) weighted.mean(df$x,df$w)) Or ddply(d, grp, summarise, mean = weighted.mean(x, w)) which is convenient if you want more than one output Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] graphing help: line runs off top of graph
Hi, See the files at http://bulldog.duhs.duke.edu/~faheem/R/ Usage is $ Rscript memgraph.R meminfo.csv Output is meminfo.pdf. As you can see, one of the lines (blue) runs off the top of the graph. Can anyone suggest a way to avoid this happening? Please CC me on any reply. Thanks in advance. Regards, Faheem. memgraph.R args - commandArgs() filename = args[6] m = read.csv(filename, header=TRUE) m = data.frame(scale(m, center=FALSE, scale = c(60, 1024^2, 1024^2, 1))) mRSS = m[,c(time, RSS)] mVSZ = m[,c(time, VSZ)] mPERCENT = m[,c(time, X.MEM)] pdf(file=paste(strsplit(filename, \\.)[[1]][1],.pdf, sep=)) plot(mRSS, col=red, type='l', xlab=time (min), ylab=memory (GB)) lines(mVSZ, col=royalblue, type='l') #plot(mPERCENT) dev.off() __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] svm
HI Amy, On Wed, Feb 3, 2010 at 1:56 AM, Amy Hessen amy_4_5...@hotmail.com wrote: Hi Steve, Could you please help me in this point?: I use SVM of R and I’m trying some datasets from UCI but when I compare the results of my program( that does not do anything more than calling SVM) with the RMSE of SVM in any other paper, I found a big gap between them. For example, this is the rmse of svm of my program for the dataset bodyfat: 2.64561 And this is the RMSE of a paper 0.0204. Could you please tell me how I can reduce this gap in the performance of SVM? Sorry, it's hard to say w/o investing any real time to investigate (and I unfortunately don't have the time to do so). There are different parameters you can play with in nu-regression vs. eps-regression and different kernel functions that can be used that might be a better fit for the type of data you are trying to learn against. Before running the SVM (or any other learning alogorithm), there are also ways to normalize your data, too .. Lots of things to look at ... -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error with R CMD check - Packages required but not available:
I tried to bypass R CMD check myPackage2 and did the following R CMD build myPackage2 R CMD INSTALL -l ~/Rlibs myPackage2 and this works, I can load myPackage2 into my R session. Wondering why R CMD check failed and is it not necessary for R CMD check to work before I can build the package? -Original Message- From: David Scott [mailto:d.sc...@auckland.ac.nz] Sent: Tuesday, February 02, 2010 07:27 PM To: Reena Bansal Subject: Re: [R] Error with R CMD check - Packages required but not available: Reena Bansal wrote: Hi All, Apologies in advance if this is not the right email to post this question. I successfully created my first R package myPackage1. Now I want to create another R package myPackage2 which requires functions from myPackage1. However when I try R CMD check myPackage2 I get the following error * checking for working pdflatex ... OK * using log directory '.../myPackage/myPackage2.Rcheck' * using R version 2.9.2 (2009-08-24) * using session charset: UTF-8 * checking for file 'myPackage2/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'myPackage2' version '1.0' * checking package dependencies ... ERROR Packages required but not available: myPackage1 See the information on DESCRIPTION files in the chapter 'Creating R packages' of the 'Writing R Extensions' manual. My DESCRIPTION file looks like this Package: myPackage2 Type: Package Title: myPackage2 Version: 1.0 Date: 2010-02-02 Author: RB Maintainer: r...@xyz.com Description: myPackage2 Depends: myPackage1 License: What license is it under? LazyLoad: yes I have also checked .libPaths() and it has the right path to find myPackage1 in my local R library. Any suggestions? Have you *installed* myPackage1 before trying to check myPackage2? This sort of structure certainly works for me (VarianceGamma and SkewHyperbolic depend on HyperbolicDist). David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] What font exactly is tkrplot looking for
Hello. I am getting an error thrown from tkrplot. It is X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 could not be loaded sessionInfo() R version 2.10.1 Patched (2009-12-29 r50852) i686-pc-linux-gnu locale: [1] LC_CTYPE=en_US LC_NUMERIC=C LC_TIME=en_US [4] LC_COLLATE=C LC_MONETARY=CLC_MESSAGES=en_US [7] LC_PAPER=en_US LC_NAME=CLC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US LC_IDENTIFICATION=C attached base packages: [1] tcltk stats graphics grDevices utils datasets methods [8] base other attached packages: [1] tkrplot_0.0-18TeachingDemos_2.5 loaded via a namespace (and not attached): [1] tools_2.10.1 I know this means tkrplot can't find the font it's looking for. I have that font family available as 75dpi (according to xfontsel). Is it looking for the 100dpi version? I'm pretty sure I have the necessary fonts. I just may need to tell X where they are, so I'm wondering exactly which font(s) are being requested. Thanks. -- Kevin E. Thorpe Biostatistician/Trialist, Knowledge Translation Program Assistant Professor, Dalla Lana School of Public Health University of Toronto email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] graphing help: line runs off top of graph
On Feb 3, 2010, at 12:53 PM, Faheem Mitha wrote: Hi, See the files at http://bulldog.duhs.duke.edu/~faheem/R/ Usage is $ Rscript memgraph.R meminfo.csv Output is meminfo.pdf. As you can see, one of the lines (blue) runs off the top of the graph. Can anyone suggest a way to avoid this happening? Please CC me on any reply. Thanks in advance. Regards, Faheem. memgraph.R args - commandArgs() filename = args[6] m = read.csv(filename, header=TRUE) m = data.frame(scale(m, center=FALSE, scale = c(60, 1024^2, 1024^2, 1))) mRSS = m[,c(time, RSS)] mVSZ = m[,c(time, VSZ)] mPERCENT = m[,c(time, X.MEM)] pdf(file=paste(strsplit(filename, \\.)[[1]][1],.pdf, sep=)) plot(mRSS, col=red, type='l', xlab=time (min), # add a more inclusive or expansive ylim argument ylim=max(c(mRSS,mVSZ)), ylab=memory (GB)) lines(mVSZ, col=royalblue, type='l') #plot(mPERCENT) dev.off() -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] offlist Re: typo in contrast package's vignettes
On Feb 3, 2010, at 10:53 AM, Peng Yu wrote: On Wed, Feb 3, 2010 at 8:41 AM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 9:28 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:22 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:20 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:14 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 3, 2010, at 12:11 AM, Peng Yu wrote: On Tue, Feb 2, 2010 at 11:04 PM, David Winsemius dwinsem...@comcast.net wrote: On Feb 2, 2010, at 11:42 PM, Peng Yu wrote: It seems that Eq (2) in the vignettes for the 'contrast' packages is not correct. That is, the numerator on the right hand side should be $c' \beta$ rather than $c' \lambda$, right? If I'm correct, could somebody notice the author to fix it? Do it yourself. What do you mean? I have two questions. I assume you are answering my second questions. Would you please make sure that your reply is complete to avoid any confusions? If you think there is an error, then you should contact the package maintainer. Simple (and complete) as that. If you don't want to check, then don't post with nonsense reply. Its the advice that you could and _should_ have read in the Posting Guide. I'm not clear how my original post violate the posting guide http://www.r-project.org/posting-guide.html. Would you please be specific which item I violated? Your use of violated, not mine. For questions about functions in standard packages distributed with R (see the FAQ Add-on packages in R), ask questions on R-help. I asked the questions because I'm not sure if I am a hundred percent correct. If I am wrong, then it is not a problem with the package. Therefore, it is perfectly OK to ask the question on r-help. If the question relates to a contributed package , e.g., one downloaded from CRAN, try contacting the package maintainer first. You have a question and it relates to a contributed package, so the premises of the second (and not the first) sentence is satisfied. The consequent is contact the maintainer. Logic ... simple clear logic applied to a declarative English sentence. Your interpretation is perverse and I assert is completely contrary to a sensible reading of those two sentences. Your interpretation is doubly perverse in that it regards the package documentation which _only_ the maintainer can adjust. I do not undertand why you are bothering hundreds of people who can do nothing about your concerns with these persistently obtuse questions while you are at the same time resisting contacting the one person who could do something, the package maintainer. Have you tried contacting the contrast package maintainer? David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to combine 2 3d scatterplots in R
On 03.02.2010 18:38, mb622 wrote: hi, I am new to R and i have managed to create 2 3d scatterplots with R and Iwaswondering if there is a way to connect them. In most cases it is advisable to just add points as shown in the examples of ?scatterplot3d I was also wondering how i can add arrows to the plot similar to the 2d comment arrows()? Example: ## plot 10 points: s3d - scatterplot3d(1:10, 1:10, 1:10) ## plot arrows from (2,2,2) to (5,5,5) ## calculate arrow projections into 2D space: from - s3d$xyz.convert(2,2,2) to - s3d$xyz.convert(5,5,5) ## and plot: arrows(from$x, from$y, to$x, to$y) Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tapply for function taking of 1 argument?
Also try this: library(sqldf) DF - data.frame(data = 1:10, groups = rep(1:2, 5), weights = 1) sqldf(select groups, sum(data * weights)/sum(weights) 'wtd mean' from DF group by groups) groups wtd mean 1 15 2 26 On Tue, Feb 2, 2010 at 5:06 PM, sjaffe sja...@riskspan.com wrote: Thanks! :-) I suppose it's obvious, but one will generally have to use a (anonymous) function to 'unpack' the data.frame into columns, unless the function already knows how to do this. I mention this because when I tested the solution on my example I got an unexpected result -- apparently weighted.mean will operate on a 2-column dataframe but not in the way one would expect. data = 1:10 weights = rep(1,10) groups = rep(c(1,2),5) by( data.frame(data,weights), groups, weighted.mean) groups: 1 [1] 15 groups: 2 [1] 17.5 But by( data.frame(data,weights), groups, function(d) { weighted.mean(d[,1], d[,2]) } ) does the right thing groups: 1 [1] 5 groups: 2 [1] 6 Bert Gunter wrote: ?by Bert Gunter Genentech Nonclinical Statistics -- View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1460489.html Sent from the R help mailing list archive at Nabble.com. [[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 flatten a tree (based on list) to a certain depth?
Suppose that I have the following list of lists of frames 'root' (let's call it a 'tree' of frames). I want to flatten it to be a list of frames. However, if I unlist(root), it will flatten the frames as well. Is there a simply way to flatten the tree to certain depth? aframe1=data.frame(x=1:3,y=1:3) aframe2=data.frame(u=7:9,v=11:13) aframe3=data.frame(p=3:5,q=6:8) main1=list(sub1=aframe1, sub2=aframe2) main2=list(sub3=aframe3) root=list(main1=main1, main2=main2) str(root) unlist(root) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tapply for function taking of 1 argument?
Thanks, Iâm actually more comfortable with vector-ish syntax than sql-ish but this is a good thing to keep in mind⦠I wonder how it compares in performance versus âbyâ or âtapplyâ From: Gabor Grothendieck [via R] [mailto:ml-node+1461531-1948782...@n4.nabble.com] Sent: Wednesday, February 03, 2010 1:19 PM To: Steve Jaffe Subject: Re: tapply for function taking of 1 argument? Also try this: library(sqldf) DF - data.frame(data = 1:10, groups = rep(1:2, 5), weights = 1) sqldf(select groups, sum(data * weights)/sum(weights) 'wtd mean' from DF group by groups) groups wtd mean 1 15 2 26 On Tue, Feb 2, 2010 at 5:06 PM, sjaffe [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1461531i=0 wrote: Thanks! :-) I suppose it's obvious, but one will generally have to use a (anonymous) function to 'unpack' the data.frame into columns, unless the function already knows how to do this. I mention this because when I tested the solution on my example I got an unexpected result -- apparently weighted.mean will operate on a 2-column dataframe but not in the way one would expect. data = 1:10 weights = rep(1,10) groups = rep(c(1,2),5) by( data.frame(data,weights), groups, weighted.mean) groups: 1 [1] 15 groups: 2 [1] 17.5 But by( data.frame(data,weights), groups, function(d) { weighted.mean(d[,1], d[,2]) } ) does the right thing groups: 1 [1] 5 groups: 2 [1] 6 Bert Gunter wrote: ?by Bert Gunter Genentech Nonclinical Statistics -- View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1460489.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1461531i=1 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1461531i=2 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. View message @ http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1461531.html To unsubscribe from Re: tapply for function taking of 1 argument?, click here (link removed) ==. -- View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1461541.html Sent from the R help mailing list archive at Nabble.com. [[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 flatten a tree (based on list) to a certain depth?
Hi, On Wed, Feb 3, 2010 at 1:19 PM, Peng Yu pengyu...@gmail.com wrote: Suppose that I have the following list of lists of frames 'root' (let's call it a 'tree' of frames). I want to flatten it to be a list of frames. However, if I unlist(root), it will flatten the frames as well. Is there a simply way to flatten the tree to certain depth? aframe1=data.frame(x=1:3,y=1:3) aframe2=data.frame(u=7:9,v=11:13) aframe3=data.frame(p=3:5,q=6:8) main1=list(sub1=aframe1, sub2=aframe2) main2=list(sub3=aframe3) root=list(main1=main1, main2=main2) str(root) unlist(root) Does `unlist(root, recursive=FALSE)` get you what you want? R unlist(root, recursive=FALSE) $main1.sub1 x y 1 1 1 2 2 2 3 3 3 $main1.sub2 u v 1 7 11 2 8 12 3 9 13 $main2.sub3 p q 1 3 6 2 4 7 3 5 8 -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] tapply for function taking of 1 argument?
My editorial opinion only: It will of necessity be slower (because there's more machinery underlying the sqldf package); but I doubt whether it would be noticeably slower than the native R solution in most practical situations. The same would be true for plyR's implementation (it relies on the proto package, which slows things down a bit). The point is that the most important issue in almost all cases is the programmer's time to create and debug correct code, especially as the native machine speeds continue to increase. R gives you the option to choose whatever idiom you prefer to minimize this. The software implementation differences thereafter will rarely be important. In other words, pick your poison. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of sjaffe Sent: Wednesday, February 03, 2010 10:25 AM To: r-help@r-project.org Subject: Re: [R] tapply for function taking of 1 argument? Thanks, Ibm actually more comfortable with vector-ish syntax than sql-ish but this is a good thing to keep in mindb I wonder how it compares in performance versus bbyb or btapplyb From: Gabor Grothendieck [via R] [mailto:ml-node+1461531-1948782...@n4.nabble.com] Sent: Wednesday, February 03, 2010 1:19 PM To: Steve Jaffe Subject: Re: tapply for function taking of 1 argument? Also try this: library(sqldf) DF - data.frame(data = 1:10, groups = rep(1:2, 5), weights = 1) sqldf(select groups, sum(data * weights)/sum(weights) 'wtd mean' from DF group by groups) groups wtd mean 1 15 2 26 On Tue, Feb 2, 2010 at 5:06 PM, sjaffe [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1461531i=0 wrote: Thanks! :-) I suppose it's obvious, but one will generally have to use a (anonymous) function to 'unpack' the data.frame into columns, unless the function already knows how to do this. I mention this because when I tested the solution on my example I got an unexpected result -- apparently weighted.mean will operate on a 2-column dataframe but not in the way one would expect. data = 1:10 weights = rep(1,10) groups = rep(c(1,2),5) by( data.frame(data,weights), groups, weighted.mean) groups: 1 [1] 15 groups: 2 [1] 17.5 But by( data.frame(data,weights), groups, function(d) { weighted.mean(d[,1], d[,2]) } ) does the right thing groups: 1 [1] 5 groups: 2 [1] 6 Bert Gunter wrote: ?by Bert Gunter Genentech Nonclinical Statistics -- View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1460 489.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1461531i=1 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [hidden email]http://n4.nabble.com/user/SendEmail.jtp?type=nodenode=1461531i=2 mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. View message @ http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1461 531.html To unsubscribe from Re: tapply for function taking of 1 argument?, click here (link removed) ==. -- View this message in context: http://n4.nabble.com/tapply-for-function-taking-of-1-argument-tp1460392p1461 541.html Sent from the R help mailing list archive at Nabble.com. [[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] color blending and transparency
Thanks for this complementary information. My head itches slightly when reading about these virtual layers with unidirectional absorption and reflection properties but I guess that's imputable to my personal background as a physicist. I still have a few questions, - is this behavior documented? (I'm happy to look at the source, but I'm not even sure if it's in grDevices, device specific, or somewhere else altogether) - have there been any attempts at implementing other options for colour blending? It would be nice to be able to switch between additive and substrative colour mixing rules on occasion, but as far as I understand the scheme we discussed is hard coded deep into R's internals (correct?). An option not to use the background at all in the mixing / reflection process would be great already. Thanks again, baptiste On 3 February 2010 17:04, Thomas Lumley tlum...@u.washington.edu wrote: My mental model for this, which I haven't bothered to check against the actual algorithms, is that colors are composed of reflective/absorbing pigment particles and that alpha says how densely they are packed. Alpha=0 means all the light gets through to bounce of what ever is below, eventually to the white paper, and alpha=1 means that all the light is reflected from the top layer of paint. With 50% blue over 50% red, you reflect 50% of the blue light and absorb 50% of the red and green light in the top layer of paint. Of the remaining light, 50% of the red is reflected and 50% of the green and blue absorbed by the particles in the bottom layer of paint. Anything that makes it through will reflect off the white paper. There is the additional complication that a transparent background still behaves as if it had white paper behind it (it's drawn on an acetate sheet which you lay on paper to see it more clearly). -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.edu University of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] About the risk code in the fportfolio package
Hello, I have a problem with fPortfolio recently. I am using below code: Data = read.table(hf.txt,header = TRUE,sep = ) Data = Data[, c(CA, SS, EM, EMN, ED, DS, MS, RA, FIA, GM, LSE, MF, SP500, NASDAQ, JPM)] d = as.timeSeries(Data) class(d) Spec = portfolioSpec() setNFrontierPoints(Spec) = 1000 setRiskFreeRate(Spec) = 3 Constraints = both Frontier = portfolioFrontier(d, Spec, Constraints) frontierPlot(Frontier, pch = 19, col = c(black, grey), add = FALSE, labels = TRUE, return = c(mean), risk = c(Cov), auto = TRUE, title = TRUE) ~~ About the frontierPlot code when I use Sigma in the risk code: frontierPlot(Frontier, pch = 19, col = c(black, grey), add = FALSE, labels = TRUE, return = c(mean), risk = c(Sigma), auto = TRUE, title = TRUE) there are the same plot!!! WHY? I use the different risk code Could you tell me what the problem is? much THANKS -- View this message in context: http://n4.nabble.com/About-the-risk-code-in-the-fportfolio-package-tp1461475p1461475.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.