[R] Matching multiple columns in a data frame
Hello, I am trying to extract a subset of a dataframe A (2 columns) by extracting all entries in A (several repeated entries) that match dataframe B in both columns. For example, part of A and B are shown below. The following does not seem to work correctly. This only seems to select on the first component and all instances of the second. ind - A$C1 %in% B[,1] A$C2 %in% B[,2] Any suggestions as to how to do this in general (even for matches in multiple columns) would be appreciated. Regards, Nandini A: C1 C2 1 F 1500 2 P 120 4 F 250 5 I 200 6 D 2010 7 F 1000 8 V0 9 F 2100 10 F 500 11 E 1800 12 A 500 13 V0 14 I 125 15 I 30 16 M 300 17 D 75 18 V 500 19 A 200 20 M 1000 21 P 225 B: C1 C2 1 A 200 2 A 600 3 A 1500 4 B 100 5 B 1000 6 C 5000 7 C 225 8 C 150 9 C 150 10 C 200 [[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] Matching multiple columns in a data frame
A[with(A, paste(C1, C2, sep = \r)) %in% with(B, paste(C1, C2, sep=\r)), ] C1 C2 19 A 200 (Using sep = \r is perhaps a little too cautious.) Bill Venables http://www.cmis.csiro.au/bill.venables/ -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Raghavan, Nandini [PRDUS] Sent: Thursday, 7 May 2009 4:19 PM To: r-help@r-project.org Subject: [R] Matching multiple columns in a data frame Hello, I am trying to extract a subset of a dataframe A (2 columns) by extracting all entries in A (several repeated entries) that match dataframe B in both columns. For example, part of A and B are shown below. The following does not seem to work correctly. This only seems to select on the first component and all instances of the second. ind - A$C1 %in% B[,1] A$C2 %in% B[,2] Any suggestions as to how to do this in general (even for matches in multiple columns) would be appreciated. Regards, Nandini A: C1 C2 1 F 1500 2 P 120 4 F 250 5 I 200 6 D 2010 7 F 1000 8 V0 9 F 2100 10 F 500 11 E 1800 12 A 500 13 V0 14 I 125 15 I 30 16 M 300 17 D 75 18 V 500 19 A 200 20 M 1000 21 P 225 B: C1 C2 1 A 200 2 A 600 3 A 1500 4 B 100 5 B 1000 6 C 5000 7 C 225 8 C 150 9 C 150 10 C 200 [[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] RPgSQL package man pages
Hi, I installed the package RPgSQL and I am wanting to look at man pages. While the ones below do work: db.result.get.value db.write.table psql sql.insert sql.select sql.update the following man pages doesn't seem to work: rpgsql.connections rpgsql.execute.query rpgsql.input rpgsql.list.contents rpgsql.proxy rpgsql.result.attributes rpgsql.type.conversions rpgsql.utils I am simply typing a ? followed by a name. Is there any trick to read the second group? Regards, Tena Sakai tsa...@gallo.ucsf.edu [[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] Help with lme4 model specification
Please note that the case of characters is important in R. Hence True differs from TRUE. You need to use REML = TRUE instead of REML = True! The only valid logical values are TRUE, FALSE, T and F. But I recommend to use only TRUE and FALSE. Because you can overwrite T and F. You could do something like T - FALSE, which is ofcourse not a good idea. TRUE and FALSE can not be overwritten. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens boeinguy2 Verzonden: donderdag 7 mei 2009 0:21 Aan: r-help@r-project.org Onderwerp: [R] Help with lme4 model specification I am new to R and am trying to specify a model for mixed model analysis. When I run the following model I get an error: AAT- lmer(Y ~ S + A + (1|S:A/H), data=AT, REML=True) The error looks like this: Error in Spar_loc:`:` : NA/NaN argument In addition: Warning messages: 1: In model.matrix.default(mt, mf, contrasts) : variable 'Spar_loc' converted to a factor 2: In Spar_loc:`:` : numerical expression has 720 elements: only the first used I am having trouble specifying th random component. It should reflect the random term as H nested within the interaction of S A. What am I doing wrong? :confused: -- View this message in context: http://www.nabble.com/Help-with-lme4-model-specification-tp23415908p2341 5908.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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] data transformation using gamma
Hi R-users, I have this code to uniformise the data using gamma: length(dp1) [1] 696 dim(dp1) [1] 58 12 dim(ahall) [1] 1 12 dim(bhall) [1] 1 12 trans_dt - function(dt,a,b) + { n1 - ncol(dt) + n2 - length(dt) + trans - vector(mode='numeric', length=n2) + dim(trans) - dim(dt) + for (i in 1:n1) + { dt[,i] - as.vector(dt[,i]) + trans[,i] - transform(dti,newdt=pgamma(dti,shape= a[1,i],scale=b[1,i])) } + trans + } trans_dt(dp1,ahall,bhall) Error in transform(dti, newdt = pgamma(dti, shape = a[1, i], scale = b[1, : object dti not found and also try trans_dt - function(dt,a,b) { n1 - ncol(dt) n2 - length(dt) trans - vector(mode='numeric', length=n2) dim(trans) - dim(dt) for (i in 1:n1) { dti - dt[,i] ai - a[1,i] bi - b[1,i] trans[,i] - transform(dti,newdt=pgamma(dti,shape= ai,scale=bi)) } trans } trans_dt(dp1,ahall,bhall) Error in pgamma(dti, shape = ai, scale = bi) : object dti not found Thank you for any help given. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] I updated/reinstalled ggplot2 and the trouble started...
What device are you using to plot the graph? According to the warning, the device is causing the problem. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Tena Sakai Verzonden: donderdag 7 mei 2009 6:22 Aan: Ian Fellows; r-help@r-project.org Onderwerp: Re: [R] I updated/reinstalled ggplot2 and the trouble started... Hi Ian, Per your suggestion, I reinstalled R 2.9.0, then I reinstalled ggplot2 on top. The problem persists. Here's the what happens after the installation: qplot (carat, price, data = diamonds, alpha = I(1/10)) Warning message: In grid.Call.graphics(L_points, x$x, x$y, x$pch, x$size) : semi-transparency is not supported on this device: reported only once per page The entire record of installing ggplot2 package, ending up with the line above is in the attached file. I would think this should be reproducible with anybody else. If you have any other suggestion, I am all ears. Regards, Tena Sakai tsa...@gallo.ucsf.edu -Original Message- From: Ian Fellows [mailto:ifell...@gmail.com] Sent: Tue 5/5/2009 11:43 PM To: Tena Sakai Subject: Re: I updated/reinstalled ggplot2 and the trouble started... Tena, May I suggest that you do a full clean install of R 2.9.0, then install ggplot2 from cran. See if the problem persists after that. Ian On Tue, May 5, 2009 at 11:13 PM, tena tsa...@gallo.ucsf.edu wrote: Hi Hadley, Many thanks for your reply. I followed your instruction and got past the point where I was stuck at. Namely, I was able to generate a few plots. But as I came to the second half of section 2.4, where I wanted to see the behavior of alpha paramter, which I had apparently misspelled, I encountered another hindrance: qplot (carat, price, data = diamonds, alpha = I(1/10)) Warning message: In grid.Call.graphics(L_points, x$x, x$y, x$pch, x$size) : semi-transparency is not supported on this device: reported only once per page A plot was generated, but there are tic marks and labels on each direction, but no plot at all. I wonder if this is yet another (hidden) package to be updated... The warning message suggests grid, but I am hesitant to do something without knowing what is what. I would appreciate your instruction. Regards, Tena Sakai On May 5, 5:24 pm, hadley wickham h.wick...@gmail.com wrote: Hi Tena, R isn't very good at detecting when package dependencies also need to be updated, so you probably need to do: install.packages(c(reshape,plyr)) And you want qplot (carat, price, data=diamonds, alpha = I(1/10)) not qplot (carat, price, data=diamonds, slpha = i(1/10)) Hadley On Tue, May 5, 2009 at 6:27 PM, tena tsa...@gallo.ucsf.edu wrote: Hi Folks, I am pretty new to R and I am even newer to ggplot. I am using R 2.7.1, 2.8.1, and 2.9.0 on linux host and what I am experiencing holds for all three. I was just typing a few examples from the chapter 2 of the book, ggplot2 --Elegant graphics for data analysis. I typed 3 qplot lines on page 13: qplot (carat, price, data=diamonds, slpha = i(1/10)) qplot (carat, price, data=diamonds, slpha = i(1/100)) qplot (carat, price, data=diamonds, slpha = i(1/200)) To me, the plot looked identical. I went to my R library directory and looked at the date on the ggplot2 directory, which was April of 2008. I decided to update the library. In R, I issued: install.packages ('ggplot2', '/usr/local/Gallo/R') and there was a complaint as to permission denied for saving the current version (or something). I reissued the command as root and this time it gave me a normal return. I was ready to retrace my steps with the book. I only got to page 11 this time. Here's what happened (in all three versions): set.seed (1410) dsmall - diamonds [sample (nrow(diamonds), 100), ] qplot (carat, price, data = diamonds) Error in get(new, env = FacetGrid, inherits = TRUE) (FacetGrid, ...) : could not find function is.formula Can somebody please clue me in as to what's
[R] Gaussian local detrending and smoothing within a moving time window
Is there an R function implementing a Gaussian local detrending and smoothing within a moving time window ? I used ksmooth over the entire time series. Plotting the data before and after this operation shows that the signal is actuslly smoother but the tend is still there. I wonder whether ksmooth can be adapted on a sliding window, iteratively providing overlapping signal segments like: x[(n+r):(m+r)] where n m; r =1,2,3, so the sliding window width is m-n However, I do not know how the bandwidth and the window with are going to be related. Thank you for any comment and/or suggestion. Maura tutti i telefonini TIM! [[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] PGF Device
Am Mittwoch, den 06.05.2009, 16:08 +0200 schrieb baptiste auguie: I think the pgfSweave project on R-forge is working on this (as far as i know it currently relies on eps2pgf) Right, but eps2pgf fails me on more complex / stacked plots. Otherwise, I would be content using eps2pgf. Lasse http://r-forge.r-project.org/R/?group_id=331 HTH, Baptiste On 6 May 2009, at 15:37, Lasse Bombien wrote: Hi all, I saw a thread from 2007 about the possible implementation of a PGF (http://sourceforge.net/projects/pgf/) graphics device. Does anyone know if something came of it? I would very much like if that was the case. Regards, Lasse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 about plsr
Hi, I need your help, so I send letter to you. I have a problem about plsr in pls package. I want to show how classfied or related each ohter samples, so I tried to use plsr and biplot. But, I failed. Because, I had to change data type of my sample. Unfortunately, I didn't know how change data type. I want you to help me about that. please, help me. I show you my sample data , my scripts and error message. sample data asdf sp mw.1 mw.2 mw.3 1 a125 2 a236 3 b347 4 c458 5 c569 My script p1=plsr(sp~ .,data=asdf,varidation='CV') error message Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored I use korean version R. so I can show origin error message directly. The error message mean that colMeans(Y) : 'x' is must numerical value. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] I need your help about plsr
Hi, plsr funtion in pls package are intented for calculation of regression models. You must define your Y matrix as bianary identification matrix or You can just use plsda function from R's caret package. http://caret.r-forge.r-project.org/Classification_and_Regression_Training.html Best regards, Andris On Thu, May 7, 2009 at 11:34 AM, yongkook Kwon yongkookk...@gmail.com wrote: Hi, I need your help, so I send letter to you. I have a problem about plsr in pls package. I want to show how classfied or related each ohter samples, so I tried to use plsr and biplot. But, I failed. Because, I had to change data type of my sample. Unfortunately, I didn't know how change data type. I want you to help me about that. please, help me. I show you my sample data , my scripts and error message. sample data asdf sp mw.1 mw.2 mw.3 1 a 1 2 5 2 a 2 3 6 3 b 3 4 7 4 c 4 5 8 5 c 5 6 9 My script p1=plsr(sp~ .,data=asdf,varidation='CV') error message Warning message: In model.response(mf, numeric) : using type=numeric with a factor response will be ignored I use korean version R. so I can show origin error message directly. The error message mean that colMeans(Y) : 'x' is must numerical value. [[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] Bumps chart in R
On Thu, May 7, 2009 at 2:15 AM, Mike Lawrence mike.lawre...@dal.ca wrote: (cross posting to the ggplot2 group for posterity) Here's how I'd approach it: library(ggplot2) text = letters[1:20] tal1 = rnorm (20,5,2) tal2 = rnorm (20,6,3) dif = tal2-tal1 df0 = data.frame(text,tal1,tal2) df = melt( data = df0 , id.vars = 'text' , variable_name = 'tal' ) df$dif = dif df$col = ifelse(dif0,'red',ifelse(dif0,'blue','black')) df$size = abs(dif) # draw the plot Unfortunately it's not perfect: (1) col isn't being interpreted literally, so instead of truly red blue. (2) the lines ends are square whereas usually they're rounded. (3) attempting to remove the legend via opts(legend.position=none) seems to fail. Thank you with your melted data I was able to come very close to what I want. legen.posistion=none works for me... Annonying that colours don't work like expected... It seams to be a frequent concern. My code: qplot(tal,value,data=df,group=text,geom=line,size=size,colour=col,xlab=Change from time to time, ylab = Points)+ geom_text(aes(label=text),subset(df,tal==tal1),size=3,hjust=2,vjust=0)+ theme_bw()+ opts(legend.position=none)+ opts(title=As time went by) +opts(plot.title=theme_text(vjust=0,size=20)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Pie chart from .csv file
Ive found out a way around my problem. I was trying to plaot a histogram of strings, but I had to change it into integers. I ran an sql query on the original DB that I got the CSV file from and used COUNT to get the number of each unique item in a given column. I then used these numbers to create a histogram in R. It's a round about way of doing it, but it will have to suffice. Glad you found a solution to your problem. For future reference, an easier way to convert strings to numbers is to use as.numeric or as.integer. as.numeric(1.23) # 1.23 as.integer(4) # 4 If the process of reading in your data from the CSV file converts the strings to factors, then see the FAQ on R ( http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f). Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] When was the package relaimpo first introduced in R?
Dimitri Liakhovitski wrote: Hello! I am wondering when the package relaimpo was first introduced in R? Or maybe there is a way to look it up? I am not seeing it in the help file. The first archived version in your_CRAN_Mirror/src/contrib/Archive/relaimpo/ is dated 01-Dec-2005, obviously. 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] Bumps chart in R
Dear Andreas and Mike, You need to use scale_colour_manual() if you want to set the colours yourself. Ggplot2 interpretes the col variable in the dataset as an ordinairy factor. library(ggplot2) df0 - data.frame(text = letters[1:21], tal1 = c(rnorm (20,5,2), 5), tal2 = c(rnorm (20,6,3), 5)) df0$dif - df0$tal2 - df0$tal1 df - melt(data = df0, id.vars = c('text', 'dif'), variable_name = 'tal') df$Change - factor(ifelse(df$dif0,'Up',ifelse(df$dif0,'Down','Stable')), levels = c(Up, Stable, Down)) df$size - abs(df$dif) ggplot(df, aes(x = tal, y = value, label = text, group = text, size = size, col = Change)) + geom_line() + geom_text(data = subset(df, tal==tal1), size=3, hjust=2, vjust=0) + scale_x_discrete(Change from time to time) + scale_y_continuous(Points) + theme_bw()+ opts(legend.position=none)+ opts(title=As time went by\n) +opts(plot.title=theme_text(vjust=0,size=20)) + scale_colour_manual(values = c(red, black, blue)) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Andreas Christoffersen Verzonden: donderdag 7 mei 2009 12:22 Aan: Mike Lawrence; r-help@r-project.org; ggpl...@googlegroups.com Onderwerp: Re: [R] Bumps chart in R On Thu, May 7, 2009 at 2:15 AM, Mike Lawrence mike.lawre...@dal.ca wrote: (cross posting to the ggplot2 group for posterity) Here's how I'd approach it: library(ggplot2) text = letters[1:20] tal1 = rnorm (20,5,2) tal2 = rnorm (20,6,3) dif = tal2-tal1 df0 = data.frame(text,tal1,tal2) df = melt( data = df0 , id.vars = 'text' , variable_name = 'tal' ) df$dif = dif df$col = ifelse(dif0,'red',ifelse(dif0,'blue','black')) df$size = abs(dif) # draw the plot Unfortunately it's not perfect: (1) col isn't being interpreted literally, so instead of truly red blue. (2) the lines ends are square whereas usually they're rounded. (3) attempting to remove the legend via opts(legend.position=none) seems to fail. Thank you with your melted data I was able to come very close to what I want. legen.posistion=none works for me... Annonying that colours don't work like expected... It seams to be a frequent concern. My code: qplot(tal,value,data=df,group=text,geom=line,size=size,colour=col,xlab=Change from time to time, ylab = Points)+ geom_text(aes(label=text),subset(df,tal==tal1),size=3,hjust=2,vjust=0)+ theme_bw()+ opts(legend.position=none)+ opts(title=As time went by) +opts(plot.title=theme_text(vjust=0,size=20)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matching multiple columns in a data frame
?merge merge(A,B) C1 C2 1 A 200 On Thu, May 7, 2009 at 2:19 AM, Raghavan, Nandini [PRDUS] nragh...@its.jnj.com wrote: Hello, I am trying to extract a subset of a dataframe A (2 columns) by extracting all entries in A (several repeated entries) that match dataframe B in both columns. For example, part of A and B are shown below. The following does not seem to work correctly. This only seems to select on the first component and all instances of the second. ind - A$C1 %in% B[,1] A$C2 %in% B[,2] Any suggestions as to how to do this in general (even for matches in multiple columns) would be appreciated. Regards, Nandini A: C1 C2 1 F 1500 2 P 120 4 F 250 5 I 200 6 D 2010 7 F 1000 8 V0 9 F 2100 10 F 500 11 E 1800 12 A 500 13 V0 14 I 125 15 I 30 16 M 300 17 D 75 18 V 500 19 A 200 20 M 1000 21 P 225 B: C1 C2 1 A 200 2 A 600 3 A 1500 4 B 100 5 B 1000 6 C 5000 7 C 225 8 C 150 9 C 150 10 C 200 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error using lapply with oneway_test (coin package)
Dear expeRts, I would like to use a oneway_test (from package coin) to test whether two groups differ on various variables. The variables are encoded within a data frame. Unfortunately, I obtained an error, that I don't understand. Could you please help me ? Example: library(coin) y - as.data.frame(matrix(rnorm(200), ncol=2)) group - as.factor(unif(100)) lapply(y, function(var) oneway_test(var ~ group)) Error message is: (in French, my locale) Erreur dans eval(expr, envir, enclos) : objet 'var' introuvable (my personal translation in English) Error in eval(expr, envir, enclos) : object 'var' not found Thank you, Matthieu Matthieu Dubois Post-doctoral fellow Psychology and NeuroCognition Lab (CNRS UMR 5105) Université Pierre Mendès-France BP47 --- 38040 Grenoble Cedex 9 --- France Email: matthieu.dub...@upmf-grenoble.fr Gmail: matth...@gmail.com http://web.upmf-grenoble.fr/LPNC/membre_matthieu_dubois [[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] Show name of dataset in graph
Hi, Ive written a script to run several multivariate statistical analysis automatically. As one result a biplot and screeplot is produced. Now Id like to display the name of the inputdatset as part of the title of these graphics and I do not want to enter it each time I run the script. How can I extract the name of a dataset? An (shortened) extraction from the script: Test1 - function(pri, sec, Pca, Ca, Dca){ #pri - primary Parameters (biological Dataset (abundances)) #sec secondary Parameters #Pca, Ca, Dca Default=F, If set to TRUE these Methods are active several mathematical Operations biplot(pri, pc.biplot=T, main=paste(PCA - , ???) . Instead of the ??? I d like to have a variable. For example if Test1(dataset.typ5, sec.typ5, Pca=TRUE) then the title of the plots should be PCA dataset.typ5 Does anyone know a way? Regards, oli __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Generating plots with two lines, each line plotted with a different color
R 2.9.0 windows xp I would like to have the two lines generated by my plot have different colors, in addition to the two different line types specified by the plot command below. I would appreciate advice on how I can specify line colors. plot(survfit(Surv(Age,Died) ~ Rx, data = GVHDdata),lty=c(1,2),lwd=2) Thanks, John John Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics Baltimore VA Medical Center GRECC, University of Maryland School of Medicine Claude D. Pepper OAIC, University of Maryland Clinical Nutrition Research Unit, and Baltimore VA Center Stroke of Excellence University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) jsor...@grecc.umaryland.edu Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating plots with two lines, each line plotted with a different color
On Thu, May 07, 2009 at 08:00:59AM -0400, John Sorkin wrote: I would like to have the two lines generated by my plot have different colors, in addition to the two different line types specified by the plot command below. I would appreciate advice on how I can specify line colors. plot(survfit(Surv(Age,Died) ~ Rx, data = GVHDdata),lty=c(1,2),lwd=2) Try adding col=c(red,blue) as additional parameter. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 using lapply with oneway_test (coin package)
On 07/05/2009 6:11 AM, Matthieu Dubois wrote: Dear expeRts, I would like to use a oneway_test (from package coin) to test whether two groups differ on various variables. The variables are encoded within a data frame. Unfortunately, I obtained an error, that I don't understand. Could you please help me ? Example: library(coin) y - as.data.frame(matrix(rnorm(200), ncol=2)) group - as.factor(unif(100)) lapply(y, function(var) oneway_test(var ~ group)) Error message is: (in French, my locale) Erreur dans eval(expr, envir, enclos) : objet 'var' introuvable (my personal translation in English) Error in eval(expr, envir, enclos) : object 'var' not found That's a scoping problem, I think a bug in oneway_test. Because the formula var ~ group is created with the anonymous function within lapply, its environment should be the evaluation frame of that function call and var should be visible. If I replace oneway_test() with lm() it works. I think a workaround is to construct the data argument explicitly, i.e. lapply(y, function(var) oneway_test(var ~ group, data.frame(var=var, group=group))) I've cc'd Torsten Hothorn, the maintainer of coin. Duncan Murdoch Thank you, Matthieu Matthieu Dubois Post-doctoral fellow Psychology and NeuroCognition Lab (CNRS UMR 5105) Université Pierre Mendès-France BP47 --- 38040 Grenoble Cedex 9 --- France Email: matthieu.dub...@upmf-grenoble.fr Gmail: matth...@gmail.com http://web.upmf-grenoble.fr/LPNC/membre_matthieu_dubois [[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] convert large integers to hex
There is an interface between R and bc -- not on CRAN but available from its home page here: http://r-bc.googlecode.com source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;) bc(obase = 16; 123456789123456789, retclass = character) [1] 1B69B4BACD05F15 On Wed, May 6, 2009 at 9:59 PM, jim holtman jholt...@gmail.com wrote: You can use the 'bc' command (use Cygwin if on Windows); /cygdrive/c: bc bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. x=6595137340052185552 obase=16 x 5B86A277DEB9A1D0 You can call this from R. On Wed, May 6, 2009 at 3:26 PM, Sundar Dorai-Raj sdorai...@gmail.comwrote: Hi, I'm wondering if someone has solved the problem of converting very large integers to hex. I know about format.hexmode and as.hexmode, but these rely on integers. The numbers I'm working with are overflowing and losing precision. Here's an example: x - 6595137340052185552 # stored as character as.integer(x) # warning about inaccurate conversion format.hexmode(as.numeric(x)) # warnings about loss of precision as.hexmode(x) # more warnings and does not do what I expected I'm planning on writing a function that will do this, but would like to know if anybody already has a solution. Basically, I would like the functionality of format.hexmode on arbitrarily large integers. Thanks, --sundar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Show name of dataset in graph
I?ve written a script to run several multivariate statistical analysis automatically. As one result a biplot and screeplot is produced. Now I?d like to display the name of the inputdatset as part of the title of these graphics and I do not want to enter it each time I run the script. How can I extract the name of a dataset? An (shortened) extraction from the script: Test1 - function(pri, sec, Pca, Ca, Dca){ #pri - primary Parameters (biological Dataset (abundances)) #sec ? secondary Parameters #Pca, Ca, Dca ? Default=F, If set to TRUE these Methods are active ?several mathematical Operations? biplot(pri, pc.biplot=T, main=paste(?PCA - ?, ???)?. Instead of the ??? I? d like to have a variable. For example if Test1(dataset.typ5, sec.typ5, Pca=TRUE) then the title of the plots should be ?PCA ? dataset.typ5? This demonstrates the basic idea: dfr1 - data.frame(x=1:10, y=runif(10)) dfr2 - data.frame(x=11:20, y=runif(10)) library(lattice) myplot - function(dfr) { xyplot(y~x, data=dfr, main=as.character(substitute(dfr))) } myplot(dfr1) myplot(dfr2) Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PGF Device
Lasse Bombien lasse at phonetik.uni-muenchen.de writes: Am Mittwoch, den 06.05.2009, 16:08 +0200 schrieb baptiste auguie: I think the pgfSweave project on R-forge is working on this (as far as i know it currently relies on eps2pgf) Right, but eps2pgf fails me on more complex / stacked plots. Otherwise, I would be content using eps2pgf. Same for me; pgf/tikz is my method of choice for graphics in latex because it gets around the eps-detour that can cause strange problems. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] When was the package relaimpo first introduced in R?
Thanks a lot, Uwe. Do you think you could expain how one looks this type of information up? What's obvious to some of us might not be obvious to others. Dimitri, der, obviously, deutsch spricht. 2009/5/7 Uwe Ligges lig...@statistik.tu-dortmund.de: Dimitri Liakhovitski wrote: Hello! I am wondering when the package relaimpo was first introduced in R? Or maybe there is a way to look it up? I am not seeing it in the help file. The first archived version in your_CRAN_Mirror/src/contrib/Archive/relaimpo/ is dated 01-Dec-2005, obviously. Uwe Ligges -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] convert large integers to hex
Thanks for both answers. In the end I decided to use Gabor's bc package. Thanks, --sundar On Thu, May 7, 2009 at 5:10 AM, Gabor Grothendieck ggrothendi...@gmail.com wrote: There is an interface between R and bc -- not on CRAN but available from its home page here: http://r-bc.googlecode.com source(http://r-bc.googlecode.com/svn/trunk/R/bc.R;) bc(obase = 16; 123456789123456789, retclass = character) [1] 1B69B4BACD05F15 On Wed, May 6, 2009 at 9:59 PM, jim holtman jholt...@gmail.com wrote: You can use the 'bc' command (use Cygwin if on Windows); /cygdrive/c: bc bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. x=6595137340052185552 obase=16 x 5B86A277DEB9A1D0 You can call this from R. On Wed, May 6, 2009 at 3:26 PM, Sundar Dorai-Raj sdorai...@gmail.comwrote: Hi, I'm wondering if someone has solved the problem of converting very large integers to hex. I know about format.hexmode and as.hexmode, but these rely on integers. The numbers I'm working with are overflowing and losing precision. Here's an example: x - 6595137340052185552 # stored as character as.integer(x) # warning about inaccurate conversion format.hexmode(as.numeric(x)) # warnings about loss of precision as.hexmode(x) # more warnings and does not do what I expected I'm planning on writing a function that will do this, but would like to know if anybody already has a solution. Basically, I would like the functionality of format.hexmode on arbitrarily large integers. Thanks, --sundar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] When was the package relaimpo first introduced in R?
Dimitri Liakhovitski wrote: Thanks a lot, Uwe. Do you think you could expain how one looks this type of information up? What's obvious to some of us might not be obvious to others. Dimitri, der, obviously, deutsch spricht. Dimitri, on CRAN there is a package page and the link to the archives, or, on the package's page, there is a link to the particular package's archive. There you will find all CRAN versions including the dates. Beste Gruesse, Uwe 2009/5/7 Uwe Ligges lig...@statistik.tu-dortmund.de: Dimitri Liakhovitski wrote: Hello! I am wondering when the package relaimpo was first introduced in R? Or maybe there is a way to look it up? I am not seeing it in the help file. The first archived version in your_CRAN_Mirror/src/contrib/Archive/relaimpo/ is dated 01-Dec-2005, obviously. 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] PGF Device
If one was to implement a Tikz output for R graphics, I'm not sure what route to take: 1) focus exclusively on Grid graphics and implement a conversion at the R level à la gridSVG (see Paul Murrell's webpage) 2) create a new device ( I have no idea where to find guidelines for this, and I'm not even clear on what exactly a Device is). In any case, given that pdf is often the preferred output for R graphics (e.g. through the Sweave route), it seems that the pgf format would be an excellent addition if only for its perfect handling of LaTeX formulas. Best wishes, baptiste On 7 May 2009, at 14:39, Dieter Menne wrote: Lasse Bombien lasse at phonetik.uni-muenchen.de writes: Am Mittwoch, den 06.05.2009, 16:08 +0200 schrieb baptiste auguie: I think the pgfSweave project on R-forge is working on this (as far as i know it currently relies on eps2pgf) Right, but eps2pgf fails me on more complex / stacked plots. Otherwise, I would be content using eps2pgf. Same for me; pgf/tikz is my method of choice for graphics in latex because it gets around the eps-detour that can cause strange problems. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bubble Plot Over a Map
Hi everybody, Well here is another doubt! Im elaborating some maps, and I pretend to plot over it the abundance of species. I could do that using points(), but Id like to use bubble() from sp package. When trying to use bubble() I face the fallowing issue: When I call the bubble function it overwrite everything I previously plotted. It doesnt happen with points (obviously), only with bubble(). I tried to specify panel.smooth as panel function to bubble, I tried to use add=T as argument, but it didnt accept such thing. The only thing that I thought right now, so I still have to try, is saving the bubble() as an object and try to manipulate its properties over my map. I already searched the list posts but wasnt able to find a similar doubt with its possible solutions. Bellow is the map code using points, Im trying to substitute the points() functions with one bubble() function. for (i in 1:length(colnames(Spp10ml))) { png(paste(colnames(Spp10ml),'.png',sep='')[i],width=5.2,height=3.6,pointsize =5,units='in',bg=NA,restoreConsole=T,res=1200) par(mar=c(5,0,0,0)) map('worldHires','brazil',ylim=c(-5.15,-4.55),xlim=c(-37,-36.1),type='n') rect(-37.1,-5.25,-36,-4.9,density=NULL,angle=45,col='#dbf4ff',border=F) plot(Batimetria,ylab='',xlab='',border=F,col=Cor$Cor,add=T) plot(Municipios,ylab='',xlab='',col=rgb(245,232,140,max=255,alpha=255),add=T ,lwd=0.2) axis(1,xaxp=c(-37,-36.1,5),cex.axis=1.5) axis(2,yaxp=c(-5.15,-4.55,5),cex.axis=1.5) text(Prof$Long,Prof$Lat,rownames(Prof),col='black',cex=1.2,srt=-24,family='A R',font=2) text(c(-36.96,-36.96,-36.865,-36.54,-36.37,-36.2),c(-4.96,-5.05,-5.11,-5.14, -5.14,-5.14),c('Areia Branca','Serra do Mel','Porto do Mangue','Macau','Guamaré','Galinhos'),col='Black',cex=1.3,font=2) rect(-36.20,-4.56,-36.155,-4.565,density=NULL,angle=45,col='black',border='b lack',lwd=0.1) rect(-36.155,-4.56,-36.111,-4.565,density=NULL,angle=45,col='white',border=' black',lwd=0.1) shadowtext(c(-36.20,-36.155,-36.111,-36.215),c(-4.573,-4.573,-4.573,-4.562), c('0','5','10','km'),col='white',cex=1) Norte(-36.155,-4.60,0.02) box(which='plot',lty='solid') points(Pontos$long[Spp10ml[,i]0 Spp10ml[,i]=50],Pontos$lat[Spp10ml[,i]0 Spp10ml[,i]=50],pch=21,bg=rgb(70,70,70,max=255,alpha=255),col= 'black',cex=1.5) points(Pontos$long[Spp10ml[,i]=51 Spp10ml[,i]=200],Pontos$lat[Spp10ml[,i]=51 Spp10ml[,i]=200],pch=23,bg='yellow',col='black',cex=1.5) points(Pontos$long[Spp10ml[,i]=201 Spp10ml[,i]=400],Pontos$lat[Spp10ml[,i]=201 Spp10ml[,i]=400],pch=22,bg='orange',col='black',cex=1.5) points(Pontos$long[Spp10ml[,i]=401],Pontos$lat[Spp10ml[,i]=401],pch=24,bg= 'red',col='black',cex=1.5) dev.off()} Thanks in advance. - MSc. mailto:r.alui...@gmail.com Rodrigo Aluizio Centro de Estudos do Mar/UFPR Laboratório de Micropaleontologia Avenida Beira Mar s/n - CEP 83255-000 Pontal do Paraná - PR - Brasil [[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] When was the package relaimpo first introduced in R?
Vielen Dank, Uwe! Dimitri 2009/5/7 Uwe Ligges lig...@statistik.tu-dortmund.de: Dimitri Liakhovitski wrote: Thanks a lot, Uwe. Do you think you could expain how one looks this type of information up? What's obvious to some of us might not be obvious to others. Dimitri, der, obviously, deutsch spricht. Dimitri, on CRAN there is a package page and the link to the archives, or, on the package's page, there is a link to the particular package's archive. There you will find all CRAN versions including the dates. Beste Gruesse, Uwe 2009/5/7 Uwe Ligges lig...@statistik.tu-dortmund.de: Dimitri Liakhovitski wrote: Hello! I am wondering when the package relaimpo was first introduced in R? Or maybe there is a way to look it up? I am not seeing it in the help file. The first archived version in your_CRAN_Mirror/src/contrib/Archive/relaimpo/ is dated 01-Dec-2005, obviously. Uwe Ligges -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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] RSPerl and Statistics::R
Greetings! Being a Perl hacker for some time, and wanting to leverage what R provides, I've been trying to work with Statistics::R and RSPerl. The former has a race condition that breeds some unreliability and the latter seems to have issues all around, and neither has been updated in some time. Are these projects are abandoned, or is there some effort currently being undertaken to either refresh or reinvent the glue binding Perl and R together? If not, then I'm probably going to give it a go myself, but I'm sort of hoping that there's a jewel of a library out there that doesn't come up as quickly in Google as the aforementioned libraries. Thanks, Daniel M. Klein This email (including attachments and files, if any) is confidential, may be privileged and is intended for the above-named recipient(s) only. If you have received this message in error, please notify me by return email and delete this message from your system. Any unauthorized use or disclosure of this message is strictly prohibited. Copyright in this email and any document created by Genesis Genomics will be and remain vested in us and will not be transferred to you. [[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] extending strsplit to handle missing text that doesn't have the target on which to split
I am sure there is an obvious answer to this that I'm missing but I can't find it. I'm parsing headers of Emails and most have a date like this: Wed, 16 Nov 2005 05:28:00 -0800 and I can parse that using: tmp.dat.data - matrix(unlist(strsplit(headers$Date.line,,)), ncol = 2, byrow = TRUE) before going on to look at the day and date/time data. However, a very few headers I want to parse are missing the initial day of the week and look like this: 15 Nov 2005 09:10:00 +0100 That means that my use of strsplit() results in that date/time part being all of the item in the list for those entries so the effect of matrix(unlist()) is to pull the next list entry up in the matrix. Because I happened to have only two errant entries I didn't see what was happening for a moment. (An odd number gives a warning message about dimensions not fitting but an odd number has silently moved things up/left so doesn't: no quarrel with that from me, my stupidity that I was slow to see what was happening!) I'm sure I should be able to find a simple way to get around this but at the moment I can't. Here's a simple, reproducible example: dat - c(Tue, 15 Nov 2005 09:44:50 EST, 15 Nov 2005 09:10:00 +0100, Tue, 15 Nov 2005 09:44:50 EST, Tue, 15 Nov 2005 16:29:57 +, Wed, 16 Nov 2005 07:00:45 EST, Wed, 16 Nov 2005 05:28:00 -0800, Wed, 16 Nov 2005 14:06:21 +, 15 Nov 2005 09:10:00 +0100) tmp.dat.data - matrix(unlist(strsplit(dat,,)),ncol = 2, byrow = TRUE) tmp.dat.data comes out as a 7x2 matrix contents: [,1] [,2] [1,] Tue 15 Nov 2005 09:44:50 EST [2,] 15 Nov 2005 09:10:00 +0100 Tue [3,] 15 Nov 2005 09:44:50 EST Tue [4,] 15 Nov 2005 16:29:57 + Wed [5,] 16 Nov 2005 07:00:45 EST Wed [6,] 16 Nov 2005 05:28:00 -0800 Wed [7,] 16 Nov 2005 14:06:21 + 15 Nov 2005 09:10:00 +0100 I'd like an 8x2 matrix with tmp.dat.data[2,1] == and tmp.dat.data[8,1] == I'm sure there must be a simple way to achieve this by rolling a slightly different variant of strsplit that pads things and then applying that to the input vector but I'm failing to see how to do this at the moment. TIA, Chris -- Applied researcher, neither statistician nor programmer! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 call time series functions from C ?
Hi everyone, I meet the problem to call R from C. Can someone tell me is it possible to call time series functions(such as ar and arima)from C program on linux platform, and then compile the C program to a standalone executable file? I know we can call some function defined in Rmath.h , but I have not found the entry point for time series function. I would very much appreciate receiving your response ! ^_^ bin, dong goo...@126.com Buaa, Beijing PR China [[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] Show name of dataset in graph
The usual way of doing this in R functions is via deparse, as in the examples in ?deparse: fd-function(x) plot(x, main=deparse(substitute(x))) q-1:10 fd(q) as.character works for simple cases but is probably not the best option. Compare fd(log(q)) with fc-function(x) plot(x, main=as.character(substitute(x))) fc(log(q)) In the case of an expression, substitute returns a 'call' object, and applying as.character to that returns the individual elements of the call (log and q in this case) and that is plotted as a multi-line string. deparse() returns a the character string log(q) which is what you normally want. Steve E richard.cot...@hsl.gov.uk 07/05/2009 13:26:46 I?ve written a script to run several multivariate statistical analysis automatically. As one result a biplot and screeplot is produced. Now I?d like to display the name of the inputdatset as part of the title of these graphics and I do not want to enter it each time I run the script. How can I extract the name of a dataset? An (shortened) extraction from the script: Test1 - function(pri, sec, Pca, Ca, Dca){ #pri - primary Parameters (biological Dataset (abundances)) #sec ? secondary Parameters #Pca, Ca, Dca ? Default=F, If set to TRUE these Methods are active ?several mathematical Operations? biplot(pri, pc.biplot=T, main=paste(?PCA - ?, ???)?. Instead of the ??? I? d like to have a variable. For example if Test1(dataset.typ5, sec.typ5, Pca=TRUE) then the title of the plots should be ?PCA ? dataset.typ5? This demonstrates the basic idea: dfr1 - data.frame(x=1:10, y=runif(10)) dfr2 - data.frame(x=11:20, y=runif(10)) library(lattice) myplot - function(dfr) { xyplot(y~x, data=dfr, main=as.character(substitute(dfr))) } myplot(dfr1) myplot(dfr2) Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential\ infor...{{dropped:19}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Step and stepAIC
Hi all,  Iâm using step and stepAIC for stepwise regression. After each step, I would like to make an additional calculation based on the independent variables that have been selected until this step and their corresponding weights. Where do I have to add this calculation?  And a second question: Is it possible, to define a certain limit of factors for the regression, e.g. 20 variables are available but I want step to stop after the 10th factor has been selected?!  Thanks in advance  Peter-Heinz [[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] Print to File Formatting
Brigid Mooney wrote: Hello, I am writing out to a file and have two quick questions that I can't seem to track down the correct answers for. Luckily, I *think* they are both simple enough that someone might be able to point me in the right direction on them without too much trouble. Both questions relate to the process below where CompleteFrame is a data frame containing what I want printed to a file. filename - C:\\MyDocuments\\TestOut_050609.txt output -file(filename, open=wt) write.csv(CompleteFrame, output, row.names = FALSE, col.names=FALSE) close(output) Question #1: Every time I run this process, I get the warning: Warning message: In write.csv(CompleteFrame, output, row.names = FALSE, col.names = FALSE) : attempt to set 'col.names' ignored And it still prints the column names as the first row in my file, which I do not want... Question #2: This process puts quotes around all data of class = character. I can't have these quotes in my file - is it possible to get R to omit them even if my data frame contains character strings? Any help or hints on this are greatly appreciated! Thanks, Brigid __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Hi Brigid, Re. Question 1: This is simply due to a convention about csv files. In order to ensure conformity of the output file, write.csv() doesn't allow users to change col.names. Re. Question 2: The quote argument is what you should be modifying. If you really want no column names, use write.table() instead (with sep=, and a filename with a .csv extension). After all, write.csv() is merely a wrapper for write.table(). Cheers, -- *Luc Villandré* /Biostatistician McGill University Health Center - Montreal Children's Hospital Research Institute/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 call time series functions from C ?
On 5/7/2009 9:24 AM, goon83 wrote: Hi everyone, I meet the problem to call R from C. Can someone tell me is it possible to call time series functions(such as ar and arima)from C program on linux platform, and then compile the C program to a standalone executable file? I know we can call some function defined in Rmath.h , but I have not found the entry point for time series function. There are none, but you can write a front end for R, and it can evaluate R expressions, etc. The procedure is described in the Writing R Extensions manual. Remember that if you distribute the program you do need to follow the GPL, and distribute all of R as well as all of your own program in source code form. Duncan Murdoch I would very much appreciate receiving your response ! ^_^ bin, dong goo...@126.com Buaa, Beijing PR China [[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] Plotting counts vs. intervals for a shingle
Hello! Suppose I have a set of values: a - c(1:10, 5:10) Suppose I also have a set of intervals: b - cbind(c(0,2.5,4.5,6.5), c(5.5,7.5,9.5,11)) I can create a shingle that counts how many values are in each interval: c - shingle(a, b) I can display the shingle to see the counts: summary(c, showValues=FALSE) The display looks like this: Intervals: min max count 1 0.0 5.5 6 2 2.5 7.5 8 3 4.5 9.510 4 6.5 11.0 8 Overlap between adjacent intervals: [1] 4 6 6 I would like to plot the count vs. the Intervals I can create a vector representing the intervals: labels - as.character(levels(c)) But I can't seem to create a vector of counts, which would permit me to plot counts vs. intervals. Thanks for any insights you can provide. p.s. My real data contains 25,094 values and 5,809 intervals. Many of the intervals will not contain any of the values. -Douglas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] data transformation using gamma
Roslina, this code performs what you need: dt = matrix((1:(58*12))/58/12,58) # some numbers # if dt is a data.frame use dt = as.matrix(dt) a = (1:12)/12 # some a coef b = (12:1)/12 # some b coef dtgam = matrix(pgamma(dt,a,b),58) # dtgam is the transformation you're looking for no loop needed no transform function involved cheers, Patrizio 2009/5/7 Roslina Zakaria zrosl...@yahoo.com: Hi R-users, I have this code to uniformise the data using gamma: length(dp1) [1] 696 dim(dp1) [1] 58 12 dim(ahall) [1] 1 12 dim(bhall) [1] 1 12 trans_dt - function(dt,a,b) + { n1 - ncol(dt) + n2 - length(dt) + trans - vector(mode='numeric', length=n2) + dim(trans) - dim(dt) + for (i in 1:n1) + { dt[,i] - as.vector(dt[,i]) + trans[,i] - transform(dti,newdt=pgamma(dti,shape= a[1,i],scale=b[1,i])) } + trans + } trans_dt(dp1,ahall,bhall) Error in transform(dti, newdt = pgamma(dti, shape = a[1, i], scale = b[1, : object dti not found and also try trans_dt - function(dt,a,b) { n1 - ncol(dt) n2 - length(dt) trans - vector(mode='numeric', length=n2) dim(trans) - dim(dt) for (i in 1:n1) { dti - dt[,i] ai - a[1,i] bi - b[1,i] trans[,i] - transform(dti,newdt=pgamma(dti,shape= ai,scale=bi)) } trans } trans_dt(dp1,ahall,bhall) Error in pgamma(dti, shape = ai, scale = bi) : object dti not found Thank you for any help given. [[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. -- +- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frede...@unimore.it +- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Generating plots with two lines, each line plotted with a different color
On Thu, 7 May 2009, John Sorkin wrote: R 2.9.0 windows xp I would like to have the two lines generated by my plot have different colors, in addition to the two different line types specified by the plot command below. I would appreciate advice on how I can specify line colors. plot(survfit(Surv(Age,Died) ~ Rx, data = GVHDdata),lty=c(1,2),lwd=2) ,col=c(tomato,goldenrod) -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] Step and stepAIC
Peter-Heinz Fox peterheinzfox at yahoo.de writes: Iâm using step and stepAIC for stepwise regression. After each step, I would like to make an additional calculation based on the independent variables that have been selected until this step and their corresponding weights. Where do I have to add this calculation? dropTerm is the toolbox function stepAIC uses; you could use it to build your own stepAIC version. But also make sure you have read http://markmail.org/thread/gk7ysg6tclz4vtdi and consider some lasso variant method instead (this partly answers your second question). Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 using lapply with oneway_test (coin package)
That's a scoping problem, I think a bug in oneway_test. Because the formula var ~ group is created with the anonymous function within lapply, its environment should be the evaluation frame of that function call and var should be visible. If I replace oneway_test() with lm() it works. I think a workaround is to construct the data argument explicitly, i.e. lapply(y, function(var) oneway_test(var ~ group, data.frame(var=var, group=group))) yes, that would be the fix: R lapply(y, function(var) oneway_test(var ~ group, data = data.frame(var = var, group = group))) $V1 Asymptotic 2-Sample Permutation Test data: var by group (1, 2) Z = -1.2054, p-value = 0.2280 alternative hypothesis: true mu is not equal to 0 $V2 Asymptotic 2-Sample Permutation Test data: var by group (1, 2) Z = 0.5672, p-value = 0.5706 alternative hypothesis: true mu is not equal to 0 Thanks, Duncan. Torsten I've cc'd Torsten Hothorn, the maintainer of coin. Duncan Murdoch Thank you, Matthieu Matthieu Dubois Post-doctoral fellow Psychology and NeuroCognition Lab (CNRS UMR 5105) Université Pierre Mendès-France BP47 --- 38040 Grenoble Cedex 9 --- France Email: matthieu.dub...@upmf-grenoble.fr Gmail: matth...@gmail.com http://web.upmf-grenoble.fr/LPNC/membre_matthieu_dubois [[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] Bubble Plot Over a Map
Hi Rodrigo, did you consider having a look at package ggplot2 (thanks to Hadley Wickham). I guess you'll find something very close to your need (functions ggplot, geom_point,...) Hope this helps. regards. Olivier Rodrigo Aluizio wrote: Hi everybody, Well here is another doubt! Im elaborating some maps, and I pretend to plot over it the abundance of species. I could do that using points(), but Id like to use bubble() from sp package. When trying to use bubble() I face the fallowing issue: When I call the bubble function it overwrite everything I previously plotted. It doesnt happen with points (obviously), only with bubble(). I tried to specify panel.smooth as panel function to bubble, I tried to use add=T as argument, but it didnt accept such thing. The only thing that I thought right now, so I still have to try, is saving the bubble() as an object and try to manipulate its properties over my map. I already searched the list posts but wasnt able to find a similar doubt with its possible solutions. Bellow is the map code using points, Im trying to substitute the points() functions with one bubble() function. for (i in 1:length(colnames(Spp10ml))) { png(paste(colnames(Spp10ml),'.png',sep='')[i],width=5.2,height=3.6,pointsize =5,units='in',bg=NA,restoreConsole=T,res=1200) par(mar=c(5,0,0,0)) map('worldHires','brazil',ylim=c(-5.15,-4.55),xlim=c(-37,-36.1),type='n') rect(-37.1,-5.25,-36,-4.9,density=NULL,angle=45,col='#dbf4ff',border=F) plot(Batimetria,ylab='',xlab='',border=F,col=Cor$Cor,add=T) plot(Municipios,ylab='',xlab='',col=rgb(245,232,140,max=255,alpha=255),add=T ,lwd=0.2) axis(1,xaxp=c(-37,-36.1,5),cex.axis=1.5) axis(2,yaxp=c(-5.15,-4.55,5),cex.axis=1.5) text(Prof$Long,Prof$Lat,rownames(Prof),col='black',cex=1.2,srt=-24,family='A R',font=2) text(c(-36.96,-36.96,-36.865,-36.54,-36.37,-36.2),c(-4.96,-5.05,-5.11,-5.14, -5.14,-5.14),c('Areia Branca','Serra do Mel','Porto do Mangue','Macau','Guamaré','Galinhos'),col='Black',cex=1.3,font=2) rect(-36.20,-4.56,-36.155,-4.565,density=NULL,angle=45,col='black',border='b lack',lwd=0.1) rect(-36.155,-4.56,-36.111,-4.565,density=NULL,angle=45,col='white',border=' black',lwd=0.1) shadowtext(c(-36.20,-36.155,-36.111,-36.215),c(-4.573,-4.573,-4.573,-4.562), c('0','5','10','km'),col='white',cex=1) Norte(-36.155,-4.60,0.02) box(which='plot',lty='solid') points(Pontos$long[Spp10ml[,i]0 Spp10ml[,i]=50],Pontos$lat[Spp10ml[,i]0 Spp10ml[,i]=50],pch=21,bg=rgb(70,70,70,max=255,alpha=255),col= 'black',cex=1.5) points(Pontos$long[Spp10ml[,i]=51 Spp10ml[,i]=200],Pontos$lat[Spp10ml[,i]=51 Spp10ml[,i]=200],pch=23,bg='yellow',col='black',cex=1.5) points(Pontos$long[Spp10ml[,i]=201 Spp10ml[,i]=400],Pontos$lat[Spp10ml[,i]=201 Spp10ml[,i]=400],pch=22,bg='orange',col='black',cex=1.5) points(Pontos$long[Spp10ml[,i]=401],Pontos$lat[Spp10ml[,i]=401],pch=24,bg= 'red',col='black',cex=1.5) dev.off()} Thanks in advance. - MSc. mailto:r.alui...@gmail.com Rodrigo Aluizio Centro de Estudos do Mar/UFPR Laboratório de Micropaleontologia Avenida Beira Mar s/n - CEP 83255-000 Pontal do Paraná - PR - Brasil [[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. -- View this message in context: http://www.nabble.com/Bubble-Plot-Over-a-Map-tp23426635p23428390.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] A potential bug for paste() ?
Hi, everyone, Try the following command to see if you get TRUE or FALSE. I get FALSE on a unix platform but TRUE on Windows. Any comment? all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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 call time series functions from C ?
hi Duncan, tks for you response, it's depressed to know that i can not use time series of R to finish my study. I really think R is powerfull, i used it to finish all my statistic homework last year^_^. but i still wonder can i use the function of time series in the embedded way of C code. Can you give me some suggestion about how to use time series of R in C code? tks bin dong goo...@126.com Buaa, Beijing PR China ÔÚ2009-05-07?21:51:13£¬Duncan?Murdoch?murd...@stats.uwo.ca?дµÀ£º On?5/7/2009?9:24?AM,?goon83?wrote: ?Hi?everyone, ???I?meet?the?problem?to?call?R?from?C.? ?? ???Can?someone?tell?me?is?it?possible?to?call?time?series?functions(such?as?ar?and?arima)from??C?program?on?linux?platform,?and?then?compile?the?C?program?to?a?standalone?executable?file? ? ???I?know?we?can?call?some?function?defined?in?Rmath.h?,?but?I?have?not?found?the?entry?point?for?time?series?function.? There?are?none,?but?you?can?write?a?front?end?for?R,?and?it?can?evaluate? R?expressions,?etc.??The?procedure?is?described?in?the?Writing?R? Extensions?manual. Remember?that?if?you?distribute?the?program?you?do?need?to?follow?the? GPL,?and?distribute?all?of?R?as?well?as?all?of?your?own?program?in? source?code?form. Duncan?Murdoch ?? ???I?would?very?much?appreciate?receiving?your?response?!?^_^ ? ? ?bin,?dong ?goo...@126.com ?Buaa,?Beijing?PR?China ? ??? ? ? [[alternative?HTML?version?deleted]] ? ?__ ?r-h...@r-project.org?mailing?list ?https://stat.ethz.ch/mailman/listinfo/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] A potential bug for paste() ?
It probably has less to do with paste() than with Theoph, but since we have no idea what that might be, it's hard to tell. See the bit about reproducible example, please. Sarah On Thu, May 7, 2009 at 10:38 AM, Jun Shen jun.shen...@gmail.com wrote: Hi, everyone, Try the following command to see if you get TRUE or FALSE. I get FALSE on a unix platform but TRUE on Windows. Any comment? all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) -- 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] PGF Device
I can only second Dieter and Baptiste. Am Donnerstag, den 07.05.2009, 14:57 +0200 schrieb baptiste auguie: If one was to implement a Tikz output for R graphics, I'm not sure what route to take: 1) focus exclusively on Grid graphics and implement a conversion at the R level à la gridSVG (see Paul Murrell's webpage) 2) create a new device ( I have no idea where to find guidelines for this, and I'm not even clear on what exactly a Device is). In any case, given that pdf is often the preferred output for R graphics (e.g. through the Sweave route), it seems that the pgf format would be an excellent addition if only for its perfect handling of LaTeX formulas. Best wishes, baptiste On 7 May 2009, at 14:39, Dieter Menne wrote: Lasse Bombien lasse at phonetik.uni-muenchen.de writes: Am Mittwoch, den 06.05.2009, 16:08 +0200 schrieb baptiste auguie: I think the pgfSweave project on R-forge is working on this (as far as i know it currently relies on eps2pgf) Right, but eps2pgf fails me on more complex / stacked plots. Otherwise, I would be content using eps2pgf. Same for me; pgf/tikz is my method of choice for graphics in latex because it gets around the eps-detour that can cause strange problems. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Lasse Bombien Institut für Phonetik und Sprachverarbeitung Schellingstraße 3/II D-80799 München email: la...@phonetik.uni-muenchen.de web: http://www.phonetik.uni-muenchen.de/~lasse phone: +49 (0) 89 2180 2812 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 call time series functions from C ?
On 5/7/2009 10:55 AM, goon83 wrote: hi Duncan, tks for you response, it's depressed to know that i can not use time series of R to finish my study. I really think R is powerfull, i used it to finish all my statistic homework last year^_^. but i still wonder can i use the function of time series in the embedded way of C code. Can you give me some suggestion about how to use time series of R in C code? I did, in the previous message. Duncan Murdoch tks bin dong goo...@126.com Buaa, Beijing PR China ??2009-05-07?21:51:13??Duncan?Murdoch?murd...@stats.uwo.ca??? On?5/7/2009?9:24?AM,?goon83?wrote: ?Hi?everyone, ???I?meet?the?problem?to?call?R?from?C.? ?? ???Can?someone?tell?me?is?it?possible?to?call?time?series?functions(such?as?ar?and?arima)from??C?program?on?linux?platform,?and?then?compile?the?C?program?to?a?standalone?executable?file? ? ???I?know?we?can?call?some?function?defined?in?Rmath.h?,?but?I?have?not?found?the?entry?point?for?time?series?function.? There?are?none,?but?you?can?write?a?front?end?for?R,?and?it?can?evaluate? R?expressions,?etc.??The?procedure?is?described?in?the?Writing?R? Extensions?manual. Remember?that?if?you?distribute?the?program?you?do?need?to?follow?the? GPL,?and?distribute?all?of?R?as?well?as?all?of?your?own?program?in? source?code?form. Duncan?Murdoch ?? ???I?would?very?much?appreciate?receiving?your?response?!?^_^ ? ? ?bin,?dong ?goo...@126.com ?Buaa,?Beijing?PR?China ? ??? ? ? [[alternative?HTML?version?deleted]] ? ?__ ?r-h...@r-project.org?mailing?list ?https://stat.ethz.ch/mailman/listinfo/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] Linear least squares fit with errors in both x and y values.
Hi, I'd like to perform a weighted linear least squares fit with R on data with varying errors on both vectors. I can do this with one axis using lm, but have no idea where to go from here. I've tried googling, but no idea. Any suggestions? I'm also trying to plot these errors on a graph. Again I can see how to do it for one set of data but not the other. Thanks, James __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Step and stepAIC
I also wonder if stepAIC can work with an lme model. I tried. it doesn't for now. Appreciate any comment. Jun On Thu, May 7, 2009 at 9:15 AM, Dieter Menne dieter.me...@menne-biomed.dewrote: Peter-Heinz Fox peterheinzfox at yahoo.de writes: Iâm using step and stepAIC for stepwise regression. After each step, I would like to make an additional calculation based on the independent variables that have been selected until this step and their corresponding weights. Where do I have to add this calculation? dropTerm is the toolbox function stepAIC uses; you could use it to build your own stepAIC version. But also make sure you have read http://markmail.org/thread/gk7ysg6tclz4vtdi and consider some lasso variant method instead (this partly answers your second question). Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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 call time series functions from C ?
Hi Duncan, Sorry, i miss the informatin in the previous message, you said that i can write a front end to call , does the front end can be implemented by c, and i can compile the c code to a standalone program. i will appreiciate for more detail information tks? ? ?bin?dong? ?goo...@126.com ?Buaa,?Beijing?PR?China ÔÚ2009-05-07?23:05:47£¬Duncan?Murdoch?murd...@stats.uwo.ca?дµÀ£º On?5/7/2009?10:55?AM,?goon83?wrote: ?hi?Duncan, ?? ?tks?for?you?response,?it's?depressed?to?know?that?i?can?not?use?time?series?of?R?to?finish?my?study. ?? ?I?really?think?R?is?powerfull,?i?used?it?to?finish?all?my?statistic?homework?last?year^_^. ?? ?but?i?still?wonder?can?i?use?the?function?of?time?series?in?the?embedded?way?of?C?code. ?? ?? ?Can?you?give?me?some?suggestion?about?how?to?use?time?series?of?R?in?C?code? I?did,?in?the?previous?message. Duncan?Murdoch ?? ?? ?? ?tks? ?? ? ?bin?dong? ?goo...@126.com ?Buaa,?Beijing?PR?China ?? ?? ? ? ?? ? ? ?ÔÚ2009-05-07?21:51:13£¬Duncan?Murdoch?murd...@stats.uwo.ca?дµÀ£º On?5/7/2009?9:24?AM,?goon83?wrote: ?Hi?everyone, ???I?meet?the?problem?to?call?R?from?C.? ?? ???Can?someone?tell?me?is?it?possible?to?call?time?series?functions(such?as?ar?and?arima)from??C?program?on?linux?platform,?and?then?compile?the?C?program?to?a?standalone?executable?file? ? ???I?know?we?can?call?some?function?defined?in?Rmath.h?,?but?I?have?not?found?the?entry?point?for?time?series?function.? There?are?none,?but?you?can?write?a?front?end?for?R,?and?it?can?evaluate? R?expressions,?etc.??The?procedure?is?described?in?the?Writing?R? Extensions?manual. Remember?that?if?you?distribute?the?program?you?do?need?to?follow?the? GPL,?and?distribute?all?of?R?as?well?as?all?of?your?own?program?in? source?code?form. Duncan?Murdoch ?? ???I?would?very?much?appreciate?receiving?your?response?!?^_^ ? ? ?bin,?dong ?goo...@126.com ?Buaa,?Beijing?PR?China ? ??? ? ? [[alternative?HTML?version?deleted]] ? ?__ ?r-h...@r-project.org?mailing?list ?https://stat.ethz.ch/mailman/listinfo/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] Bumps chart in R
Thank you Thierry! That was very helpfull I have added geom_point which makes the lineending look more round. Also - since the chart becomes verye clustered I also added text to the right. like so: ggplot(df, aes(x = tal, y = value, label = text, group = text, size = size, col = Change))+ geom_line()+ geom_text(data = subset(df, tal==tal1),size=3, hjust=1, vjust=0)+ geom_text(data = subset(df, tal==tal2),hjust=-1, size=3)+ geom_point() + scale_x_discrete(Change from time to time) + scale_y_continuous(Points) + theme_bw()+ opts(legend.position=none)+ opts(title=As time went by)+ opts(plot.title=theme_text(vjust=0,size=20))+ scale_colour_manual(values = c(red, black, blue)) Thanks for all your help! On Thu, May 7, 2009 at 1:17 PM, ONKELINX, Thierry thierry.onkel...@inbo.be wrote: Dear Andreas and Mike, You need to use scale_colour_manual() if you want to set the colours yourself. Ggplot2 interpretes the col variable in the dataset as an ordinairy factor. library(ggplot2) df0 - data.frame(text = letters[1:21], tal1 = c(rnorm (20,5,2), 5), tal2 = c(rnorm (20,6,3), 5)) df0$dif - df0$tal2 - df0$tal1 df - melt(data = df0, id.vars = c('text', 'dif'), variable_name = 'tal') df$Change - factor(ifelse(df$dif0,'Up',ifelse(df$dif0,'Down','Stable')), levels = c(Up, Stable, Down)) df$size - abs(df$dif) ggplot(df, aes(x = tal, y = value, label = text, group = text, size = size, col = Change)) + geom_line() + geom_text(data = subset(df, tal==tal1), size=3, hjust=2, vjust=0) + scale_x_discrete(Change from time to time) + scale_y_continuous(Points) + theme_bw()+ opts(legend.position=none)+ opts(title=As time went by\n) +opts(plot.title=theme_text(vjust=0,size=20)) + scale_colour_manual(values = c(red, black, blue)) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Andreas Christoffersen Verzonden: donderdag 7 mei 2009 12:22 Aan: Mike Lawrence; r-help@r-project.org; ggpl...@googlegroups.com Onderwerp: Re: [R] Bumps chart in R On Thu, May 7, 2009 at 2:15 AM, Mike Lawrence mike.lawre...@dal.ca wrote: (cross posting to the ggplot2 group for posterity) Here's how I'd approach it: library(ggplot2) text = letters[1:20] tal1 = rnorm (20,5,2) tal2 = rnorm (20,6,3) dif = tal2-tal1 df0 = data.frame(text,tal1,tal2) df = melt( data = df0 , id.vars = 'text' , variable_name = 'tal' ) df$dif = dif df$col = ifelse(dif0,'red',ifelse(dif0,'blue','black')) df$size = abs(dif) # draw the plot Unfortunately it's not perfect: (1) col isn't being interpreted literally, so instead of truly red blue. (2) the lines ends are square whereas usually they're rounded. (3) attempting to remove the legend via opts(legend.position=none) seems to fail. Thank you with your melted data I was able to come very close to what I want. legen.posistion=none works for me... Annonying that colours don't work like expected... It seams to be a frequent concern. My code: qplot(tal,value,data=df,group=text,geom=line,size=size,colour=col,xlab=Change from time to time, ylab = Points)+ geom_text(aes(label=text),subset(df,tal==tal1),size=3,hjust=2,vjust=0)+ theme_bw()+ opts(legend.position=none)+ opts(title=As time went by) +opts(plot.title=theme_text(vjust=0,size=20)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list
Re: [R] How to call time series functions from C ?
you have a couple of options. If you require specific R functions to do what you want, then you will need to call R from C. I believe that Dirk has been working on an RInside package that does this. Alternatively, you can use my tslib package, which is a general time series library written in c++. It's public interface in R, is the fts package, which just wraps the c++ library to R functions. sources are available here: http://github.com/armstrtw/tslib/tree/master http://github.com/armstrtw/fts/tree/master If you want to try out tslib, feel free to contact me off list for help. -Whit 2009/5/7 Duncan Murdoch murd...@stats.uwo.ca: On 5/7/2009 10:55 AM, goon83 wrote: hi Duncan, tks for you response, it's depressed to know that i can not use time series of R to finish my study. I really think R is powerfull, i used it to finish all my statistic homework last year^_^. but i still wonder can i use the function of time series in the embedded way of C code. Can you give me some suggestion about how to use time series of R in C code? I did, in the previous message. Duncan Murdoch tks bin dong goo...@126.com Buaa, Beijing PR China 在2009-05-07?21:51:13,Duncan?Murdoch?murd...@stats.uwo.ca?写道: On?5/7/2009?9:24?AM,?goon83?wrote: ?Hi?everyone, ???I?meet?the?problem?to?call?R?from?C.? ?? ???Can?someone?tell?me?is?it?possible?to?call?time?series?functions(such?as?ar?and?arima)from??C?program?on?linux?platform,?and?then?compile?the?C?program?to?a?standalone?executable?file? ? ???I?know?we?can?call?some?function?defined?in?Rmath.h?,?but?I?have?not?found?the?entry?point?for?time?series?function.? There?are?none,?but?you?can?write?a?front?end?for?R,?and?it?can?evaluate? R?expressions,?etc.??The?procedure?is?described?in?the?Writing?R? Extensions?manual. Remember?that?if?you?distribute?the?program?you?do?need?to?follow?the? GPL,?and?distribute?all?of?R?as?well?as?all?of?your?own?program?in? source?code?form. Duncan?Murdoch ?? ???I?would?very?much?appreciate?receiving?your?response?!?^_^ ? ? ?bin,?dong ?goo...@126.com ?Buaa,?Beijing?PR?China ? ??? ? ? [[alternative?HTML?version?deleted]] ? ?__ ?r-h...@r-project.org?mailing?list ?https://stat.ethz.ch/mailman/listinfo/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.
[R] Draw a random number about the fitting of a glm model using family=quasi
Hi, I desire to draw a random number about the fitting of a glm model using a quasi linear error distribution. For example, if my family is poisson, then this is what I want: model1 = glm(amount~days,family=poisson(link=log),data=dataset1) mean1 = predict(model1,newdata =data.frame(days=time),type=response) rpois(length(mean1),mean1) But I wish to change my model to: model2 = glm(amount~days,family=quasi(link=log, variance=mu),data=dataset2) mean2 = predict(model2,newdata =data.frame(days=time),type=response) Is there a way to draw a random number about the mean when I have a quasi-linear error distribution? Thanks. -- View this message in context: http://www.nabble.com/Draw-a-random-number-about-the-fitting-of-a-glm-model-using-family%3Dquasi-tp23427875p23427875.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] Linear least squares fit with errors in both x and y values.
HI, I'd like to perform a weighted linear least squares fit with R on data with varying errors on both vectors. I can do this with one axis using lm, but have no idea where to go from here. I've tried googling, but no idea. Any suggestions? Thanks, James __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 save independent R sessions in BATCH mode???
Hi guys, I already have put this question some time ago however replies were not straight to the problem. Even so thanks a lot for the answers! I reformulate the problem. I have a script file with the following commands: for (i in 1:300) - open session -- load(X_i.rdata) - perform some calcules -- ( ) - save session -- save.image(Y_i.rdata) end for The problem here is that, I cannot save.image and begin a new clean session. An hypothesis could be to delete all R objects after the save.image, but this does not seem too efficient to perform. What should I do to begin a R clean session in the same batch processing? Are there any other suggestion on this? Thanks in advance, Diogo André Alagador __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with lme4 model specification
Thanks! I made this correction ONKELINX, Thierry wrote: Please note that the case of characters is important in R. Hence True differs from TRUE. You need to use REML = TRUE instead of REML = True! The only valid logical values are TRUE, FALSE, T and F. But I recommend to use only TRUE and FALSE. Because you can overwrite T and F. You could do something like T - FALSE, which is ofcourse not a good idea. TRUE and FALSE can not be overwritten. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens boeinguy2 Verzonden: donderdag 7 mei 2009 0:21 Aan: r-help@r-project.org Onderwerp: [R] Help with lme4 model specification I am new to R and am trying to specify a model for mixed model analysis. When I run the following model I get an error: AAT- lmer(Y ~ S + A + (1|S:A/H), data=AT, REML=True) The error looks like this: Error in Spar_loc:`:` : NA/NaN argument In addition: Warning messages: 1: In model.matrix.default(mt, mf, contrasts) : variable 'Spar_loc' converted to a factor 2: In Spar_loc:`:` : numerical expression has 720 elements: only the first used I am having trouble specifying th random component. It should reflect the random term as H nested within the interaction of S A. What am I doing wrong? :confused: -- View this message in context: http://www.nabble.com/Help-with-lme4-model-specification-tp23415908p2341 5908.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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 this message in context: http://www.nabble.com/Help-with-lme4-model-specification-tp23415908p23428528.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] compiling 64 bit JRI.dll with 64bit XP
Hi all, I was able to run my Java-R program using a 32-bit jdk on my 64-bit machine; however I wish to use the 64-bit jdk so my Java program can take advantage of the larger memory capabilities etc. I'm currently trying to compile JRI_0.4-1 on a 64-bit XP I got to a point that I was able to generate a 32-bit dll, but I don't know exactly how to modify it so that it's able to generate a 64-bit dll. I tried modifying the makefile adding -m64 to some of the gcc command with no success. I am not very experienced with creating dll's, but I was wondering if anybody attempted to compile a 64-bit JRI.dll? And if so what type of modifications or resources should I use? Thanks! Tim -- View this message in context: http://www.nabble.com/compiling-64-bit-JRI.dll-with-64bit-XP-tp23428511p23428511.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 call time series functions from C ?
Do you have to use the entire xxxGB at once? If not store it in a database and fetch the portions for the current analysis as you need them. On Thu, May 7, 2009 at 10:55 AM, goon83 goo...@126.com wrote: hi Duncan, tks for you response, it's depressed to know that i can not use time series of R to finish my study. I really think R is powerfull, i used it to finish all my statistic homework last year^_^. but i still wonder can i use the function of time series in the embedded way of C code. Can you give me some suggestion about how to use time series of R in C code? tks bin dong goo...@126.com Buaa, Beijing PR China 在2009-05-07?21:51:13,Duncan?Murdoch?murd...@stats.uwo.ca?写道: On?5/7/2009?9:24?AM,?goon83?wrote: ?Hi?everyone, ???I?meet?the?problem?to?call?R?from?C.? ?? ???Can?someone?tell?me?is?it?possible?to?call?time?series?functions(such?as?ar?and?arima)from??C?program?on?linux?platform,?and?then?compile?the?C?program?to?a?standalone?executable?file? ? ???I?know?we?can?call?some?function?defined?in?Rmath.h?,?but?I?have?not?found?the?entry?point?for?time?series?function.? There?are?none,?but?you?can?write?a?front?end?for?R,?and?it?can?evaluate? R?expressions,?etc.??The?procedure?is?described?in?the?Writing?R? Extensions?manual. Remember?that?if?you?distribute?the?program?you?do?need?to?follow?the? GPL,?and?distribute?all?of?R?as?well?as?all?of?your?own?program?in? source?code?form. Duncan?Murdoch ?? ???I?would?very?much?appreciate?receiving?your?response?!?^_^ ? ? ?bin,?dong ?goo...@126.com ?Buaa,?Beijing?PR?China ? ??? ? ? [[alternative?HTML?version?deleted]] ? ?__ ?r-h...@r-project.org?mailing?list ?https://stat.ethz.ch/mailman/listinfo/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] Step and stepAIC
Jun Shen jun.shen.ut at gmail.com writes: I also wonder if stepAIC can work with an lme model. I tried. it doesn't for now. Appreciate any comment. It can, and it displays a nice error message telling you exactly why it did not work if you try out of the box. Check parameter method in your lme call. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] visualization of sub-parts in 3D arrays
Hello all; Let's say we have a block of 3D data belonging to cubic cells, and increasing indexes are ordered x: from west to east y: from north to south z: from top to bottom --- nx - 25 ny - 12 nz - 4 my.array - array(NA,dim=c(nx,ny,nz)) for(z in 1:nz){ my.array[,,z] - runif(nx*ny,z-1,z) } --- Is there a way to relatively easy plot sub-blocks of this 3d array in R? This would include simultaneous plots of several layers one over the other, and keeping the gaps between them if they are non-contiguous. Also this would include transversal cuts of thickness 1 or 1, and from a selected point of view. I mean as a render in which lateral planes (xz and yz planes) are treated similarly to xy planes. Thanks and best regards, Javier --- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Step and stepAIC
Jun Shen jun.shen.ut at gmail.com writes: I also wonder if stepAIC can work with an lme model. I tried. it doesn't for now. Appreciate any comment. It can do it, and it displays a nice error message, as I remember, why it won't do it in the default setting. Check parameter method of your lme call. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] lasso based selection for mixed model
Dear useRs (called Frank Harrell, most likely), after having preached for years to my medical colleagues to be cautious with stepwise selection procedures, they chanted back asking for an alternative when using mixed models. There is a half dozen laXXX packages around for all types of linear models, but as far I see there is none for mixed models such as lme. Even boot.stepAIC (which I considered valid, but Frank objects) is not for lme. I found one SPSS macro around that comes close. Any ideas? Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A potential bug for paste() ?
On Thu, 2009-05-07 at 09:38 -0500, Jun Shen wrote: Hi, everyone, Try the following command to see if you get TRUE or FALSE. I get FALSE on a unix platform but TRUE on Windows. Any comment? all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) And what is Theoph? Please do read the posting guide and provide a reproducible example. Is Theoph a list? a - list(A = rnorm(10), B = rnorm(10)) paste(a[1], a[2]) [1] c(0.511810414967963, 0.165995305876871, 1.22637694512945, -0.496453787173788, 0.325876407556065, 1.97392856823209, -0.228962880984580, -0.172306887133861, -0.881280038259407, -0.216958955239245) c(-0.281058662811336, 0.918418337792562, -1.44005513590710, 0.22857441100305, 0.840138552938062, 0.0555436312146647, -0.602645008995437, -0.158866265592772, 0.959478898002479, -0.892389972305427) paste(a[[1]], a[[2]]) [1] 0.511810414967963 -0.281058662811336 [2] 0.165995305876871 0.918418337792562 [3] 1.22637694512945 -1.44005513590710 [4] -0.496453787173788 0.22857441100305 [5] 0.325876407556065 0.840138552938062 [6] 1.97392856823209 0.0555436312146647 [7] -0.228962880984580 -0.602645008995437 [8] -0.172306887133861 -0.158866265592772 [9] -0.881280038259407 0.959478898002479 [10] -0.216958955239245 -0.892389972305427 typeof(a[[1]]) [1] double typeof(a[1]) [1] list If it is, note that [ and [[ do not return the same thing for a list and as such it is not surprising that they are not equal, pasted or otherwise. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] I updated/reinstalled ggplot2 and the trouble started...
Hi, What device are you using to plot the graph? I am not explicitly specifying any. I am on redhat linux and as I understand it R uses DISPLAY environment variable, which is set for an X11 server (X Darwin, v1.4.0, X11 6.8.2). Other qplot()'s I have used (straight out of the book) work fine. I am coming to believe that before the current incarnation, it simply ignored the alpha parameter and gave the plot, whereas with the latest it doens't want to ignore and not going further. I'd be curious if this problem is reproducible with anybody else. Regards, Tena Sakaki tsa...@gallo.ucsf.edu -Original Message- From: ONKELINX, Thierry [mailto:thierry.onkel...@inbo.be] Sent: Thu 5/7/2009 1:01 AM To: Tena Sakai; Ian Fellows; r-help@r-project.org Subject: RE: [R] I updated/reinstalled ggplot2 and the trouble started... What device are you using to plot the graph? According to the warning, the device is causing the problem. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Tena Sakai Verzonden: donderdag 7 mei 2009 6:22 Aan: Ian Fellows; r-help@r-project.org Onderwerp: Re: [R] I updated/reinstalled ggplot2 and the trouble started... Hi Ian, Per your suggestion, I reinstalled R 2.9.0, then I reinstalled ggplot2 on top. The problem persists. Here's the what happens after the installation: qplot (carat, price, data = diamonds, alpha = I(1/10)) Warning message: In grid.Call.graphics(L_points, x$x, x$y, x$pch, x$size) : semi-transparency is not supported on this device: reported only once per page The entire record of installing ggplot2 package, ending up with the line above is in the attached file. I would think this should be reproducible with anybody else. If you have any other suggestion, I am all ears. Regards, Tena Sakai tsa...@gallo.ucsf.edu -Original Message- From: Ian Fellows [mailto:ifell...@gmail.com] Sent: Tue 5/5/2009 11:43 PM To: Tena Sakai Subject: Re: I updated/reinstalled ggplot2 and the trouble started... Tena, May I suggest that you do a full clean install of R 2.9.0, then install ggplot2 from cran. See if the problem persists after that. Ian On Tue, May 5, 2009 at 11:13 PM, tena tsa...@gallo.ucsf.edu wrote: Hi Hadley, Many thanks for your reply. I followed your instruction and got past the point where I was stuck at. Namely, I was able to generate a few plots. But as I came to the second half of section 2.4, where I wanted to see the behavior of alpha paramter, which I had apparently misspelled, I encountered another hindrance: qplot (carat, price, data = diamonds, alpha = I(1/10)) Warning message: In grid.Call.graphics(L_points, x$x, x$y, x$pch, x$size) : semi-transparency is not supported on this device: reported only once per page A plot was generated, but there are tic marks and labels on each direction, but no plot at all. I wonder if this is yet another (hidden) package to be updated... The warning message suggests grid, but I am hesitant to do something without knowing what is what. I would appreciate your instruction. Regards, Tena Sakai On May 5, 5:24 pm, hadley wickham h.wick...@gmail.com wrote: Hi Tena, R isn't very good at detecting when package dependencies also need to be updated, so you probably need to do: install.packages(c(reshape,plyr)) And you want qplot (carat, price, data=diamonds, alpha = I(1/10)) not qplot (carat, price, data=diamonds, slpha = i(1/10)) Hadley On Tue, May 5, 2009 at 6:27 PM, tena tsa...@gallo.ucsf.edu wrote: Hi Folks, I am pretty new to R and I am even newer to ggplot. I am using R 2.7.1, 2.8.1, and 2.9.0 on linux host and what I am experiencing holds for all three. I was just typing a few examples from the chapter 2 of the book, ggplot2 --Elegant graphics for data analysis. I typed 3 qplot lines on page 13: qplot (carat, price, data=diamonds, slpha = i(1/10)) qplot (carat, price, data=diamonds, slpha = i(1/100)) qplot (carat, price, data=diamonds, slpha = i(1/200)) To me, the plot looked identical. I went
Re: [R] Step and stepAIC
Thanks a lot, Dieter, I changed the method to ML for my lme call. Now I get a different error when running the stepAIC Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type What does that mean? The same dataset was used for an lm call and everything is fine to run stepAIC. Jun On Thu, May 7, 2009 at 10:44 AM, Dieter Menne dieter.me...@menne-biomed.dewrote: Jun Shen jun.shen.ut at gmail.com writes: I also wonder if stepAIC can work with an lme model. I tried. it doesn't for now. Appreciate any comment. It can do it, and it displays a nice error message, as I remember, why it won't do it in the default setting. Check parameter method of your lme call. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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] Linear least squares fit with errors in both x and y values.
James, look up errors in variables models or instrumental variable models in econometrics. The statistics alternative is a random effects or mixed effects model which plugs the variation in the x's into a randomly varying parameter - these are available in R (?lmer or glmm - I think). Someone on the list much more knowledgeable than I about these will be able to give you some help if you ask a good question. Gerard James Allsopp jamesaalls...@go oglemail.com To Sent by: r-help@r-project.org r-help-boun...@r- cc project.org Subject [R] Linear least squares fit with 07/05/2009 15:19 errors in both x and y values. HI, I'd like to perform a weighted linear least squares fit with R on data with varying errors on both vectors. I can do this with one axis using lm, but have no idea where to go from here. I've tried googling, but no idea. Any suggestions? Thanks, James __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. It is the policy of the Department of Justice, Equality and Law Reform and the Agencies and Offices using its IT services to disallow the sending of offensive material. Should you consider that the material contained in this message is offensive you should contact the sender immediately and also mailminder[at]justice.ie. Is le haghaidh an duine nó an eintitis ar a bhfuil sí dírithe, agus le haghaidh an duine nó an eintitis sin amháin, a bheartaítear an fhaisnéis a tarchuireadh agus féadfaidh sé go bhfuil ábhar faoi rún agus/nó faoi phribhléid inti. Toirmisctear aon athbhreithniú, atarchur nó leathadh a dhéanamh ar an bhfaisnéis seo, aon úsáid eile a bhaint aisti nó aon ghníomh a dhéanamh ar a hiontaoibh, ag daoine nó ag eintitis seachas an faighteoir beartaithe. Má fuair tú é seo trí dhearmad, téigh i dteagmháil leis an seoltóir, le do thoil, agus scrios an t-ábhar as aon ríomhaire. Is é beartas na Roinne Dlí agus Cirt, Comhionannais agus Athchóirithe Dlí, agus na nOifígí agus na nGníomhaireachtaí a úsáideann seirbhísí TF na Roinne, seoladh ábhair cholúil a dhícheadú. Más rud é go measann tú gur ábhar colúil atá san ábhar atá sa teachtaireacht seo is ceart duit dul i dteagmháil leis an seoltóir láithreach agus le mailminder[ag]justice.ie chomh maith. *** __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 call time series functions from C ?
On 5/7/2009 11:17 AM, goon83 wrote: Hi Duncan, Sorry, i miss the informatin in the previous message, you said that i can write a front end to call , does the front end can be implemented by c, and i can compile the c code to a standalone program. i will appreiciate for more detail information See the Writing R Extensions manual, as I said in the original reply. Duncan Murdoch tks? ? ?bin?dong? ?goo...@126.com ?Buaa,?Beijing?PR?China ??2009-05-07?23:05:47??Duncan?Murdoch?murd...@stats.uwo.ca??? On?5/7/2009?10:55?AM,?goon83?wrote: ?hi?Duncan, ?? ?tks?for?you?response,?it's?depressed?to?know?that?i?can?not?use?time?series?of?R?to?finish?my?study. ?? ?I?really?think?R?is?powerfull,?i?used?it?to?finish?all?my?statistic?homework?last?year^_^. ?? ?but?i?still?wonder?can?i?use?the?function?of?time?series?in?the?embedded?way?of?C?code. ?? ?? ?Can?you?give?me?some?suggestion?about?how?to?use?time?series?of?R?in?C?code? I?did,?in?the?previous?message. Duncan?Murdoch ?? ?? ?? ?tks? ?? ? ?bin?dong? ?goo...@126.com ?Buaa,?Beijing?PR?China ?? ?? ? ? ?? ? ? ???2009-05-07?21:51:13??Duncan?Murdoch?murd...@stats.uwo.ca??? On?5/7/2009?9:24?AM,?goon83?wrote: ?Hi?everyone, ???I?meet?the?problem?to?call?R?from?C.? ?? ???Can?someone?tell?me?is?it?possible?to?call?time?series?functions(such?as?ar?and?arima)from??C?program?on?linux?platform,?and?then?compile?the?C?program?to?a?standalone?executable?file? ? ???I?know?we?can?call?some?function?defined?in?Rmath.h?,?but?I?have?not?found?the?entry?point?for?time?series?function.? There?are?none,?but?you?can?write?a?front?end?for?R,?and?it?can?evaluate? R?expressions,?etc.??The?procedure?is?described?in?the?Writing?R? Extensions?manual. Remember?that?if?you?distribute?the?program?you?do?need?to?follow?the? GPL,?and?distribute?all?of?R?as?well?as?all?of?your?own?program?in? source?code?form. Duncan?Murdoch ?? ???I?would?very?much?appreciate?receiving?your?response?!?^_^ ? ? ?bin,?dong ?goo...@126.com ?Buaa,?Beijing?PR?China ? ??? ? ? [[alternative?HTML?version?deleted]] ? ?__ ?r-h...@r-project.org?mailing?list ?https://stat.ethz.ch/mailman/listinfo/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] A potential bug for paste() ?
On Thu, May 7, 2009 at 9:56 AM, Sarah Goslee sarah.gos...@gmail.com wrote: It probably has less to do with paste() than with Theoph, but since we have no idea what that might be, it's hard to tell. See the bit about reproducible example, please. Well, actually Theoph is one of the datasets in the (required) datasets package. It happens to be data from a pharmacokinetics experiment so it is natural that PK/PD scientist would think of it. find(Theoph) [1] package:datasets str(Theoph) Classes ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and 'data.frame': 132 obs. of 5 variables: $ Subject: Ord.factor w/ 12 levels 67811..: 11 11 11 11 11 11 11 11 11 11 ... $ Wt : num 79.6 79.6 79.6 79.6 79.6 79.6 79.6 79.6 79.6 79.6 ... $ Dose : num 4.02 4.02 4.02 4.02 4.02 4.02 4.02 4.02 4.02 4.02 ... $ Time : num 0 0.25 0.57 1.12 2.02 ... $ conc : num 0.74 2.84 6.57 10.5 9.66 8.58 8.36 7.47 6.89 5.94 ... - attr(*, formula)=Class 'formula' length 3 conc ~ Time | Subject .. ..- attr(*, .Environment)=environment: R_EmptyEnv - attr(*, labels)=List of 2 ..$ x: chr Time since drug administration ..$ y: chr Theophylline concentration in serum - attr(*, units)=List of 2 ..$ x: chr (hr) ..$ y: chr (mg/l) On Thu, May 7, 2009 at 10:38 AM, Jun Shen jun.shen...@gmail.com wrote: Hi, everyone, Try the following command to see if you get TRUE or FALSE. I get FALSE on a unix platform but TRUE on Windows. Any comment? all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) There is a difference between Theoph[1] and Theoph[[1]]. The Theoph object is a data frame. Whenever you use the single bracket extractor you will get another data frame. str(Theoph[1]) Classes ‘nfnGroupedData’, ‘nfGroupedData’, ‘groupedData’ and 'data.frame': 132 obs. of 1 variable: $ Subject: Ord.factor w/ 12 levels 67811..: 11 11 11 11 11 11 11 11 11 11 ... A data frame is a special type of a list and, in general, this applies to any list - single bracket extraction applied to a list always produces a list, even if it is a list of one element. The double bracket extractor returns the element of the list, not a sublist. str(Theoph[[1]]) Ord.factor w/ 12 levels 67811..: 11 11 11 11 11 11 11 11 11 11 ... I think of the distinction as being like the difference between an element of a set (the [[ operator) and a subset of size one (the [ operator). __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] dotplot: labeling coordinates for each point
On Thu, May 7, 2009 at 7:42 AM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote: Hi Deepayan, I guess I’m quite confusing when asking the question. I was actually looking for labels beside the dot in the graph (shown below), rather than the labels on the x-axis. Is that possible? Thanks a lot! In that case dotplot(y ~ x, xlab=Store, ylab=Revenue, main=test, scales=list(x = list(draw = FALSE)), panel = function(x, y, ...) { panel.dotplot(x, y, ...) id - y 90 panel.text(as.numeric(x[id]), y[id], labels = sprintf((%s,%g), as.character(x[id]), y[id]), pos = 4) }) -Deepayan Best, Tony -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Deepayan Sarkar Sent: Thursday, May 07, 2009 1:44 AM To: Qifei Zhu Cc: r-help@r-project.org Subject: Re: [R] dotplot: labeling coordinates for each point On Wed, May 6, 2009 at 6:54 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote: Hi Deepayan, Thanks for the reply. here is a very simple example of what I'm looking for: y=c(100,0,-20) x=c(Atlanta, Baltimore, Berkeley CA) dotplot(y~x, xlab=Store, ylab=Revenue,main=test, scale=list(rot=60)) Basically it produces a graph of city on the x-axis and its associated revenue on the y-axis. In the real data set, the x-axis will be filled of tens or even hundreds of cities, so I wanna label the dots in the graph whenever the revenue (y value) is greater than a threshold, let's say 90 in this case. The labels should be in (x,y) format, which is (Atlanta, 100) in this case. Appreciate a lot for your help! dotplot(y~x, xlab=Store, ylab=Revenue,main=test, xlim = ifelse(y 90, sprintf((%s,%g), x, y), ), scales=list(rot=60)) -Deepayan Best, Tony -Original Message- From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com] Sent: Wednesday, May 06, 2009 8:40 PM To: Qifei Zhu Cc: David Winsemius; r-help@r-project.org Subject: Re: [R] dotplot: labeling coordinates for each point On Tue, May 5, 2009 at 7:04 PM, Qifei Zhu zhu_qi...@yahoo.com.sg wrote: Hi Deepayan, Thanks for the hint. I spent some time on the research but haven't got any luck in writing the custom panel function for the conditional labeling of points in a graph. Could you please provide some more thoughts and probably some pseudo code? Thank you so much for your time! I'll be happy to try if you provide a reproducible example. -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A potential bug for paste() ?
Theoph is in the datasets package, so it should be available in all versions of R: class(Theoph) [1] nfnGroupedData nfGroupedData groupedDatadata.frame The key to what's happening is that there are some methods for groupedData objects in the nlme library, which I suspect the original poster had loaded in Windows, but not Unix. Here's what I see on a Linux system: all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) [1] FALSE library(nlme) all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) [1] TRUE So if nlme is loaded, the following methods are available for groupedData objects: methods(class='groupedData') [1] as.data.frame.groupedData* asTable.groupedData* [3] collapse.groupedData* formula.groupedData* [5] [.groupedData* isBalanced.groupedData* [7] lme.groupedData* lmList.groupedData* [9] print.groupedData* update.groupedData* Thus subscripting for these objects is performed differently when the nlme package is loaded. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Thu, 7 May 2009, Gavin Simpson wrote: On Thu, 2009-05-07 at 09:38 -0500, Jun Shen wrote: Hi, everyone, Try the following command to see if you get TRUE or FALSE. I get FALSE on a unix platform but TRUE on Windows. Any comment? all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) And what is Theoph? Please do read the posting guide and provide a reproducible example. Is Theoph a list? a - list(A = rnorm(10), B = rnorm(10)) paste(a[1], a[2]) [1] c(0.511810414967963, 0.165995305876871, 1.22637694512945, -0.496453787173788, 0.325876407556065, 1.97392856823209, -0.228962880984580, -0.172306887133861, -0.881280038259407, -0.216958955239245) c(-0.281058662811336, 0.918418337792562, -1.44005513590710, 0.22857441100305, 0.840138552938062, 0.0555436312146647, -0.602645008995437, -0.158866265592772, 0.959478898002479, -0.892389972305427) paste(a[[1]], a[[2]]) [1] 0.511810414967963 -0.281058662811336 [2] 0.165995305876871 0.918418337792562 [3] 1.22637694512945 -1.44005513590710 [4] -0.496453787173788 0.22857441100305 [5] 0.325876407556065 0.840138552938062 [6] 1.97392856823209 0.0555436312146647 [7] -0.228962880984580 -0.602645008995437 [8] -0.172306887133861 -0.158866265592772 [9] -0.881280038259407 0.959478898002479 [10] -0.216958955239245 -0.892389972305427 typeof(a[[1]]) [1] double typeof(a[1]) [1] list If it is, note that [ and [[ do not return the same thing for a list and as such it is not surprising that they are not equal, pasted or otherwise. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] A potential bug for paste() ?
Thanks for everyone's attention on this issue! On Thu, May 7, 2009 at 11:20 AM, Phil Spector spec...@stat.berkeley.eduwrote: Theoph is in the datasets package, so it should be available in all versions of R: class(Theoph) [1] nfnGroupedData nfGroupedData groupedDatadata.frame The key to what's happening is that there are some methods for groupedData objects in the nlme library, which I suspect the original poster had loaded in Windows, but not Unix. Here's what I see on a Linux system: all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) [1] FALSE library(nlme) all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) [1] TRUE So if nlme is loaded, the following methods are available for groupedData objects: methods(class='groupedData') [1] as.data.frame.groupedData* asTable.groupedData* [3] collapse.groupedData* formula.groupedData* [5] [.groupedData* isBalanced.groupedData* [7] lme.groupedData* lmList.groupedData* [9] print.groupedData* update.groupedData* Thus subscripting for these objects is performed differently when the nlme package is loaded. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Thu, 7 May 2009, Gavin Simpson wrote: On Thu, 2009-05-07 at 09:38 -0500, Jun Shen wrote: Hi, everyone, Try the following command to see if you get TRUE or FALSE. I get FALSE on a unix platform but TRUE on Windows. Any comment? all(paste(Theoph[1],Theoph[2])==paste(Theoph[[1]],Theoph[[2]])) And what is Theoph? Please do read the posting guide and provide a reproducible example. Is Theoph a list? a - list(A = rnorm(10), B = rnorm(10)) paste(a[1], a[2]) [1] c(0.511810414967963, 0.165995305876871, 1.22637694512945, -0.496453787173788, 0.325876407556065, 1.97392856823209, -0.228962880984580, -0.172306887133861, -0.881280038259407, -0.216958955239245) c(-0.281058662811336, 0.918418337792562, -1.44005513590710, 0.22857441100305, 0.840138552938062, 0.0555436312146647, -0.602645008995437, -0.158866265592772, 0.959478898002479, -0.892389972305427) paste(a[[1]], a[[2]]) [1] 0.511810414967963 -0.281058662811336 [2] 0.165995305876871 0.918418337792562 [3] 1.22637694512945 -1.44005513590710 [4] -0.496453787173788 0.22857441100305 [5] 0.325876407556065 0.840138552938062 [6] 1.97392856823209 0.0555436312146647 [7] -0.228962880984580 -0.602645008995437 [8] -0.172306887133861 -0.158866265592772 [9] -0.881280038259407 0.959478898002479 [10] -0.216958955239245 -0.892389972305427 typeof(a[[1]]) [1] double typeof(a[1]) [1] list If it is, note that [ and [[ do not return the same thing for a list and as such it is not surprising that they are not equal, pasted or otherwise. G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/http://www.ucl.ac.uk/%7Eucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[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] Step and stepAIC
Jun Shen jun.shen.ut at gmail.com writes: I changed the method to ML for my lme call. Now I get a different error when running the stepAIC Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type What does that mean? The same dataset was used for an lm call and everything is fine to run stepAIC. Show sessionInfo() (do you have the recent version?) Show str(yourdataset) Show lme( your formula) Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 64 bit R double precision
Hi, If R is compiled for a 64 bit platform, does the double data type make use of the additional precision or is it set at a fixed length? Thanks, Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Step and stepAIC
Hi, Dieter, sessionInfo() R version 2.9.0 (2009-04-17) i386-pc-mingw32 str(cov) 'data.frame': 40 obs. of 13 variables: $ ID : int 2 3 4 5 6 7 8 9 10 11 ... $ AMT : num 50 50 50 50 50 50 50 50 25 25 ... $ Cmax : num [1:40(1d)] 8901 5574 10496 10882 8130 ... ..- attr(*, dimnames)=List of 1 .. ..$ ID: chr 2 3 4 5 ... $ biomarker: num 3817 2542 5127 4478 3362 ... $ CRCL : num 29.2 44.5 65.5 57.1 63.3 ... $ SEX : chr male male male male ... $ WT : num 79.7 86.4 80.5 55.2 83.8 ... $ AGE : int 48 21 20 61 67 24 60 36 23 22 ... $ AGE2 : num 0 0 0 1 1 0 1 0 0 0 ... $ SEX2 : num 1 1 1 1 1 0 1 0 0 0 ... $ AGE3 : num 1 0 0 1 1 0 1 1 0 0 ... $ CRCL2: num 0 1 1 1 1 1 1 1 1 1 ... $ WT2 : num 0 0 0 0 0 0 0 1 0 1 ... lme(biomarker~Cmax+AGE,data=cov,method='ML',random=~1+AGE|ID,keep.data=T)-mod.lme2 Warning message: In lme.formula(biomarker ~ Cmax + AGE, data = cov, method = ML, : Fewer observations than random effects in all level 1 groups stepAIC(mod.lme2,scope=list(upper=~Cmax+AGE+SEX2+WT+CRCL,lower=~1+Cmax)) Start: AIC=637.53 biomarker ~ Cmax + AGE Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type I also wonder if stepAIC tests random effect to each covariate (e.g. AGE, WT, CRCL...) Thanks. Jun On Thu, May 7, 2009 at 11:37 AM, Dieter Menne dieter.me...@menne-biomed.dewrote: Jun Shen jun.shen.ut at gmail.com writes: I changed the method to ML for my lme call. Now I get a different error when running the stepAIC Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type What does that mean? The same dataset was used for an lm call and everything is fine to run stepAIC. Show sessionInfo() (do you have the recent version?) Show str(yourdataset) Show lme( your formula) Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] RSPerl and Statistics::R
RSPerl is not abandonded, but I haven't had much time to work on it. If you can send me an example to reproduce the race condition, we can probably think about a solution. D. Daniel Klein wrote: Greetings! Being a Perl hacker for some time, and wanting to leverage what R provides, I've been trying to work with Statistics::R and RSPerl. The former has a race condition that breeds some unreliability and the latter seems to have issues all around, and neither has been updated in some time. Are these projects are abandoned, or is there some effort currently being undertaken to either refresh or reinvent the glue binding Perl and R together? If not, then I'm probably going to give it a go myself, but I'm sort of hoping that there's a jewel of a library out there that doesn't come up as quickly in Google as the aforementioned libraries. Thanks, Daniel M. Klein This email (including attachments and files, if any) is confidential, may be privileged and is intended for the above-named recipient(s) only. If you have received this message in error, please notify me by return email and delete this message from your system. Any unauthorized use or disclosure of this message is strictly prohibited. Copyright in this email and any document created by Genesis Genomics will be and remain vested in us and will not be transferred to you. [[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] .First and loading a package in a workspace
Hi, I'm writing a package called rNMR and I'd like to be able to save a workspace with rNMR loaded, exit R, and then load the workspace, loading rNMR at the same time. This is no problem on Windows but on Linux and Macs I can't get it to work. Here's the deal. rNMR has includes a .onLoad function: .onLoad = function(lib,pkg){ print(rNMR version 1.0) } and also calls a different function which writes a .First to the global environment: .First - function(){ require(rNMR) } Actually these have been simplified from there original versions in order to easier diagnose the problem. I've tested both versions and neither work. I open R and load rNMR. I know .onLoad runs because I see [1] rNMR version 1.0 in R. Then I create the .First function as above (normally this is done internally by rNMR, but I'm doing this manually here to ensure it gets done correctly). Just to make sure I check that .First is in the right place: getAnywhere(.First) 2 differing objects matching ‘.First’ were found in the following places .GlobalEnv namespace:rNMR Use [] to view one of them .First function(){ require(rNMR) } Both versions of .First are identical. So, you'd expect that if I saved this workspace and exited, when I reopen R and load the workspace, .First should run, loading the rNMR package, and calling .onLoad. Here's what I get when I load the workspace: load(/home/undergrad/Desktop/test.RData) [1] rNMR version 1.0 but if I check for rNMR: search() [1] .GlobalEnvpackage:stats package:graphics [4] package:grDevices package:utils package:datasets [7] package:methods Autoloads package:base it's clearly not attached. I can't access any rNMR functions without loading rNMR again. .First still exists in the workspace, but somehow rNMR hasn't loaded. If this is the case, why is .onLoad running (indicated by the printed rNMR version info)? Odder still, the original version of .First was designed to open a tk toplevel containing rNMR menus, which it does. Commands from these menus work but commands typed in the console don't and everything else seems to indicate that rNMR is not attached. Any thoughts? Thanks in advance, Seth -- View this message in context: http://www.nabble.com/.First-and-loading-a-package-in-a-workspace-tp23431418p23431418.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] 64 bit R double precision
On 5/7/2009 12:56 PM, Paul Emberson wrote: Hi, If R is compiled for a 64 bit platform, does the double data type make use of the additional precision or is it set at a fixed length? It is still a 64 bit floating point value. R may use long double internally for some calculations, but the numeric type that is saved doesn't change. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Step and stepAIC
Jun Shen jun.shen.ut at gmail.com writes: lme(biomarker~Cmax+AGE,data=cov,method='ML',random=~1+AGE|ID,keep.data=T) Warning message: In lme.formula(biomarker ~ Cmax + AGE, data = cov, method = ML, : Fewer observations than random effects in all level 1 groups That's why the posting guide says: tell the whole story. After that warning, expect everything. You want too much from your data. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 64 bit R double precision
Paul Emberson wrote: Hi, If R is compiled for a 64 bit platform, does the double data type make use of the additional precision or is it set at a fixed length? No. Double is double, 64 bits, although sometimes 80 bits when things are kept in registers. However, even though the FPU is identical between 64 and 32 bit machines, you do not in general get the same results, due to tricks played by optimizing compilers. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 do Naive Bayes in R?
On Wednesday 06 May 2009, spencerg wrote: help.search('bayes') only searches installed packages. To go beyond that, you might try the following: Thanks for the clarification. Dylan -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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~ how can I drow colorful text in biplot.
Hi. I want to show easily classified samples in the one biplot. My samples have 14 types and each type have 21 samples So, I cannot understand distribution of samples after plsda. I want to give a color each types text in graph. How can I do that? [[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] Help with lme4 model specification
Thanks for your response. This is suspicious : Spar_loc doesn't appear in your statement... Yes Spar_loc should look suspicious. I posted the real error messages but hid the variable names in the model. Spar_loc is the original form of S. The precedence of modelling operators is not very clear (and does not seem to be formally defined in the standard documentation...). In doubt, use parentheses. So try ...+(1|(S:A)/H), just in case.. This did not work. However I did discover something that does: AAT- lmer(Y ~ S + A + (1|H %in% S:A), data=AT, REML=TRUE) Not sure why this worked. I read that it is an alternate way of specifying nesting. This runs without error. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 this message in context: http://www.nabble.com/Help-with-lme4-model-specification-tp23415908p23428678.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] Weighted multinomial logistic regression using the mlogit package
I have been trying to use the mlogit package to do a multinomial logistic regression, including both alternative-specific and individual-specific variables. I used the mlogit.data function to turn my dataframe into the correct format for the mlogit function, and have been able to run the regression. However, I would like to weight the different cases differently. (Just to clarify, it's not the alternatives I want to weight differently; it's the individual instances in which a choice has to be made.) I have used the following line of code: ML2-mlogit(choice~var1+var2+var3+var5,data=M,weights=weights) Here, M is the dataframe in the appropriate format; var1, var2, var3 and var5 are predictors (alternative-specific) that are columns of M; and weights is another column of M. This line works too, but it gives me the same answer as when the weights were omitted, which seems to indicate that the weights aren't properly being taken into account. Any suggestions? Michael Freiman __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] increasing memory for R bg job
Hi, Is the following command used to increase the memory or any other command when a background R job is run? R --min-vsize=vl --max-vsize=vu --min-nsize=nl --max-nsize=nu --max-ppsize=N source: http://stat.ethz.ch/R-manual/R-patched/library/base/html/Memory.html Thx Carol [[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] CHM error
Hi, I would need some help in solving a problem with my R. Whenever I try to type ?paste or in general any command for the html help in R, I receive this error message. The strange thing is that I have never had this kind of problem in the past with R, and now I really don't understand why it says that. Also I have selected every single element in the installation process. The message is this one: Error in print.help_files_with_topic(D:/Programmi/R/R-2.9.0/library/base/chm/print) : CHM file could not be displayed I would really appreciate some suggestion. Thanks very much. -- View this message in context: http://www.nabble.com/CHM-error-tp23432814p23432814.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] for loop vectorization
Hi, I am still not familiar with vectorization. Could you help with making this for loop more efficient? The code is trying to make a Q matrix for a multidimensional state space with specific conditions. thanks Mira tmp = 0:(maxvals[1]) for(i in 2:nchars) { tmp - outer(tmp, 0:(maxvals[i]), FUN=paste, sep=.) } states = tmp stateidx = array(1:length(states), dim=dim(states)) transition - matrix(data=0, nrow=length(states), ncol=length(states)) findstatedim - function(x) which(stateidx==x, arr.ind = TRUE) manhattandistance - function(x,y) sum(abs(findstatedim(x)-findstatedim(y))) for(i in 1:length(states)) { for (j in 1:length(states)) { if (manhattandistance(i, j)==1) { if (sum(findstatedim(i)-findstatedim(j)) 0) { transition[i,j] = gain if (findstatedim(i)[findstatedim(i)-findstatedim(j) == -1] == 1) { transition[i,j] = firstgain } } else { transition[i,j] = loss } } } } transition [[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] GAM ordered probit
Dear All, Anyone know if there is a package that fits Generalized Linear Models(GAM) to data with ordered dependent variable(response) ? Simon Wood's mgcv has probit, logit,... other links, however, I could not find a way to do GAM *ordered *probit. Yee's VGAM claims to fit ordinal proportional odds model(cumulative logit model) (see: http://www.stat.auckland.ac.nz/~yee/VGAM/) but I could not find how to do so in the package's help. Best, Mehdi Shadmehr PhD Candidate in Economics UIUC [[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] for loop vectorization
uhoh, missed two lines on the top.Sorry about that. the whole code looks like this. nchars = 4 maxvals = c(2,2,2,2) tmp = 0:(maxvals[1]) for(i in 2:nchars) { tmp - outer(tmp, 0:(maxvals[i]), FUN=paste, sep=.) } states = tmp stateidx = array(1:length(states), dim=dim(states)) transition - matrix(data=0, nrow=length(states), ncol=length(states)) findstatedim - function(x) which(stateidx==x, arr.ind = TRUE) manhattandistance - function(x,y) sum(abs(findstatedim(x)-findstatedim(y))) for(i in 1:length(states)) { for (j in 1:length(states)) { if (manhattandistance(i, j)==1) { if (sum(findstatedim(i)-findstatedim(j)) 0) { transition[i,j] = gain if (findstatedim(i)[findstatedim(i)-findstatedim(j) == -1] == 1) { transition[i,j] = firstgain } } else { transition[i,j] = loss } } } } transition On Thu, May 7, 2009 at 2:54 PM, miraceti mirac...@gmail.com wrote: Hi, I am still not familiar with vectorization. Could you help with making this for loop more efficient? The code is trying to make a Q matrix for a multidimensional state space with specific conditions. thanks Mira tmp = 0:(maxvals[1]) for(i in 2:nchars) { tmp - outer(tmp, 0:(maxvals[i]), FUN=paste, sep=.) } states = tmp stateidx = array(1:length(states), dim=dim(states)) transition - matrix(data=0, nrow=length(states), ncol=length(states)) findstatedim - function(x) which(stateidx==x, arr.ind = TRUE) manhattandistance - function(x,y) sum(abs(findstatedim(x)-findstatedim(y))) for(i in 1:length(states)) { for (j in 1:length(states)) { if (manhattandistance(i, j)==1) { if (sum(findstatedim(i)-findstatedim(j)) 0) { transition[i,j] = gain if (findstatedim(i)[findstatedim(i)-findstatedim(j) == -1] == 1) { transition[i,j] = firstgain } } else { transition[i,j] = loss } } } } transition [[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] dependency ‘Matrix’ is not availabl e when installing Rcmdr
Uwe Ligges wrote: Argh, it disappeared. Probably a bug in my scripts that removed the old version of Matrix from the Windows binary repository for R-2.8.x (new versions of Matrix won't pass checks under the outdated version of R). I will compile an old version tomorrow and make it available again. It's now waiting to be synced by CRAN (i.e. available from CRAN master within a couple of hours). Uwe Ligges Sorry for the inconvenience and thanks for the report. If you upgrade to R-2.9.0 you won't see this problem and you can also get a newer version of Matrix. Uwe Ligges John Sorkin wrote: R 2.8.1 Windows XP Any suggestions for addressing the problem listed below, obtained when installing Rcmdr The downloaded packages are in C:\Documents and Settings\jsorkin\Local Settings\Temp\RtmpaxlG6g\downloaded_packages updating HTML package descriptions Warning message: dependency ‘Matrix’ is not available Thanks, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] levelplot question
From the help for panel.levelplot in the section on 'col.regions': the exact number being one more than the length of 'at' was what I based my assumption on (also the not longer than at phrase in the last sentence on recycling). The second part was somewhat speculation on my part, automatically adding -Inf and Inf would mean that you would not need to make sure to span the range of the data, but on the other hand, it would make it hard to exclude values outside the region as in your example, arguments could be made for either direction, the current behavior is probably best overall. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com] Sent: Wednesday, May 06, 2009 6:35 PM To: Greg Snow Cc: Antje; r-h...@stat.math.ethz.ch Subject: Re: [R] levelplot question On Tue, May 5, 2009 at 8:58 AM, Greg Snow greg.s...@imail.org wrote: The function that is doing the color assignments is level.colors in the lattice package. Looking at the code confirms that the number of colors should be 1 less than the length of the at variable (the documentation implies that it should be 1 more, looks like a documentation bug to me). Could you point to the place where this is implied? I couldn't see anything obviously wrong in ?levelplot or ?level.colors. It is possible that at one time the author intended to prepend -Inf and append Inf to the at vector so that it did not need to span the entire range of the data, but that was not implemented. I think I would prefer that fix to changing the documentation. That is a slightly different issue though: e.g., level.colors(c(1, 2, 3), at = c(1.5, 2.5, 3.5), colors = FALSE) [1] NA 1 2 The first value doesn't fall in any interval, so gets a NA. level.colors() is mainly a helper function for levelplot(), and it is important there that the first and last intervals not be open-ended. levelplot() has no 'zlim' argument, and you need 'at' to restrict the values shown, e.g., levelplot(volcano, at = do.breaks(c(120, 200), 10)) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] levelplot question
On Thu, May 7, 2009 at 12:02 PM, Greg Snow greg.s...@imail.org wrote: From the help for panel.levelplot in the section on 'col.regions': the exact number being one more than the length of 'at' was what I based my assumption on (also the not longer than at phrase in the last sentence on recycling). Thanks, that's definitely a documentation bug. I've reorganized the documentation for levelplot colors (hopefully for the better). Should show up in the next update. -Deepayan The second part was somewhat speculation on my part, automatically adding -Inf and Inf would mean that you would not need to make sure to span the range of the data, but on the other hand, it would make it hard to exclude values outside the region as in your example, arguments could be made for either direction, the current behavior is probably best overall. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: Deepayan Sarkar [mailto:deepayan.sar...@gmail.com] Sent: Wednesday, May 06, 2009 6:35 PM To: Greg Snow Cc: Antje; r-h...@stat.math.ethz.ch Subject: Re: [R] levelplot question On Tue, May 5, 2009 at 8:58 AM, Greg Snow greg.s...@imail.org wrote: The function that is doing the color assignments is level.colors in the lattice package. Looking at the code confirms that the number of colors should be 1 less than the length of the at variable (the documentation implies that it should be 1 more, looks like a documentation bug to me). Could you point to the place where this is implied? I couldn't see anything obviously wrong in ?levelplot or ?level.colors. It is possible that at one time the author intended to prepend -Inf and append Inf to the at vector so that it did not need to span the entire range of the data, but that was not implemented. I think I would prefer that fix to changing the documentation. That is a slightly different issue though: e.g., level.colors(c(1, 2, 3), at = c(1.5, 2.5, 3.5), colors = FALSE) [1] NA 1 2 The first value doesn't fall in any interval, so gets a NA. level.colors() is mainly a helper function for levelplot(), and it is important there that the first and last intervals not be open-ended. levelplot() has no 'zlim' argument, and you need 'at' to restrict the values shown, e.g., levelplot(volcano, at = do.breaks(c(120, 200), 10)) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PGF Device
Have you contacted the author of eps2pgf? A while back I had a plot generated by R that produced an error in eps2pgf, I sent a copy of it to the author of eps2pgf and within a couple of days he sent me a new version that worked with my plot. But he cannot fix problems that he does not know about. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Lasse Bombien Sent: Thursday, May 07, 2009 3:02 AM To: r-help@r-project.org Subject: Re: [R] PGF Device Am Mittwoch, den 06.05.2009, 16:08 +0200 schrieb baptiste auguie: I think the pgfSweave project on R-forge is working on this (as far as i know it currently relies on eps2pgf) Right, but eps2pgf fails me on more complex / stacked plots. Otherwise, I would be content using eps2pgf. Lasse http://r-forge.r-project.org/R/?group_id=331 HTH, Baptiste On 6 May 2009, at 15:37, Lasse Bombien wrote: Hi all, I saw a thread from 2007 about the possible implementation of a PGF (http://sourceforge.net/projects/pgf/) graphics device. Does anyone know if something came of it? I would very much like if that was the case. Regards, Lasse __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] by-group processing
Max, Since the dataset is sorted by ID, with ties broken by N, the following should do it and do it quickly. It grabs the rows just before ID changes. with(data, data[ c(ID[-1] != ID[-length(ID)], TRUE),, drop=FALSE]) ID Type N 7 45900I 7 10 49270E 3 24 46550I 7 Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Max Webber Sent: Wednesday, May 06, 2009 3:09 PM To: r-help@r-project.org Subject: [R] by-group processing Given a dataframe like data ID Type N 1 45900A 1 2 45900B 2 3 45900C 3 4 45900D 4 5 45900E 5 6 45900F 6 7 45900I 7 8 49270A 1 9 49270B 2 10 49270E 3 18 46550A 1 19 46550B 2 20 46550C 3 21 46550D 4 22 46550E 5 23 46550F 6 24 46550I 7 containing an identifier (ID), a variable type code (Type), and a running count of the number of records per ID (N), how can I return a dataframe of only those records with the maximum value of N for each ID? For instance, data ID Type N 7 45900I 7 10 49270E 3 24 46550I 7 I know that I can use tapply ( data $ N , data $ ID , max ) 45900 46550 49270 7 7 3 to get the values of the maximum N for each ID, but how is it that I can find the index of these values to subsequently use to subscript data? -- maxine-webber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] for loop vectorization
this 'ifelse' usage looks promising. thank you very much. On Thu, May 7, 2009 at 3:12 PM, Patrick Burns pbu...@pburns.seanet.comwrote: If you haven't seen it yet, 'The R Inferno' may be of use to you. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of The R Inferno and A Guide for the Unwilling S User) miraceti wrote: Hi, I am still not familiar with vectorization. Could you help with making this for loop more efficient? The code is trying to make a Q matrix for a multidimensional state space with specific conditions. thanks Mira tmp = 0:(maxvals[1]) for(i in 2:nchars) { tmp - outer(tmp, 0:(maxvals[i]), FUN=paste, sep=.) } states = tmp stateidx = array(1:length(states), dim=dim(states)) transition - matrix(data=0, nrow=length(states), ncol=length(states)) findstatedim - function(x) which(stateidx==x, arr.ind = TRUE) manhattandistance - function(x,y) sum(abs(findstatedim(x)-findstatedim(y))) for(i in 1:length(states)) { for (j in 1:length(states)) { if (manhattandistance(i, j)==1) { if (sum(findstatedim(i)-findstatedim(j)) 0) { transition[i,j] = gain if (findstatedim(i)[findstatedim(i)-findstatedim(j) == -1] == 1) { transition[i,j] = firstgain } } else { transition[i,j] = loss } } } } transition [[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] Do you use R for data manipulation?
+1. I worked with Matthew for a while and saw in practice just how powerful that package is. I'm surprised it isn't more widely used. Martin Tom Short wrote: Another tool I find useful is Matthew Dowle's data.table package. It has very fast indexing, can have much lower memory requirements than a data frame, and has some built-in data manipulation capability. Especially with a 64-bit OS, you can use this to keep things in memory where you otherwise would have to use a database. See here: http://article.gmane.org/gmane.comp.lang.r.packages/282 - Tom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Using lme() for split plot
Hi, I'm trying to figure out how to use lme() for analyzing a split-plot experiment. I've been looking at the examples from the 'R Book', those are nested but with only one factor at the whole-plot level, my test is 2^2 at the whole-plot level, with a single many level factor at the sub-plot level. My question is about properly specifying the random effects part of the model, lme( y ~ block + a*b*poly(c, n), random=~ ? ) Where 'a' and 'b' are my two level whole-plot factors and 'c' is the many level sub-plot factor. I'm not sure what to use to get the right error terms. Do I use two error terms: random = ~ 1 | block/a + 1 | block/b or one: random = ~ 1 | block/a*b or something else entirely? I haven't been able to find any relevant examples on Google. Thanks for any suggestions/pointers. -- Joshua Stults Website: http://j-stults.blogspot.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] making an Affybatch object for expresso
Hi All, I have microarray data that does not come in a CEL file. Currently it is in the form of columns = individual samples and rows = individual probes. There are about 79 columns and it is in a tab delimited text file. Is there a way to convert this file into an AffyBatch so that I can run expresso with it? Thanks, George __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PGF Device
No I haven't done that, and of course, you're right. I'll do that. But I still wish there was a way to generate PGF code directly. Lasse Am Donnerstag, den 07.05.2009, 13:28 -0600 schrieb Greg Snow: Have you contacted the author of eps2pgf? A while back I had a plot generated by R that produced an error in eps2pgf, I sent a copy of it to the author of eps2pgf and within a couple of days he sent me a new version that worked with my plot. But he cannot fix problems that he does not know about. -- Lasse Bombien Institut für Phonetik und Sprachverarbeitung Schellingstraße 3/II D-80799 München email: la...@phonetik.uni-muenchen.de web: http://www.phonetik.uni-muenchen.de/~lasse phone: +49 (0) 89 2180 2812 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] PGF Device
In fact, eps2pgf worked fine in my example after building it from svn. Am Donnerstag, den 07.05.2009, 13:28 -0600 schrieb Greg Snow: Have you contacted the author of eps2pgf? A while back I had a plot generated by R that produced an error in eps2pgf, I sent a copy of it to the author of eps2pgf and within a couple of days he sent me a new version that worked with my plot. But he cannot fix problems that he does not know about. -- Lasse Bombien Institut für Phonetik und Sprachverarbeitung Schellingstraße 3/II D-80799 München email: la...@phonetik.uni-muenchen.de web: http://www.phonetik.uni-muenchen.de/~lasse phone: +49 (0) 89 2180 2812 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 properly shade the background panels of an xyplot?
Hi: Here is simplified example of what I am having trouble with: I want to set the gray shade of the background of each panel of a xyplot with its mean. My aim is to be able to compare at a glance which panel has the highest mean. But, in order to achieve this I have to normalize the means between 0 and 1. The normalization is necessary to stay within the valid range for the gray() command. I can’t figure out how to do it :-( Here is an example where I use max(Oats$yield) (the all around maximum value) to normalize. Note that what I am looking for is an expression what would mean something like this as max(mean of every panel) # Start Example, just copy and paste data(Oats, package = MEMSS) tp1.oats - xyplot(yield ~ nitro | Variety + Block, data = Oats, panel = function(x, y, subscripts, ...) { # How to normalize my heatmap metric with # the value of the panel that has maximum average ? # metric = eval(mean(y)/ max(mean-of-each-panel) metric = eval(mean(y)/max(Oats$yield)) panel.fill(col = gray(metric)) panel.lines(x,y) } ) print(tp1.oats) # End Example Does anybody have any suggestion how I can get max(mean-of-each-panel) ? Thanks PS: Deepayan THANKS to your reply to my previous email it was exactly what I needed. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.