Re: [R] survival object
On Sat, Apr 9, 2011 at 7:36 PM, Eugenio Larios elari...@email.arizona.edu wrote: Hi All, I am trying to do a survivorship analysis with library(survival)from a data set that looks like this: I followed a bunch of naturally germinated seedlings of an annual plant from germination to death (none made it to reproduce, and died in a period of ~60 days after germination.) I also know the size of the seed of every individual censused. So I am trying to analyze seedling survival as a function of seed size. I performed 5 censuses in unequal intervals of time starting 15 days after germination until everyone died. Does that make my data right censored? So I have the following variables: seed size (as a continuous variable and as a categorized variable in big and small with 0=small and 1=big), the 5 census events (with 0=dead 1=survivors) First, I want to make a survival object with Surv() but apparently this function only takes two intervals of time (time, and time2). Is there a way to include my five census events in it? I could be wrong, but I think the form for your intervals should be: Surv(start, stop, event) depending how your data is stored, you may need to reshape it to a format amenable to this (e.g., ?reshape (the function) or reshape/reshape2 (the packages)). With the survival object I can go on and fit a model with survfit(survivalobject~seedsize,data=mydata), right? Yes. Although it makes the single call a bit long, I kind of like to locate the call to Surv() within survfit(), so that it is evaluated in an environment including the variables in mydata. Just to avoid repeatedly typing mydata or attach()ing it Cheers, Josh thanks -- Eugenio Larios PhD Student University of Arizona. Ecology Evolutionary Biology. elari...@email.arizona.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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] Package mice: Error in if (meth[j] != ) { : argument is of length zero
On Fri, Apr 8, 2011 at 2:56 PM, Rita Carreira ritacarre...@hotmail.com wrote: Dear R users, I am using package mice and I am getting the error Error in if (meth[j] != ) { : argument is of length zero. I have tried using several different versions of R (even the one that will be coming out this month) to no avail. I am using RStudio as my interface with R. Also note that I had run this a couple of days ago and it was working fine; I can't, however, remember the version of R that I was using but it was either R-2.11.1 or R-2.12.1. Please find below my code and error. Any thoughts or ideas? library(mice) # setting up the default settings for the imputation ini - mice(NewPrimal, Without NewPrimal, we cannot reproduce what you are seeing (this is where small sample datasets are helpful). seed = 52275, method = norm, maxit=0, pred = quickpred(NewPrimal, mincor = 0.25, minpuc = 0.95, include = c(D1, D2, D3, Qtr1, Qtr2, Qtr3, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec), exclude = c(ActualWeekEndingDate, Date, Year)), print=FALSE) Error in if (meth[j] != ) { : argument is of length zero You can get more details right after the error by typing: traceback() a quick grep of the mice code suggests the error forcing an exit may occur around line 155. You might be able to do something like: fix(mice) and then add a browser() call in somewhere before line 155 and then poke around to get a better sense of what is going on. Cheers, Josh Thank you so very much! Rita If you think education is expensive, try ignorance--Derek Bok [[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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] look for the package of latent class stochastic frontier
Dear all, I want to finished my paper by latent class Stochastic Frontier Analysis , but i can not find the package, is there anyone that may help me Thanks a lot. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Converting edgelist to symmetric matrix
Hi, I have network data in the form of a couple of edgelists containing weights in the format x,y,weight whereby x represents row header and y represents column header. All edgelists are based on links among 634 nodes and I need to convert them into a 634*634 weighted matrix. I searched for online help using possible keywords I know, but I could not find a clue how to do this in R. Any help will be appreciated. Best regards, Shafique [[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] system() command in R
Thank you all for the suggestions. I've been trying different things to make this work. Mike I did try what you suggested . It would work normally But i guess here the problem is my local server itself. It by default takes time to start and nothing I do is helping . So I came up with the idea to communicate with the server through R-java connection. I am halfway through that , I hope it works:) Thank you all for the response. On Tue, Apr 5, 2011 at 4:36 PM, Jeff Newmiller jdnew...@dcn.davis.ca.uswrote: The ampersand is a good idea, but nohup is best avoided in scripts. Rather the server itself should handle the transition to daemon status to avoid ending up with many duplicate server processes running. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Mike Marchywka marchy...@hotmail.com wrote: -- Date: Tue, 5 Apr 2011 13:37:12 +0530 From: nandan.a...@gmail.com To: rasanpreet.k...@gmail.com CC: r-help@r-project.org Subject: Re: [R] system() command in R On 4 April 2011 16:54, rasanpreet kaur suri wrote: Hi all, I have a local server insalled on my system and have to start that from within my R function. here is how I start it: cmd-sh start-server.sh system(cmd, wait=FALSE) My function has to start the server and proceed with further steps. The server starts but the further steps of the program are not executed.The cursor keeps waiting after the server is started. How r u executing further steps after starting server, meant for server from R ?? i tried removing the wait=FALSE, but it still keeps waiting. I also tried putting the start-server in a separate function and my further script in a separate function and then run them together, but it still waits. The transition from the start of server to next step is not happening. Please help. I have been stuck on this for quite some time now. -- I hadn't done this in R but expect to do so soon. I just got done with some java code to do something similar and you can expect in any implementation these things will be system dependent. It often helps to have simple test cases to isolate the problem. Here I made a tst script called foo that takes a minute or so to exevute and generates some output. If I type system(./foo,wait=F) the prompt comes back right away but stdout seems to still go to my console and maybe stdin is not redicrected either and it could eat your input ( no idea, but this is probably not what you want). I did try this that could fix your problem, on debian anyway it seems to work, system(nohup ./foo ) you can man nohup for details. Rasanpreet Kaur [[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. -- Amar Kumar Nandan Karnataka, India, 560100 http://aknandan.co.nr [[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 listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Rasanpreet Kaur [[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] MLE where loglikelihood function is a function of numerical solutions
Hi there, I'm trying to solve a ML problem where the likelihood function is a function of two numerical procedures and I'm having some problems figuring out how to do this. The log-likelihood function is of the form L(c,psi) = 1/T sum [log (f(c, psi)) - log(g(c,psi))], where c is a 2xT matrix of data and psi is the parameter vector. f(c, psi) is the transition density which can be approximated. The problem is that in order to approximate this we need to first numerically solve 3 ODEs. Second, numerically solve 2 non-linear equations in two unknowns wrt the data. The g(c,psi) function is known, but dependent on the numerical solutions. I have solved the ODEs using the deSolve package and the 2 non-linear equations using the BB package, but the results are dependent on the parameters. How can I write a program that will maximise this log-likelihood function, taking into account that the numerical procedures needs to be updated for each iteration in the maximization procedure? Any help will be much appreciated. Kristian [[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] maxLik package.
Dear Sir/ Madam, I have some enquiry in R about maxLik package where, in this package we have the usage maxLik(logLik, grad, hess, start, method, iterlim, print.level) when I used this with print.level equals to 3 I could have estimates of parameters at each iteration but I do not know how can I call the information in the level. Is there any way can help me to call the information within the print. level argument?. Also when I changed the number of iterlim argument to one or zero for example I got the same estimates of parameters at print. level but with message that Iteration limit exceeded. So what is the meaning of this message and how may it effect my results? and if I change the number of iterlim to get the estimates of parameters that I need at this number is it reasonable?. Thank 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] Duncan's multiple range test
Hello; nbsp; I don't find quantile function of duncan's multiple range test. nbsp; Example nbsp; quantile function of Tukey test is qtukey(...). What is quantile functionnbsp;fornbsp;Duncan's multiple range test? If you help me, i am very happy. nbsp; Thanks. Facebook ve Twitter hesaplarýný tek yerden güncelle, anýnda paylaþ! Hemen týkla! [[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] Multinomial Logit Model with lots of Dummy Variables
Hi All, I am attempting to build a Multinomial Logit model with dummy variables of the following form: Dependent Variable : 0-8 Discrete Choices Dummy Variable 1: 965 dummy varsgh...@student.monash.edu.augh@gp1.com Dummy Variable 2: 805 dummy vars The data set I am using has the dummy columns pre-created, so it's a table of 72,381 rows and 1770 columns. The first 965 columns represent the dummy columns for Variable 1 The next 805 columns represent the dummy columns for Variable 2 My code to build the mlogit model looks like the following. I want to know...is there a better way of doing this without these huge equations? (I probably also need a more powerful PC to do all of this). I'll also want to perform a joint test of significance on the first 805 coefficients... Is this possible? Thanks GP [code] #install MLOGIT library(mlogit) #load mydata mydata = 0 mydata-read.csv(file=G:\\data.csv,head=TRUE) my_data=0 num.rows=length(mydata[,1]) num.cols=965+805+1 my_data=matrix(0,nr=num.rows,nc=num.cols) for(i in 1:num.rows) { nb=mydata[i,2] np=mydata[i,3] my_data[i,nb]=1 my_data[i,965+np]=1 my_data[i,1+1770]=mydata[i,1] } #convert matrix to data.frame # convert to data frame my_data_frame-as.data.frame(my_data) #check data frame headers head(my_data_frame) #load dataframe into mldata with choice variable mldata-mlogit.data(my_data_frame, varying=NULL, choice=V1771, shape=wide) #V1771 = dependent var #V1-V965 = variable 1 dummies #V966-V1700 = variable 2 dummies #regress V1771 against all 1700 variables... mlogit.model-mlogit(V1771~0|V1+V2+V3...+V1700,data=mldata, reflevel=0) [/code] -- View this message in context: http://r.789695.n4.nabble.com/Multinomial-Logit-Model-with-lots-of-Dummy-Variables-tp3439492p3439492.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] Adding text labels to lattice plots with multiple panels
Hi Peter, Thanks for the solutions. The only problem now is that I have duplicate values in my labels that are removed by the duplicated function. Perhaps a better example of the labels vector would be: lab - c(1,2,4,4,6,6) Your first version would maintain the second 4 (because they are in different panels) but leave a blank for the second 6. 1 2 4 4 6 The second version removes the second 4 and 6. 1 2 4 6 The following works, but it is not very efficient for my full data set with six levels of f1, two levels of f2, and 64 replicates of each of these combinations. bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab - df$lab[subscripts] lab[c(2:3,5:6,8:9)] - panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Thanks, Jeff On Sat, Apr 9, 2011 at 7:52 PM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2011-04-09 06:21, Dennis Murphy wrote: Hi: One hopes that there is a more elegant solution than this bit of ad-hockery. From your posted example: f1- c(rep(c(rep(a, 3), rep(b, 3), rep(c, 3)), 2)) f2- c(rep(A, 9), rep(B, 9)) dv- c(0.9, 0.8, 0.85, 0.6, 0.65, 0.7, 0.8, 0.85, 0.8, 0.95, 0.85, 0.9, 0.65, 0.7, 0.75, 0.85, 0.9, 0.85) df- data.frame(f1, f2, dv) df$lab- rep(1:6, each = 3) df$lab2- '' df$lab2[seq(1, 16, by = 3)]- 1:6 # adapt to your situation - seq(1, nrow(df) - 63, by = 64), perhaps bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab2[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Alternatively, panel.text() takes an alpha = argument; for example, bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab, alpha = 0.5) } ) You could toy with the value of alpha until something acceptable emerges. But as I said, there is probably a better solution and I'm happy to be educated if there is. Here's a slight variation on your first solution which doesn't require the data to be appropriately sorted, using your df: bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab - df$lab[subscripts] lab[duplicated(lab)] - panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) and another variation which sets the text positions to NA for all but the first pass through the panel.text() function: bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { at.y - rep(0.55, nrow(df)) is.na(at.y) - which(duplicated(df$lab)) panel.bwplot(x, y, ...) panel.text(x, at.y[subscripts], labels = df$lab[subscripts]) } ) I think that the alpha argument is too one-off, i.e. dependent on how many levels in the boxplot. Peter Ehlers HTH, Dennis On Sat, Apr 9, 2011 at 4:56 AM, Jeff Stevensstev0...@googlemail.comwrote: Hi, Thanks for the work around, Dennis. My actual data set has 64 replicates for each factor level combination (rather than the 3 in the example), so the overplotting is quite messy. Any ideas on how to avoid the overplotting? Jeff On Fri, Apr 8, 2011 at 7:32 PM, Dennis Murphydjmu...@gmail.com wrote: Hi: After a number of false starts, I finally consulted Deepayan's book and the example on p. 73, suitably adapted, yielded a solution. Add a variable for the labels and then... df$lab- rep(1:6, each = 3) bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) If you look closely, you'll see that each label is overplotted three times. A similar plot in ggplot2 would be library(ggplot2) ggplot(df, aes(x = f1, y = dv)) + geom_boxplot() + geom_text(aes(x = as.numeric(f1), lab = lab), y = 0.55, alpha = 0.5) + facet_wrap( ~ f2) + ylim(0.5, 1) The alpha argument in geom_text() is designed to mitigate the overplotting effect somewhat. HTH, Dennis On Fri, Apr 8, 2011 at 5:32 AM, Jeff Stevensstev0...@googlemail.com wrote: Hi, I am trying to add text to the bottom of a lattice bwplot with multiple panels. I would like to add a label below each boxplot, but the labels do not come from the data. I've tried the following, code: f1- c(rep(c(rep(a, 3), rep(b, 3), rep(c, 3)), 2)) f2- c(rep(A, 9), rep(B, 9)) dv- c(0.9, 0.8, 0.85, 0.6, 0.65, 0.7, 0.8, 0.85, 0.8, 0.95, 0.85, 0.9, 0.65, 0.7, 0.75, 0.85, 0.9, 0.85) df- data.frame(f1, f2, dv) lab- c(1, 2, 3, 4, 5, 6) bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ...) { panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) I have two problems. First, the label values are writing over one another. I wrote a horrible hack (below) that fixes that
[R] Fwd: open.exe Virus W32.ATRAPS
Hello, I am not sure if this is the correct mailing list to send this email... I was trying to install on windows XP latest R-2.12.2 and my unvirus program (Immunet 3.0) reports a virus at open.exe while this is unpacked: W32.ATRAPS Has anyone come across the same problem? Best, Costas [[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 in cluster MPI and R
Hi, ImountedanMPIclusterwithdebian.I installedthepackagesnecessarytorunusingRinthiscluster,butunsuccessfully, thefunctionsofexampleswere runbutonlyin theserver processorin the cluster.I thinkitlacks an essentialconfigurationofR packagesfor him tocommunicatewith thecluster.AnyoneknowanymorebasictutorialforusingRin thiscluster?Theclusteralreadyexistsand is functioning. Anyhelp iswelcome. Thanks Ronaldo -- 2ª lei - Na pesquisa, o que importa é o que está correto, e não quem está correto. --Herman, I. P. 2007. Following the law. NATURE, Vol 445, p. 228. Prof. Ronaldo Reis Júnior | .''`. UNIMONTES/DBG/Lab. Ecologia Comportamental e Computacional | : :' : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia | `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil | `- Fone: (38) 3229-8192 | ronaldo.r...@unimontes.br | http://www.ppgcb.unimontes.br/lecc | LinuxUser#: 205366 [[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] Multinomial Logit Model with lots of Dummy Variables
If you are just looking to collapse the dummy variables into two factor variables, the following will work. ## Generate some example data set.seed(1234) n - 100 # Generate outcome outcome - rbinom(n, 3, 0.5) colnames(exposures) - paste(V, seq(1:10), sep = ) #Generate dummy variables for A and B A - t(apply(matrix(nrow = 100, ncol = 5), 1, function(x) { sample(c(1, 0, 0, 0, 0)) })) B - t(apply(matrix(nrow = 100, ncol = 5), 1, function(x) { sample(c(1, 0, 0, 0, 0)) })) # Combine into data frame dat - data.frame(outcome, A, B) names(dat) - c('outcome', paste(A, seq(1:5), sep = ), paste(B, seq(1:5), sep = )) head(dat) ## Collapse dummies to factor variable A - apply(dat, 1, function(x) { A - x[2:6] A.names - names(x[2:6]) A.value - A.names[A==1] return(A.value) }) B - apply(dat, 1, function(x) { B - x[7:11] B.names - names(x[7:11]) B.names B.value - B.names[B==1] return(B.value) }) # Combine into new data frame dat.new - data.frame(dat$outcome, A, B) head(dat.new) Jeremy __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] set locale information in R
Hi Uwe, Thank you very much.. That worked :) Regards, Raji 2011/4/9 Uwe Ligges lig...@statistik.tu-dortmund.de Try Sys.setenv(LANGUAGE=Fr) Uwe Ligges On 07.04.2011 10:29, Raji wrote: Hi R-helpers, Is it possible to localise the error messages/warnings that comes from R.My application takes in a locale information.I used the following command to set the locale in R.But in RGui, i still get the error messages in English only.Can you please help me out with this? Sys.setlocale(LC_ALL, French) Regards, Raji -- View this message in context: http://r.789695.n4.nabble.com/set-locale-information-in-R-tp3432760p3432760.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[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] Adding text labels to lattice plots with multiple panels
On 2011-04-10 04:50, Jeff Stevens wrote: Hi Peter, Thanks for the solutions. The only problem now is that I have duplicate values in my labels that are removed by the duplicated function. Perhaps a better example of the labels vector would be: lab- c(1,2,4,4,6,6) Your first version would maintain the second 4 (because they are in different panels) but leave a blank for the second 6. 1 2 4 4 6 The second version removes the second 4 and 6. 1 2 4 6 The following works, but it is not very efficient for my full data set with six levels of f1, two levels of f2, and 64 replicates of each of these combinations. bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] lab[c(2:3,5:6,8:9)]- panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Good point; I hadn't thought of that. Now I realize that a solution that fiddles with the labels inside the panel function is likely to be less efficient anyway. So let's adjust the labels to be printed before we do the bwplot() call. What's needed is to set to blanks the labels that are duplicates because they correspond to duplicated (f1,f2) combinations. ## add an adjusted labels variable to the data; ## lab is the current vector of labels; names(df) #[1] f1 f2 dv lab df - transform(df, lab2 = ifelse(duplicated(df[, c(f1,f2)]), , lab)) ## now use lab2 in bwplot() bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab - df$lab2[subscripts] # note the lab2 panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Peter Ehlers Thanks, Jeff On Sat, Apr 9, 2011 at 7:52 PM, Peter Ehlersehl...@ucalgary.ca wrote: On 2011-04-09 06:21, Dennis Murphy wrote: Hi: One hopes that there is a more elegant solution than this bit of ad-hockery. From your posted example: f1- c(rep(c(rep(a, 3), rep(b, 3), rep(c, 3)), 2)) f2- c(rep(A, 9), rep(B, 9)) dv- c(0.9, 0.8, 0.85, 0.6, 0.65, 0.7, 0.8, 0.85, 0.8, 0.95, 0.85, 0.9, 0.65, 0.7, 0.75, 0.85, 0.9, 0.85) df- data.frame(f1, f2, dv) df$lab- rep(1:6, each = 3) df$lab2- '' df$lab2[seq(1, 16, by = 3)]- 1:6# adapt to your situation - seq(1, nrow(df) - 63, by = 64), perhaps bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab2[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Alternatively, panel.text() takes an alpha = argument; for example, bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab, alpha = 0.5) } ) You could toy with the value of alpha until something acceptable emerges. But as I said, there is probably a better solution and I'm happy to be educated if there is. Here's a slight variation on your first solution which doesn't require the data to be appropriately sorted, using your df: bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] lab[duplicated(lab)]- panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) and another variation which sets the text positions to NA for all but the first pass through the panel.text() function: bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { at.y- rep(0.55, nrow(df)) is.na(at.y)- which(duplicated(df$lab)) panel.bwplot(x, y, ...) panel.text(x, at.y[subscripts], labels = df$lab[subscripts]) } ) I think that the alpha argument is too one-off, i.e. dependent on how many levels in the boxplot. Peter Ehlers HTH, Dennis On Sat, Apr 9, 2011 at 4:56 AM, Jeff Stevensstev0...@googlemail.comwrote: Hi, Thanks for the work around, Dennis. My actual data set has 64 replicates for each factor level combination (rather than the 3 in the example), so the overplotting is quite messy. Any ideas on how to avoid the overplotting? Jeff On Fri, Apr 8, 2011 at 7:32 PM, Dennis Murphydjmu...@gmail.comwrote: Hi: After a number of false starts, I finally consulted Deepayan's book and the example on p. 73, suitably adapted, yielded a solution. Add a variable for the labels and then... df$lab- rep(1:6, each = 3) bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) If you look closely, you'll see that each label is overplotted three times. A similar plot in ggplot2 would be library(ggplot2) ggplot(df, aes(x = f1, y = dv)) + geom_boxplot() + geom_text(aes(x = as.numeric(f1), lab = lab), y = 0.55, alpha = 0.5) + facet_wrap( ~ f2) + ylim(0.5, 1) The alpha argument in geom_text() is designed to mitigate the overplotting effect somewhat. HTH,
[R] howto calculate column means in data frame
Long story short, I have a big iterative procedure that produces a long list of data.frames such as the one called results here. Is there an easy way to produce a similar list of data.frames comprised of the mean of each of the columns in results, such that it ends up like the one I've shown in resultsmean below? I've tried apply and lapply, still not got the correct arguments. As usual, TIA. Jim results [[1]] nameLOR23 BIA23 MSE23 H0R23 1 0.222 -1.012228 -0.0959370.0356501.00 2 0.222 -0.8363000.0799910.0423220.75 3 0.222 -0.5186310.3976590.2145930.50 [[2]] nameLOR23 BIA23 MSE23 H0R23 1 0.2211122 -0.7246300.1916600.051308 1 2 0.2211122 -0.7818120.1344780.033872 1 3 0.2211122 -0.5221090.3941810.1646280.75 would like resultsmean [[1]] nameLOR23 BIA23 MSE23 H0R23 1 0.222 -0.783330.12734 0.0971600.75 [[2]] nameLOR23 BIA23 MSE23 H0R23 1 0.2211122 -0.675660.2400 0.08266 0.916 === Dr. Jim Maas University of East Anglia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] howto calculate column means in data frame
Hi Jim, Using ?lapply with ?colMeans should do the trick. Here is a little sample: eg - list(mtcars, mtcars) # mtcars data frame twice in a list resultsmean - lapply(eg, colMeans) # calculate column means for each element of eg resultsmean # show the results Hope this helps, Josh On Sun, Apr 10, 2011 at 8:27 AM, Maas James Dr (MED) j.m...@uea.ac.uk wrote: Long story short, I have a big iterative procedure that produces a long list of data.frames such as the one called results here. Is there an easy way to produce a similar list of data.frames comprised of the mean of each of the columns in results, such that it ends up like the one I've shown in resultsmean below? I've tried apply and lapply, still not got the correct arguments. As usual, TIA. Jim results [[1]] name LOR23 BIA23 MSE23 H0R23 1 0.222 -1.012228 -0.095937 0.035650 1.00 2 0.222 -0.836300 0.079991 0.042322 0.75 3 0.222 -0.518631 0.397659 0.214593 0.50 [[2]] name LOR23 BIA23 MSE23 H0R23 1 0.2211122 -0.724630 0.191660 0.051308 1 2 0.2211122 -0.781812 0.134478 0.033872 1 3 0.2211122 -0.522109 0.394181 0.164628 0.75 would like resultsmean [[1]] name LOR23 BIA23 MSE23 H0R23 1 0.222 -0.78333 0.12734 0.097160 0.75 [[2]] name LOR23 BIA23 MSE23 H0R23 1 0.2211122 -0.67566 0.2400 0.08266 0.916 === Dr. Jim Maas University of East Anglia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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] howto calculate column means in data frame
jamaas wrote: Long story short, I have a big iterative procedure that produces a long list of data.frames such as the one called results here. Is there an easy way to produce a similar list of data.frames comprised of the mean of each of the columns in results, such that it ends up like the one I've shown in resultsmean below? I've tried apply and lapply, still not got the correct arguments. As usual, TIA. Jim results [[1]] nameLOR23 BIA23 MSE23 H0R23 1 0.222 -1.012228 -0.0959370.0356501.00 2 0.222 -0.8363000.0799910.0423220.75 3 0.222 -0.5186310.3976590.2145930.50 [[2]] nameLOR23 BIA23 MSE23 H0R23 1 0.2211122 -0.7246300.1916600.051308 1 2 0.2211122 -0.7818120.1344780.033872 1 3 0.2211122 -0.5221090.3941810.1646280.75 would like resultsmean [[1]] nameLOR23 BIA23 MSE23 H0R23 1 0.222 -0.783330.12734 0.0971600.75 [[2]] nameLOR23 BIA23 MSE23 H0R23 1 0.2211122 -0.675660.2400 0.08266 0.916 lapply(results, FUN=colMeans) Berend -- View this message in context: http://r.789695.n4.nabble.com/howto-calculate-column-means-in-data-frame-tp3439932p3439959.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] Orthoblique rotation on eigenvectors (SAS VARCLUS)
See the varclus function in the Hmisc package. Frank Axel Urbiz wrote: Hi All, I'd like to build a package for the community that replicates the output produced by SAS proc varclus. According to the SAS documentation, the first few steps are: 1. Find the first two principal components. 2. Perform an orthoblique rotation (quartimax rotation) on eigenvectors. 3. Assign each variable to the rotated component with which it has the higher squared correlation. The cartoon example below attempt to do this, but I found my results differ from SAS in pc3 (i.e, the standardize component scores). I'd appreciate your help in whether you see anything wrong in pc2 or pc3? set.seed(1) x1=rnorm(200); x2=0.9*x1; x3=0.7*x1; x4=x1*x1; x5=x1*x1*x1; x6=rnorm(200); x7=0.9*x6; x8=0.7*x6; x9=x6*x6; x10=x6*x6*x6; x - cbind(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) require(GPArotation) pc1 - princomp(x, cor = TRUE, scores = TRUE) pc2 - quartimax(pc1$loadings[,1:2],normalize=TRUE)$loadings pc3 - scale(x%*% pc2) pc4 - apply(x, 2, function(x) cor(x, pc3)^2) Thanks in advance for any help! Axel. [[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. - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Orthoblique-rotation-on-eigenvectors-SAS-VARCLUS-tp3438695p3440064.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] MLE where loglikelihood function is a function of numerical solutions
Hi Kristian The obvious approach is to treat it like any other MLE problem: evaluation of the log-likelihood is done as often as necessary for the optimizer you are using: eg a call to optim(psi,LL,...) where LL(psi) evaluates the log likelihood at psi. There may be computational shortcuts that would work if you knew that LL(psi+eps) were well approximated by LL(psi), for the values of eps used to evaluate numerical derivatives of LL. Of course, then you might need to write your own custom optimizer. albyn Quoting Kristian Lind kristian.langgaard.l...@gmail.com: Hi there, I'm trying to solve a ML problem where the likelihood function is a function of two numerical procedures and I'm having some problems figuring out how to do this. The log-likelihood function is of the form L(c,psi) = 1/T sum [log (f(c, psi)) - log(g(c,psi))], where c is a 2xT matrix of data and psi is the parameter vector. f(c, psi) is the transition density which can be approximated. The problem is that in order to approximate this we need to first numerically solve 3 ODEs. Second, numerically solve 2 non-linear equations in two unknowns wrt the data. The g(c,psi) function is known, but dependent on the numerical solutions. I have solved the ODEs using the deSolve package and the 2 non-linear equations using the BB package, but the results are dependent on the parameters. How can I write a program that will maximise this log-likelihood function, taking into account that the numerical procedures needs to be updated for each iteration in the maximization procedure? Any help will be much appreciated. Kristian [[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] MLE where loglikelihood function is a function of numerical solutions
to clarify: by if you knew that LL(psi+eps) were well approximated by LL(psi), for the values of eps used to evaluate numerical derivatives of LL. I mean the derivatives of LL(psi+eps) are close to the derivatives of LL(psi), and perhaps you would want the hessian to be close as well. albyn Quoting Albyn Jones jo...@reed.edu: Hi Kristian The obvious approach is to treat it like any other MLE problem: evaluation of the log-likelihood is done as often as necessary for the optimizer you are using: eg a call to optim(psi,LL,...) where LL(psi) evaluates the log likelihood at psi. There may be computational shortcuts that would work if you knew that LL(psi+eps) were well approximated by LL(psi), for the values of eps used to evaluate numerical derivatives of LL. Of course, then you might need to write your own custom optimizer. albyn Quoting Kristian Lind kristian.langgaard.l...@gmail.com: Hi there, I'm trying to solve a ML problem where the likelihood function is a function of two numerical procedures and I'm having some problems figuring out how to do this. The log-likelihood function is of the form L(c,psi) = 1/T sum [log (f(c, psi)) - log(g(c,psi))], where c is a 2xT matrix of data and psi is the parameter vector. f(c, psi) is the transition density which can be approximated. The problem is that in order to approximate this we need to first numerically solve 3 ODEs. Second, numerically solve 2 non-linear equations in two unknowns wrt the data. The g(c,psi) function is known, but dependent on the numerical solutions. I have solved the ODEs using the deSolve package and the 2 non-linear equations using the BB package, but the results are dependent on the parameters. How can I write a program that will maximise this log-likelihood function, taking into account that the numerical procedures needs to be updated for each iteration in the maximization procedure? Any help will be much appreciated. Kristian [[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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] list to data frame
I need to make a data frame out of the data that I currently have in a list. This works, but is ugly: ineffData-rbind(ineffFilesList[[1]], ineffFilesList[[2]], ineffFilesList[[3]], ineffFilesList[[4]], ineffFilesList[[5]], ineffFilesList[[6]], ineffFilesList[[7]], ineffFilesList[[8]], ineffFilesList[[9]], ineffFilesList[[10]], ineffFilesList[[11]], ineffFilesList[[12]], ineffFilesList[[13]], ineffFilesList[[14]], ineffFilesList[[15]], ineffFilesList[[16]], ineffFilesList[[17]], ineffFilesList[[18]], ineffFilesList[[19]], ineffFilesList[[20]], ineffFilesList[[21]], ineffFilesList[[22]], ineffFilesList[[23]], ineffFilesList[[24]], ineffFilesList[[25]], ineffFilesList[[26]], ineffFilesList[[27]]) What's an efficient way of doing this such that the computer will do the work of recurring through the list of elements of ineffFilesList? Much appreciation, Frank Tamborello, PhD W. M. Keck Postdoctoral Fellow School of Biomedical Informatics University of Texas Health Science Center at Houston __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] list to data frame
Hi Franklin, Try do.call(rbind, ineffFilesList) See ?do.call for more details. HTH, Jorge On Sun, Apr 10, 2011 at 2:01 PM, Franklin Tamborello II wrote: I need to make a data frame out of the data that I currently have in a list. This works, but is ugly: ineffData-rbind(ineffFilesList[[1]], ineffFilesList[[2]], ineffFilesList[[3]], ineffFilesList[[4]], ineffFilesList[[5]], ineffFilesList[[6]], ineffFilesList[[7]], ineffFilesList[[8]], ineffFilesList[[9]], ineffFilesList[[10]], ineffFilesList[[11]], ineffFilesList[[12]], ineffFilesList[[13]], ineffFilesList[[14]], ineffFilesList[[15]], ineffFilesList[[16]], ineffFilesList[[17]], ineffFilesList[[18]], ineffFilesList[[19]], ineffFilesList[[20]], ineffFilesList[[21]], ineffFilesList[[22]], ineffFilesList[[23]], ineffFilesList[[24]], ineffFilesList[[25]], ineffFilesList[[26]], ineffFilesList[[27]]) What's an efficient way of doing this such that the computer will do the work of recurring through the list of elements of ineffFilesList? Much appreciation, Frank Tamborello, PhD W. M. Keck Postdoctoral Fellow School of Biomedical Informatics University of Texas Health Science Center at Houston __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fwd: open.exe Virus W32.ATRAPS
On Apr 10, 2011, at 15:10 , Costas Vorlow wrote: Hello, I am not sure if this is the correct mailing list to send this email... I was trying to install on windows XP latest R-2.12.2 and my unvirus program (Immunet 3.0) reports a virus at open.exe while this is unpacked: W32.ATRAPS Has anyone come across the same problem? Yes, with Avira and 2.12.0. It was a false positive. See http://finzi.psych.upenn.edu/Rhelp10/2010-October/256518.html -- Peter Dalgaard Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd@cbs.dk Priv: pda...@gmail.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] By function
Liviu, Thanks for your attention and help! Sorry for attached csv file, I didn't read R-Help Posting guide careful. Another R-helper thaught me use de dput() function, and this output are in email's end. Your correction in my code works pretty well!! Now I can understand a little more how the R think! Thanks a lot! Also thanks for the suggetion to use sessionInfo(). I will do that on next questions to list. All best, and thanks very much again, Raoni The dput() of data is: structure(list(Data = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L), .Label = c(2011-02-04, 2011-02-05, 2011-02-07, 2011-02-08, 2011-02-09, 2011-02-10, 2011-02-11, 2011-02-14, 2011-02-15, 2011-02-16, 2011-02-17, 2011-02-18, 2011-02-21, 2011-02-22, 2011-02-23, 2011-02-24, 2011-02-25, 2011-02-28, 2011-03-01, 2011-03-02, 2011-03-03, 2011-03-04, 2011-03-10, 2011-03-11, 2011-03-14, 2011-03-15, 2011-03-16, 2011-03-17, 2011-03-28, 2011-03-29, 2011-03-30, 2011-03-31, 2011-04-01, 2011-04-04, 2011-04-05, 2011-04-06, 2011-04-07 ), class = factor), Fisherman = structure(c(5L, 1L, 2L, 5L, 1L, 2L, 1L, 2L, 5L, 5L, 2L, 1L, 2L, 5L, 1L, 2L, 5L, 1L, 5L, 5L, 2L, 1L, 5L, 1L, 2L, 5L, 1L, 2L, 5L, 1L), .Label = c(Yellow, Blue, White, Green, Red), class = factor), N = c(0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c(Date, Fisherman, N), row.names = c(NA, 30L), class = data.frame) 2011/4/9 Liviu Andronic landronim...@gmail.com: Hello On Fri, Apr 8, 2011 at 12:38 AM, Raoni Rodrigues caciquesamu...@gmail.com wrote: Hello all! I have a data frame with nine variables and 293 cases. (attached goes the csv file). The CSV didn't get through so it's difficult to replicate your example. Please post the output of: str(cpue) I need to calculate a index using the sum of one variable (N) divided by the length of other variable (Fisherman), but for each day (Date). I tried to use that codes: by (cpue, cpue$Date, function (x) sum (cpue$N)/length(cpue$Fisherman)) [..] In both codes, as result, I received the same value for all Date value. And, oddly, this result is the value of calculation for all data frame, as I used just: sum (cpue$N)/length(cpue$Fishermans) From the code above, this is expected since in the function() statement you use the entire df (cpue) and not the subset (x). Try this: by (cpue, cpue$Date, function (x) sum (x$N)/length(x$Fisherman)) Sorry for the basic question, but I worked on this simple code all day and can't do it work out! And have no idea why... I'm using R 2.11 in Windows XP. It is often a good a idea to post the output of sessionInfo() Regards Liviu Since now, thanks for the attention and all help, Best, Raoni __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Do you know how to read? http://www.alienetworks.com/srtest.cfm http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader Do you know how to write? http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding text labels to lattice plots with multiple panels
On 2011-04-10 12:19, Jeff Stevens wrote: Many thanks, Peter. This works brilliantly, and I prefer to have the labels assigned outside of panel function as well. Cheers, Jeff Small add-on: It's probably best to ensure that the labels are of type character, not factor. Peter [...snip...] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] list to data frame
On Sun, Apr 10, 2011 at 06:01:39PM +, Franklin Tamborello II wrote: I need to make a data frame out of the data that I currently have in a list. This works, but is ugly: ineffData-rbind(ineffFilesList[[1]], ineffFilesList[[2]], ineffFilesList[[3]], ineffFilesList[[4]], ineffFilesList[[5]], ineffFilesList[[6]], ineffFilesList[[7]], ineffFilesList[[8]], ineffFilesList[[9]], ineffFilesList[[10]], ineffFilesList[[11]], ineffFilesList[[12]], ineffFilesList[[13]], ineffFilesList[[14]], ineffFilesList[[15]], ineffFilesList[[16]], ineffFilesList[[17]], ineffFilesList[[18]], ineffFilesList[[19]], ineffFilesList[[20]], ineffFilesList[[21]], ineffFilesList[[22]], ineffFilesList[[23]], ineffFilesList[[24]], ineffFilesList[[25]], ineffFilesList[[26]], ineffFilesList[[27]]) What's an efficient way of doing this such that the computer will do the work of recurring through the list of elements of ineffFilesList? as.data.frame(ineffFilesList) cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan Maximus-von-Imhof-Forum 3 85354 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Converting edgelist to symmetric matrix
Date: Sat, 9 Apr 2011 14:34:28 -0700 From: kmshafi...@yahoo.com To: r-help@r-project.org Subject: [R] Converting edgelist to symmetric matrix Hi, I have network data in the form of a couple of edgelists containing weights in the format x,y,weight whereby x represents row header and y represents column header. All edgelists are based on links among 634 nodes and I need to convert them into a 634*634 weighted matrix. not find a clue how to do this in R. Any help will be appreciated. I'm trying to do something related and found ?read.graph will format=ncol do what you need? This apparently creates a graph object that likely has capacilities you need. Again, I haven't actually used any of this just found while trying to solve a different problem. 'It is a simple text file with one edge per line. An edge is defined by two symbolic vertex names separated by whitespace. (The symbolic vertex names themselves cannot contain whitespace. They might followed by an optional number, this will be the weight of the edge; the number can be negative and can be in scientific notation. If there is no weight specified to an edge it is assumed to be zero. ' Best regards, Shafique __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitting controlled released data
Hi, I am new to the forum/mailing list. I have been using R for a while and I find it incredible. I was just wondering whether someone has ever written a library to calculate the best fit of experimental data to some controlled release models, having only the release cumulative drug release at given time points. For example, there is an extension for SigmaPlot http://www.sigmaplot.co.uk/products/sigmaplot/productuses/prod-uses15.php which allows rapid fitting of 5 standard model. I prefer to use free software and therefore I rather use R than Sigma Plot. Is there anyone who can help? Thank you very much Marco -- View this message in context: http://r.789695.n4.nabble.com/Fitting-controlled-released-data-tp3440303p3440303.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question about levels/as.numeric
Hi, I am still new to R and this is my first post on this mailing-list. I have two .csv (each one being a column of real numbers) coming from the same database (the first one is just longer than the second) and I read them in R the following way: returns - read.csv(test.csv, header = FALSE) returns2 - read.csv(test2.csv, header = FALSE) However, the two objects clearly don't seem to be equivalent: returns[2528:2537,1] [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 7470 Levels: -0.78 -0.85 -0.86 -0.0001 -0.000112 -0.000115 -0.000152 -0.000154 -0.000157 -0.00016 -0.000171 -0.000185 -0.000212 -0.000238 -0.000256 -0.000259 -0.000263 -0.000273 ... C returns2[1:10,1] [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 as.numeric(returns[2528:2537,1]) [1] 341 7444 2244 5149 787 1717 5251 4122 3878 1811 as.numeric(returns2[1:10,1]) [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 I would like to understand what's happening and how to handle the longer one. This problem may seem stupid, but I've been trying to figure it out for a while and nothing seems to work. I checked in excel and both seems to be completely normal lists of real numbers). What am I missing here? What are those levels and why the as.numeric doesn't work the same with the longer one? My final goal is to extract small parts of those columns the following way: cbind(returns[which(names == id)[2528:2537],1]) [,1] [1,] 341 [2,] 7444 [3,] 2244 [4,] 5149 [5,] 787 [6,] 1717 [7,] 5251 [8,] 4122 [9,] 3878 [10,] 1811 Wich should be equivalent to: cbind(returns2[which(names == id)[1:10],1]) [,1] [1,] -0.002206 [2,] 0.115696 [3,] -0.015192 [4,] 0.008719 [5,] -0.004654 [6,] -0.010688 [7,] 0.009453 [8,] 0.002676 [9,] 0.001334 [10,] -0.011326 Thanks a lot, Thibault - *Thibault Vatter* EPFL- Master, 1ère année Laboratory of Statistical Biophysics http://lbs.epfl.ch/ Tel: +41 78 820 18 64 @: thibault.vat...@epfl.ch Web: http://personnes.epfl.ch/thibault.vatter *Please consider the environment before printing this email.* [[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] Password-protect R script files
There was a question in R forum very long time back.. on how to protect R Script files from inadvertent editing by users. There is a way to do this from within R, atleast in Windows XP I have tried this and it certainly works , The method is very different from the OS based folder protection route, however making available such a method in the open forum would only kill the very spirit of R. But if someone is able to convince me the genuineness of his reasons to achieve such a purpose, I might decide to provide selective service to achieve the same. Regards Vijayan Padmanabhan [[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] Adding text labels to lattice plots with multiple panels
Many thanks, Peter. This works brilliantly, and I prefer to have the labels assigned outside of panel function as well. Cheers, Jeff On Sun, Apr 10, 2011 at 5:18 PM, Peter Ehlers ehl...@ucalgary.ca wrote: On 2011-04-10 04:50, Jeff Stevens wrote: Hi Peter, Thanks for the solutions. The only problem now is that I have duplicate values in my labels that are removed by the duplicated function. Perhaps a better example of the labels vector would be: lab- c(1,2,4,4,6,6) Your first version would maintain the second 4 (because they are in different panels) but leave a blank for the second 6. 1 2 4 4 6 The second version removes the second 4 and 6. 1 2 4 6 The following works, but it is not very efficient for my full data set with six levels of f1, two levels of f2, and 64 replicates of each of these combinations. bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] lab[c(2:3,5:6,8:9)]- panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Good point; I hadn't thought of that. Now I realize that a solution that fiddles with the labels inside the panel function is likely to be less efficient anyway. So let's adjust the labels to be printed before we do the bwplot() call. What's needed is to set to blanks the labels that are duplicates because they correspond to duplicated (f1,f2) combinations. ## add an adjusted labels variable to the data; ## lab is the current vector of labels; names(df) #[1] f1 f2 dv lab df - transform(df, lab2 = ifelse(duplicated(df[, c(f1,f2)]), , lab)) ## now use lab2 in bwplot() bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab - df$lab2[subscripts] # note the lab2 panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Peter Ehlers Thanks, Jeff On Sat, Apr 9, 2011 at 7:52 PM, Peter Ehlersehl...@ucalgary.ca wrote: On 2011-04-09 06:21, Dennis Murphy wrote: Hi: One hopes that there is a more elegant solution than this bit of ad-hockery. From your posted example: f1- c(rep(c(rep(a, 3), rep(b, 3), rep(c, 3)), 2)) f2- c(rep(A, 9), rep(B, 9)) dv- c(0.9, 0.8, 0.85, 0.6, 0.65, 0.7, 0.8, 0.85, 0.8, 0.95, 0.85, 0.9, 0.65, 0.7, 0.75, 0.85, 0.9, 0.85) df- data.frame(f1, f2, dv) df$lab- rep(1:6, each = 3) df$lab2- '' df$lab2[seq(1, 16, by = 3)]- 1:6 # adapt to your situation - seq(1, nrow(df) - 63, by = 64), perhaps bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab2[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) Alternatively, panel.text() takes an alpha = argument; for example, bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab, alpha = 0.5) } ) You could toy with the value of alpha until something acceptable emerges. But as I said, there is probably a better solution and I'm happy to be educated if there is. Here's a slight variation on your first solution which doesn't require the data to be appropriately sorted, using your df: bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] lab[duplicated(lab)]- panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) and another variation which sets the text positions to NA for all but the first pass through the panel.text() function: bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { at.y- rep(0.55, nrow(df)) is.na(at.y)- which(duplicated(df$lab)) panel.bwplot(x, y, ...) panel.text(x, at.y[subscripts], labels = df$lab[subscripts]) } ) I think that the alpha argument is too one-off, i.e. dependent on how many levels in the boxplot. Peter Ehlers HTH, Dennis On Sat, Apr 9, 2011 at 4:56 AM, Jeff Stevensstev0...@googlemail.comwrote: Hi, Thanks for the work around, Dennis. My actual data set has 64 replicates for each factor level combination (rather than the 3 in the example), so the overplotting is quite messy. Any ideas on how to avoid the overplotting? Jeff On Fri, Apr 8, 2011 at 7:32 PM, Dennis Murphydjmu...@gmail.com wrote: Hi: After a number of false starts, I finally consulted Deepayan's book and the example on p. 73, suitably adapted, yielded a solution. Add a variable for the labels and then... df$lab- rep(1:6, each = 3) bwplot(dv ~ f1 | f2, data = df, ylim = c(0.5, 1), panel = function(x, y, ..., subscripts) { lab- df$lab[subscripts] panel.bwplot(x, y, ...) panel.text(x, 0.55, labels = lab) } ) If you look closely, you'll see that each label is overplotted three times. A similar plot in ggplot2 would be
[R] About Tinn-R
Hi everybody!! I don`t know if it is correct to make a question about R and Tinn-R in this mailing-list, but I need some help with a problem for which I don't find a solution anywhere. I have Tinn-R 2.3.5.2 in my notebook and I always used it with no problems, until a few days ago when this signs appears everytime I start the programme: Key Violation. C:/Documents and Settings/Marcos/Datos de programa/Tinn-R Serious problem reading ini files! Tinn-R can not be initiated. Please, try to rename (or remove) the folder above and restart the program! I don't know what that means, I don`t have such folder in my notebook, and I always used it normally and suddenly it doesn't work anymore. I unistalled it and installed again several times, and I tried with the newest version of R and TinnR too. I can`t find help in internet, and I also cleaned the registry of the computer. Thanks in advance!! Marcos from Argentina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about levels/as.numeric
On Sun, Apr 10, 2011 at 05:47:59PM +0200, Thibault Vatter wrote: Hi, I am still new to R and this is my first post on this mailing-list. I have two .csv (each one being a column of real numbers) coming from the same database (the first one is just longer than the second) and I read them in R the following way: returns - read.csv(test.csv, header = FALSE) returns2 - read.csv(test2.csv, header = FALSE) However, the two objects clearly don't seem to be equivalent: returns[2528:2537,1] [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 7470 Levels: -0.78 -0.85 -0.86 -0.0001 -0.000112 -0.000115 -0.000152 -0.000154 -0.000157 -0.00016 -0.000171 -0.000185 -0.000212 -0.000238 -0.000256 -0.000259 -0.000263 -0.000273 ... C Hi. It seems that the first file contains a non-numeric row. It may contain C, which is the last of the levels. In this case, the whole column is considered as a character vector and is converted to a factor. returns2[1:10,1] [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 as.numeric(returns[2528:2537,1]) [1] 341 7444 2244 5149 787 1717 5251 4122 3878 1811 These are indices to the levels of the factor. Petr Savicky. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] count number of TRUEs in each row
Hi all, I have a huge matrix of TRUE/FALSE table like following, and I want to count the number of TRUEs in each row. Instead of looping through each row and do length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. [,1] [,2][,3] [1,]TRUE FALSE FALSE [2,]FALSE TRUE TRUE Thank you in advance. Wendy -- View this message in context: http://r.789695.n4.nabble.com/count-number-of-TRUEs-in-each-row-tp3440486p3440486.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] count number of TRUEs in each row
On Sun, Apr 10, 2011 at 2:24 PM, Wendy wendy2.q...@gmail.com wrote: Hi all, I have a huge matrix of TRUE/FALSE table like following, and I want to count the number of TRUEs in each row. Instead of looping through each row and do length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. [,1] [,2] [,3] [1,]TRUE FALSE FALSE [2,]FALSE TRUE TRUE rowSums(Z) Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] count number of TRUEs in each row
Hi Wendy, try this: Z - matrix(runif(1000)0.5,10,100) rowSums(Z) HTH, Denes Hi all, I have a huge matrix of TRUE/FALSE table like following, and I want to count the number of TRUEs in each row. Instead of looping through each row and do length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. [,1] [,2][,3] [1,]TRUE FALSE FALSE [2,]FALSE TRUE TRUE Thank you in advance. Wendy -- View this message in context: http://r.789695.n4.nabble.com/count-number-of-TRUEs-in-each-row-tp3440486p3440486.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about levels/as.numeric
Thibault, Your questions indicate that you would benefit enormously from reading 'An Introduction to R'. A very useful function is str(). Understanding the concept of factors is crucial in R. Checking anything with Excel is never much use. Peter Ehlers On 2011-04-10 08:47, Thibault Vatter wrote: Hi, I am still new to R and this is my first post on this mailing-list. I have two .csv (each one being a column of real numbers) coming from the same database (the first one is just longer than the second) and I read them in R the following way: returns- read.csv(test.csv, header = FALSE) returns2- read.csv(test2.csv, header = FALSE) However, the two objects clearly don't seem to be equivalent: returns[2528:2537,1] [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 7470 Levels: -0.78 -0.85 -0.86 -0.0001 -0.000112 -0.000115 -0.000152 -0.000154 -0.000157 -0.00016 -0.000171 -0.000185 -0.000212 -0.000238 -0.000256 -0.000259 -0.000263 -0.000273 ... C returns2[1:10,1] [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 as.numeric(returns[2528:2537,1]) [1] 341 7444 2244 5149 787 1717 5251 4122 3878 1811 as.numeric(returns2[1:10,1]) [1] -0.002206 0.115696 -0.015192 0.008719 -0.004654 -0.010688 0.009453 0.002676 0.001334 -0.011326 I would like to understand what's happening and how to handle the longer one. This problem may seem stupid, but I've been trying to figure it out for a while and nothing seems to work. I checked in excel and both seems to be completely normal lists of real numbers). What am I missing here? What are those levels and why the as.numeric doesn't work the same with the longer one? My final goal is to extract small parts of those columns the following way: cbind(returns[which(names == id)[2528:2537],1]) [,1] [1,] 341 [2,] 7444 [3,] 2244 [4,] 5149 [5,] 787 [6,] 1717 [7,] 5251 [8,] 4122 [9,] 3878 [10,] 1811 Wich should be equivalent to: cbind(returns2[which(names == id)[1:10],1]) [,1] [1,] -0.002206 [2,] 0.115696 [3,] -0.015192 [4,] 0.008719 [5,] -0.004654 [6,] -0.010688 [7,] 0.009453 [8,] 0.002676 [9,] 0.001334 [10,] -0.011326 Thanks a lot, Thibault - *Thibault Vatter* EPFL- Master, 1ère année Laboratory of Statistical Biophysicshttp://lbs.epfl.ch/ Tel: +41 78 820 18 64 @: thibault.vat...@epfl.ch Web: http://personnes.epfl.ch/thibault.vatter *Please consider the environment before printing this email.* [[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] Adding margin text to lattice graphics
Yes, very sorry about this -- I had subconsciously ignored the hypothetical possibility that anyone wouldn't have ggplot2 loaded in their .Rprofile ;) Replacing mpg with beaver1 (datasets) should be more reproducible. That being said, I was told off-list that this is not answering at all the question, whatever it was. Best, baptiste On 11 April 2011 09:54, Mark Leeds marklee...@gmail.com wrote: hi baptiste: thanks for that but how do I get mpg ? I got an error that R couldn't find it. thanks again. On Sat, Apr 9, 2011 at 9:45 PM, baptiste auguie baptiste.aug...@googlemail.com wrote: Hi, You may want to read about ?viewport in the grid package. They allow you to position graphical elements wherever you want on a page, such as lattice plots and text (grid.text). For a high-level interface, you could try the following, library(gridExtra) library(lattice) p1 = xyplot(1~1) p2 = levelplot(volcano) p3 = tableGrob(head(mpg[, 1:3])) p4 = textGrob(some text) grid.arrange(p1, p2, p3, p4, main=global page title, sub=p4, left=page y-label) HTH, baptiste On 10 April 2011 13:33, Dennis Fisher fis...@plessthan.com wrote: Colleagues I am learning lattice graphics (R 2.12.2; OS X). Several days ago, I inquired about adding margin text to lattice graphics. Jim Price offered a useful reply, suggesting that I add: page = function(page) grid.text('words', x = 0.5, y = 0.01) to my call to the function. The entire function that he suggested was; xyplot(1 ~ 1, par.settings = list(layout.heights = list(bottom.padding = 10)), page = function(page) grid.text('words', x = 0.5, y = 0.01)) That worked initially and I also had success with panel.text. However, I am now working with more complicated objects in which more than one image is displayed on a page. In this instance, the text added by the command above appears with each image. I would like it to appear only once, scaled across the entire page, not relative to a single panel. Is there a different command that accomplishes my goal? Or a different implementation of this same command? Any help would be greatly appreciated. Also, because of my naivete with lattice graphics, I may be asking the question in entirely the wrong way -- please feel free to redirect me. Dennis Dennis Fisher MD P (The P Less Than Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 basic loop
The loop is correct, you just need to make sure that your result is computed and stored as the n-th element that is returned by the loop. Pick up any manual of R, and looping will be explained there. Also, I would recommend that you draw a random number for every iteration of the loop. Defining the random vectors outside the loop make sense to me only if they are the same length as n. prob-numeric(1000) for (n in 1:1000) { task1 - runif(1, min=0.8, max= 0.9) task2 - runif(1, min=0.75, max= 0.85) task3 - runif(1, min=0.81, max= 0.89) prob[n]-task1*task2*task3 } If you wanted to store the individual probabilities (task1..3), you would proceed accordingly by defining them outside the loop and storing the value in the loop as the n-th element of that vector just like for prob. HTH, Daniel -- View this message in context: http://r.789695.n4.nabble.com/Help-with-basic-loop-tp3440190p3440607.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] For-lapply-parallel apply
Hi, On Sat, Apr 9, 2011 at 5:03 AM, Alaios ala...@yahoo.com wrote: Dear all, I would like to ask your help understand the subsequent steps for making my program faster. The following code: Gauslist-array(data=NA,dim=c(dimx,dimy,dimz)) for (i in c(1:dimz)){ print(sprintf('Creating the %d map',i)); Gauslist[,,i]-f - GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } creates 100 GaussMaps (each map is of 256*256 dim) and stores them in a matrix called Gauslist. This process takes too long, so I was thinking if you can help me understand what should I do to make it run in parallel (in work there is a system with 16 cores). There is mclapply (parralel version of lapply) . If I make run my code run with lapply then I will be able to run it with mclapply also (they have same syntax). If I understand it correct the sequence for doing that is to understand the following: for..loop-lapply-mcapply Can you please help me understand if my for loop can be converted to lapply or not? Your loop can be converted quite easily. The lapply function simply takes an object to iterate over as its first argument (this can be a list of things, a vector of things, etc.) and a function to apply to each element in the iteration. `lapply` will build a list of results that your function returns for each element. A simple example is to iterate over the words in a character vector and return how many characters are in each word. R words - c('cat', 'dog's, 'people') R sizes - lapply(words, function(x) nchar(x)) R sizes [[1]] [1] 3 [[2]] [1] 4 [[3]] [1] 6 So in your example: for (i in c(1:dimz)){ print(sprintf('Creating the %d map',i)); Gauslist[,,i]-f - GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } Could be something like: gauslist - lapply(1:dimz, function(i) { GaussRF(x=x, y=y, model=model, ... WHATEVER ELSE) }) using mclapply would be exactly the same, except replace lapply with mclapply. Actually, is it correct that you aren't doing anything different in the iterations of the for loop -- I mean, nothing in your code really depends on your value for `i`, right? -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] About Tinn-R
Hi, On Sun, Apr 10, 2011 at 5:13 PM, Marcos Prunello marcos...@yahoo.com.ar wrote: Hi everybody!! I don`t know if it is correct to make a question about R and Tinn-R in this mailing-list, but I need some help with a problem for which I don't find a solution anywhere. If you go to Tinn-R's Support section at sourceforge: http://sourceforge.net/projects/tinn-r/support There is a sentence there that says: Tinn-R says the best way to get help with its software is by using its forum Open Discussion. And provides a link to: http://sourceforge.net/projects/tinn-r/forums/forum/481900 So I guess you'll have better luck with an answer if you post your question there. Also, rstudio is meant to be a nice IDE (in development) that you might want to try if Tinn-R keeps giving you problems: http://www.rstudio.org/ -steve I have Tinn-R 2.3.5.2 in my notebook and I always used it with no problems, until a few days ago when this signs appears everytime I start the programme: Key Violation. C:/Documents and Settings/Marcos/Datos de programa/Tinn-R Serious problem reading ini files! Tinn-R can not be initiated. Please, try to rename (or remove) the folder above and restart the program! I don't know what that means, I don`t have such folder in my notebook, and I always used it normally and suddenly it doesn't work anymore. I unistalled it and installed again several times, and I tried with the newest version of R and TinnR too. I can`t find help in internet, and I also cleaned the registry of the computer. Thanks in advance!! Marcos from Argentina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] About Tinn-R
Dear Marcos: Did you try this version (version 2.3.7.1)? http://sourceforge.net/projects/tinn-r/ Does is show the same messages? What R version are you using? It seems more a problem with the OS that with R or Tinn-R. When you uninstall Tinn-R, do you check any file left in the folder: C:/Documents and Settings/Marcos/Datos de programa/ If there are some, erase them manualy. If the problem persist, try to rename them with different extension like .XXX and reinstall the program. Maybe is a problem with a bad sector in the hard disk. Check the hard disk to see if it is the case. Hope this helps. Kenneth El dom, 10-04-2011 a las 14:13 -0700, Marcos Prunello escribió: Hi everybody!! I don`t know if it is correct to make a question about R and Tinn-R in this mailing-list, but I need some help with a problem for which I don't find a solution anywhere. I have Tinn-R 2.3.5.2 in my notebook and I always used it with no problems, until a few days ago when this signs appears everytime I start the programme: Key Violation. C:/Documents and Settings/Marcos/Datos de programa/Tinn-R Serious problem reading ini files! Tinn-R can not be initiated. Please, try to rename (or remove) the folder above and restart the program! I don't know what that means, I don`t have such folder in my notebook, and I always used it normally and suddenly it doesn't work anymore. I unistalled it and installed again several times, and I tried with the newest version of R and TinnR too. I can`t find help in internet, and I also cleaned the registry of the computer. Thanks in advance!! Marcos from Argentina __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] rtmvt
I have been using the rtmvt function in the {tmvtnorm} package i'm getting the warning: Acceptance rate is very low and rejection sampling becomes inefficient. Consider using Gibbs sampling. but i AM specifying the gibbs algorithm!!: rtmvt(M, mean=q[,,i,j], sigma=((u[i,j] + nu[i])/(p+nu[i]))*delta[,,i], df=ceiling(nu[i]+p), lower=c(0,0), algorithm=gibbs) Any ideas why I am getting this warning and how I can fix it? -- View this message in context: http://r.789695.n4.nabble.com/rtmvt-tp3440751p3440751.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] count number of TRUEs in each row
Ms Qiao, On 10 April 2011 14:24, Wendy wendy2.q...@gmail.com wrote: I have a huge matrix of TRUE/FALSE table like following, and I want to count the number of TRUEs in each row. Instead of looping through each row and do length(Z[Z==TRUE]), I am wondering if there is an easier way of doing this. [,1] [,2][,3] [1,]TRUE FALSE FALSE [2,]FALSE TRUE TRUE Does this help... Z[Z==T] ? -- Sent from my mobile device Envoyait de mon telephone mobil [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about levels/as.numeric
On 11/04/11 10:08, Peter Ehlers wrote: SNIP Checking anything with Excel is never much use. SNIP Fortune? cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Specifying the color of points and the plot symbol to be used on a graph
R 2.12.2 Windows 7 I would like to know how to specify the color used in plotting points on a scatter plot, generated using plot(x,y) and how I can specify the particular symbol used. I would like, for example, to plot some points as blue circles and other points a red squares. If someone will tell me how to specify the symbol and color used when plotting points, I can overlay graphs [par(new=TRUE] to get the two colors I desire. 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.
Re: [R] Specifying the color of points and the plot symbol to be used on a graph
Tena koe John If I understand you correctly I think it is easier than that: plot(x, y, col=yourColourVariate, pch=yourPchVariate) where yourColourVariate and yourPchVariate are numeric variates of the same lengths as x and y (recycling occurs). Actually the former can be a character variate of legal names. HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of John Sorkin Sent: Monday, 11 April 2011 2:29 p.m. To: r-help@r-project.org Subject: [R] Specifying the color of points and the plot symbol to be used on a graph R 2.12.2 Windows 7 I would like to know how to specify the color used in plotting points on a scatter plot, generated using plot(x,y) and how I can specify the particular symbol used. I would like, for example, to plot some points as blue circles and other points a red squares. If someone will tell me how to specify the symbol and color used when plotting points, I can overlay graphs [par(new=TRUE] to get the two colors I desire. 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. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] In svm(), how to connect quantitative prediction result to categorical result?
Hi Yunfei, On Fri, Apr 8, 2011 at 8:35 PM, Li, Yunfei yunfei...@wsu.edu wrote: Hi, I am studying using SVM functions of e1071 package to do prediction, and I found during the training data are factor type, then svm.predict() can predict data directly by categories; but if response variables are numerical, the predicted value from svm will be continuous quantitative numbers, then how can I connect these quantitative numbers to categories? (for example:in an example data set, the response variables are numerical and have two categories: 0 and 1, and the predicted value are continuous quantitative numbers from 0 to 1.3, how can I know which of them represent category 0 and which represent 1?) You have to figure out if you want the svm to do classification or regression. If I remember correctly, a vanilla call to SVM will try to pick one or the other in a smart way by looking at the types (and values) of your labels (y vector). You can be more explicit and tell the SVM what you want by specifying a value for the `type` argument in your original `svm` call. See ?svm for more info. I'm not sure if I'm answering your question or not(?). If I didn't understand what you wanted, perhaps you can rephrase your question, or maybe explain how my answer is not what you were after ... otherwise hopefully someone else can provide a better answer. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] predict ordered regresssion
Is there a way to get confidence intervals around an ordered regression like polr() in the MASS package? --- Joe King, M.A. Ph.D. Student University of Washington - Seattle 206-913-2912 mailto:j...@joepking.com j...@joepking.com --- Ad astra per aspera - Through hardships to the stars [[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] Specifying the color of points and the plot symbol to be used on a graph
Thank you! An elegant solution to my problem! 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) Peter Alspach peter.alsp...@plantandfood.co.nz 4/10/2011 10:59 PM Tena koe John If I understand you correctly I think it is easier than that: plot(x, y, col=yourColourVariate, pch=yourPchVariate) where yourColourVariate and yourPchVariate are numeric variates of the same lengths as x and y (recycling occurs). Actually the former can be a character variate of legal names. HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of John Sorkin Sent: Monday, 11 April 2011 2:29 p.m. To: r-help@r-project.org Subject: [R] Specifying the color of points and the plot symbol to be used on a graph R 2.12.2 Windows 7 I would like to know how to specify the color used in plotting points on a scatter plot, generated using plot(x,y) and how I can specify the particular symbol used. I would like, for example, to plot some points as blue circles and other points a red squares. If someone will tell me how to specify the symbol and color used when plotting points, I can overlay graphs [par(new=TRUE] to get the two colors I desire. 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\...{{dropped:31}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] predict ordered regresssion
On Sun, 10 Apr 2011, Joe P King wrote: Is there a way to get confidence intervals around an ordered regression like polr() in the MASS package? Please don't both ask the author directly *and* post to a forum. The answer is the same as the one I sent you directly. - For what do you want CIs, and why? The fits/predictions are probabilities, and CIs for probabilities are rarely useful. - You can do this by simulation, and simulate() has a polr method. --- Joe King, M.A. Ph.D. Student University of Washington - Seattle 206-913-2912 mailto:j...@joepking.com j...@joepking.com --- Ad astra per aspera - Through hardships to the stars [[alternative HTML version deleted]] Please don't send HTML when asked in the posting guide not to: that is why we get far too many blank lines in your message. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.