Re: [R] I am trying to use assign and paste to assign value to existing variable
On Dec 4, 2014, at 11:24 PM, Dirkse van Schalkwyk, Theuns the...@sun.ac.za wrote: In the code below, the last line of code does what I am trying to do; however, I do not know the name of the variable before the user creates it, by choosing values in Route1. So, how can I assign values to the variables individually, when I created them using the code in lines 9-12 and assigned values in lines 15 and 16? Lines 18 to 24 are various ways that I tried without success. Line 26 does what I want of course, but since I don't know the name of the variable beforehand I cannot use it. Maybe it will be easier to re-think the problem to use a dataframe; but I would still like to know how to do this as well. evaluate-function(..., envir=.GlobalEnv){ eval(parse(text=paste( ... ,sep=)), envir=envir) } #By Rufo in stackoverflow envir - environment() Route1- c(Ao1,B1,C1,D1,Ei1) Arrive- c(15,30,100,1000,5000,12000) # the time between events exponential parameter of the arrivals N - 9 # number of simulated arrivals Route1S- length(Route1)# determines the number of routes in Route1 for (i in 1:(Route1S)){ # create the route variables, maybe can be vectorised, but this works for now... assign(paste(Route1[i],TimeB,sep = ), rep(0, N)) assign(paste(Route1[i],TimeE,sep = ), rep(0, N)) assign(paste(Route1[i],ServiceT,sep = ), rep(0, N)) } assign(paste(Route1[1],TimeB,sep = ), round(cumsum(rpois(N,Arrive[1])),2)) #time the entity comes into Source1, N values assign(paste(Route1[1],ServiceT,sep = ), round(rpois(N,Arrive[2]),2)) #just service time assign(eval(paste(Route1[1],TimeB[,2,],sep = )), 3) x[1]-0 assign(paste(Route1[1],TimeB,eval([1]),sep = ), 0) sum(unlist(mget(paste(u,1:n,sep=),envir=as.environment(-1) The line above throws an error for too many closing parens, and when a paren is removed it then very reasonably complains about a missing value for n. After a value of 3 is substituted for `n` the error becomes: Error: value for ‘u1’ not found. ( It's not clear what value the line provides since it is not assigned to any name.) evaluate(paste(Route1[1],TimeB[1],sep = ), envir=envir) # will find the value in Ao1TimeB[1], but how to place a new value in Ao1TimeB[1]??? I get 17. assign(evaluate(paste(Route1[1],TimeB[1],sep = )), 0) # Creates Ao1Timeb[1] as 0 but does not change the vector Ao1TimeB... assign(eval(parse(text=paste(Route1[1],TimeB[1],sep = ))), 0) # does not work either and is frowned upon R-help list 106 This would be much less painful if you built one list with named descendants. You can give character values that need to be evaluated to either [[ or [ routlist - list( TimeB=numeric(), TimeE=numeric() ) routlist[['TimeB']] - lapply(paste0(Route1, TimeB), function(x) rep(0,N) ) routlist[['TimeE']] - lapply(paste0(Route1, TimeB), function(x) rep(0,N) ) # Let's say the user input is to be placed in the 3rd location in TimeB's first entry inp_a - timeB inc_b - 400 routlist[[inp_a]][[1]][3] - inp_b routlist $TimeB $TimeB[[1]] [1] 0 0 400 0 0 0 0 0 0 $TimeB[[2]] [1] 0 0 0 0 0 0 0 0 0 $TimeB[[3]] [1] 0 0 0 0 0 0 0 0 0 snipped remainder. -- David. Ao1TimeB[1]- 0 # this is what I am trying to do in the previous two lines # the reason I want to do it with the paste method is because there could be 100 values in Route1 # and expanding the method to include more such as Route2 with another 100 values etc. # I am trying to figure out how to address these values Ao1TimeB[1], Ao1TimeB[2] etc without typing the variable name Theuns The integrity and confidentiality of this email is governed by these terms / Hierdie terme bepaal die integriteit en vertroulikheid van hierdie epos. http://www.sun.ac.za/emaildisclaimer The integrity and confidentiality of this email is governed by these terms / Hierdie terme bepaal die integriteit en vertroulikheid van hierdie epos. http://www.sun.ac.za/emaildisclaimer [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Plot gamma distribution with relative frequency histogram
On Dec 4, 2014, at 6:55 PM, dila radi wrote: Dear R users, I am looking to fit a gamma curve onto a histogram of the data. Consider dt1 as my data: c(203.9, 91.5, 24.5, 34.5, 164, 144, 160.5, 195, 191.5, 189, 133, 110.5, 155, 80.5, 250.5, 116, 145, 118.5, 406, 183.5, 142.5, 197, 367, 134, 153.5) I am using this code in R x-dt1 h-hist(x,breaks=seq(0,500,25),col=rgb(0,0,1), plot=F) h$counts - h$counts / sum(h$counts) plot(h, freq=TRUE, ylab=Relative Frequency, xlab=Rainfall (mm), main = 'Histogram KBU-ML Gamma Disribution') est - fitdistr(dt1,gamma)$estimate curve(dgamma(x, rate=0.02220921, shape=3.63421746),from=0, to=500, main=Gamma distribution, add = T, col = red) but the gamma fit is not fitted onto histogram as much as it supposed to be. How should I overcome this? First read ?hist. Then set freq=FALSE. Then you will be comparing like to like. Otherwise you cna just hack it by multiplying the dgamma expression by 25. sum(h$counts) #before the standardization [1] 25 Thank you in advanced. Dila [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Put 2 ablines in an empty plot
Bonjour Hi everybody, Firs of all, sorry for my terrible English, I would like to know if it’s possible to create an “empty plot” in which i could add two ablines I created on two different plots earlyer in my script. As a result I would like to have a plot with only the two ablines (in the same plot) but without the graphs I used to create the ablines in the first place. I hope I explained my problem well enough. Thanks for helping me out, i hope someone has the answer. Adrien Bonvin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Using line (Tukey's robust line) on 3 observations?
Le 4 d�c. 2014 � 13:40, Tal Galili a �crit : By accident I came across the following example: x - 1:3 y - 1:3 line(x, y) # returns: Call: line(x, x) Coefficients: [1] -2 2 While when using 1:4, it will give the more reasonable 0,1 coefficients. I imagine this is in the way it calculate the quantiles (i.e.: a feature). Can someone help in explaining this? Thanks, Tal Strange, indeed. The problem arises also with other examples : line(1:8,1:8) Call: line(1:8, 1:8) Coefficients: [1] -1.125 1.250 line(1:9,1:9) Call: line(1:9, 1:9) Coefficients: [1] -1.0 1.2 _ St�phane Adamowicz Inra, centre de recherche Paca, unit� PSH 228, route de l'a�rodrome CS 40509 domaine St Paul, site Agroparc 84914 Avignon, cedex 9 France stephane.adamow...@avignon.inra.fr tel. +33 (0)4 32 72 24 35 fax. +33 (0)4 32 72 24 32 do not dial 0 when out of France web PSH : https://www6.paca.inra.fr/psh web Inra : http://www.inra.fr/ _ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Put 2 ablines in an empty plot
On Dec 5, 2014, at 12:30 AM, Adrien Bonvin wrote: Bonjour Hi everybody, Firs of all, sorry for my terrible English, I would like to know if it’s possible to create an “empty plot” in which i could add two ablines I created on two different plots earlyer in my script. Read there help page for ?plot.default. There is a type parameter that lets you do what you ask. There's also a worked example on ?plot.window As a result I would like to have a plot with only the two ablines (in the same plot) but without the graphs I used to create the ablines in the first place. I hope I explained my problem well enough. Thanks for helping me out, i hope someone has the answer. Adrien Bonvin [[alternative HTML version deleted]] Please read what the posting guide says about html posting. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 2 ablines dans 1 même plot vide
If I understand correctly plot(1:10, 1:10, type = n) should get you started. This is an Anglophone list by the way. On 04/12/2014 22:23, Adrien Bonvin wrote: Bonjour J’aimerais savoir comment créer un “plot vide”, dans lequel je pourrais ajouter deux valeurs d’abline, tracées à partir de deux nuages de points différents (que je souhaiterais ne pas voir dans mon graphique final). Comme résultat final je voudrais donc avoir un plot ne contenant que les deux droites d’abline sans les nuages de points qui vont avec. J’espère que mon problème est assez bien expliqué. Merci beaucoup pour votre attention, en espérant que vous avez la solution à mon problème. Cordialement Adrien Bonvin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - No virus found in this message. Checked by AVG - www.avg.com Version: 2015.0.5577 / Virus Database: 4235/8683 - Release Date: 12/05/14 -- Michael http://www.dewey.myzen.co.uk __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Put 2 ablines in an empty plot
The following example may give you an idea regarding your question. Please see what happens by typing the codes x - seq(from=-5, to=5, by=1) y1 - 0 + 0.5*x y2 - 0 - 0.5*x plot(x,y1, type=n) points(x,y1) points(x,y2) abline(a=0, b=0.5) abline(a=0, b=-0.5) Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/05/2014 02:30 AM, Adrien Bonvin wrote: Bonjour Hi everybody, Firs of all, sorry for my terrible English, I would like to know if it’s possible to create an “empty plot” in which i could add two ablines I created on two different plots earlyer in my script. As a result I would like to have a plot with only the two ablines (in the same plot) but without the graphs I used to create the ablines in the first place. I hope I explained my problem well enough. Thanks for helping me out, i hope someone has the answer. Adrien Bonvin [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Run script automatically on several input files in the directory and produce separate outputs?
Hi, I have written a script that currently reads in a .txt file where I specify the name e.g mydata-read.table(a_date.txt, header=TRUE) The script eventually produces a plot, e.g: pdf(file=myfilename.txt) plot(etc) dev.off What I want to do is run this script on several input files in my directory, without having to manually change the input file name each time, and produce the output plot pdf with the input file name as the output file name. It would also be handy if my plot title is also the input file name. I'm relatively new to R so i'm not sure how to approach this. I presume it's some sort of loop function, but i've never implemented one of these before - any advice would be greatly appreciated! Thanks in advance! Thomas -- Thomas Barningham Centre for Ocean and Atmospheric Sciences School of Environmental Sciences University of East Anglia Norwich Research Park Norwich NR4 7TJ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] using inspect with a TermDocumentMatrix to convert to a data frame
Great! Thank you! On Fri, Dec 5, 2014 at 12:48 AM, Wush Wu wush...@gmail.com wrote: Dear Erin, For the issue of printing big data.frame, you could define a customized `print.data.frame` in the user environment to prevent R prints all the data. For example: ```r print.data.frame - function(df) { base::print.data.frame(head(df)) cat(===\n) base::print.data.frame(tail(df)) } ``` Hope that helps. Regards, Wush 2014-12-05 11:53 GMT+08:00 Erin Hodgess erinm.hodg...@gmail.com: Hello! I am working through the Social Media Mining with R book and I have something that is a bit problematic. Here is the code: hash2_tdm - TermDocumentMatrix(hash2_corpus) print(hash2_tdm) print(findFreqTerms(hash2_tdm,lowfreq=10)) hash3_tdm - removeSparseTerms(hash2_tdm,0.92) hash3.df - as.data.frame(inspect(hash3_tdm)) Now when the hash3.df is created, the entire data frame is printed on the console. That's ok if the data frame is relatively small, but is not acceptable for a large data frame. Has anyone run into this before, please? I have tried all kinds of other options for converting to a data frame, but to no avail. This is on R-3.1.2, on Ubuntu 14.0.4 Thanks! Sincerely, Erin -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Mathematical and Statistics University of Houston - Downtown mailto: erinm.hodg...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Run script automatically on several input files in the directory and produce separate outputs?
Dear Thomas, list.files() will be your new best friend. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 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 [mailto:r-help-boun...@r-project.org] Namens Thomas Barningham Verzonden: vrijdag 5 december 2014 14:41 Aan: r-help@r-project.org Onderwerp: [R] Run script automatically on several input files in the directory and produce separate outputs? Hi, I have written a script that currently reads in a .txt file where I specify the name e.g mydata-read.table(a_date.txt, header=TRUE) The script eventually produces a plot, e.g: pdf(file=myfilename.txt) plot(etc) dev.off What I want to do is run this script on several input files in my directory, without having to manually change the input file name each time, and produce the output plot pdf with the input file name as the output file name. It would also be handy if my plot title is also the input file name. I'm relatively new to R so i'm not sure how to approach this. I presume it's some sort of loop function, but i've never implemented one of these before - any advice would be greatly appreciated! Thanks in advance! Thomas -- Thomas Barningham Centre for Ocean and Atmospheric Sciences School of Environmental Sciences University of East Anglia Norwich Research Park Norwich NR4 7TJ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. D I S C L A I M E R Bezoek onze website/Visit our websitehttps://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] function to avoid -
Hi, An other alternative using assign function func - function(){ X - 5 assign(X, X, envir = .GlobalEnv) } Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Tue, Dec 2, 2014 at 8:40 PM, Adams, Jean jvad...@usgs.gov wrote: Glad to see this query and the responses. You all just helped me to eliminate the use of global variables from my R package. I knew they were not recommended, but I didn't know how to get around using them. Thanks! Jean On Tue, Dec 2, 2014 at 10:59 AM, Karim Mezhoud kmezh...@gmail.com wrote: OK thanks as: myenv - new.env(parent = emptyenv()) fun - function(){ fun1 - function(){ myenv$X - 5 } } fun() ls(myenv) #X X #5 Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Tue, Dec 2, 2014 at 5:47 PM, Greg Snow 538...@gmail.com wrote: By At the top level Hadley meant to put that code outside of the function definition. In you source file that line should be very near the top, before any function definitions. Then myenv will not be temporary (well it will go away when you end the R session). Further, when this code is compiled into a package then myenv becomes package local, meaning that functions within the package can access it and the objects inside of it, but it will not interfere with any other packages or the global environment. On Tue, Dec 2, 2014 at 9:32 AM, Karim Mezhoud kmezh...@gmail.com wrote: Thanks Dr Hadley, but when I use a function the myenv remains temporary and I am to face the same problem. fun - function(){ myenv - new.env(parent = emptyenv()) fun1 - function(){ myenv$X - 5 } } ls(myEnv) #character(0) Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Tue, Dec 2, 2014 at 4:17 PM, Hadley Wickham h.wick...@gmail.com wrote: At the top level do: myenv - new.env(parent = emptyenv()) Then in your functions do myenv$x - 50 myenv$x etc You also should not be using data() in that way. Perhaps you want R/sysdata.rda. See http://r-pkgs.had.co.nz/data.html for more details. Hadley On Tue, Dec 2, 2014 at 2:28 AM, Karim Mezhoud kmezh...@gmail.com wrote: Dear All, I am writing a GUIpackage that needs global variables. I had many warning message when I checked the code as for example: geteSet: no visible binding for global variable ‘curselectCases’ I would like to write a function that creates a global place for Objects to be loaded as: Fun - function(){ Object - 5 Var2Global - function(Object){ .myDataEnv - new.env(parent=emptyenv()) # not exported isLoaded - function(Object) { exists(Object, .myDataEnv) } getData - function(Object) { if (!isLoaded(Object)) data(Object, envir=.myDataEnv) .myDataEnv[[Object]] } } } To avoid the use of: Object - 5 but it seems not working yet. Object == 5 is not a global variable after running Fun(). Any Idea? Thanks Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Run script automatically on several input files in the directory and produce separate outputs?
Dear Thierry, Thanks for your suggestion...but I don't how I would apply this for my situation, the R help isn't much help for me either. (Apologies - I am a rookie!) Do I still need a for loop? Many thanks Thomas On Fri, Dec 5, 2014 at 2:20 PM, ONKELINX, Thierry thierry.onkel...@inbo.be wrote: Dear Thomas, list.files() will be your new best friend. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 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 [mailto:r-help-boun...@r-project.org] Namens Thomas Barningham Verzonden: vrijdag 5 december 2014 14:41 Aan: r-help@r-project.org Onderwerp: [R] Run script automatically on several input files in the directory and produce separate outputs? Hi, I have written a script that currently reads in a .txt file where I specify the name e.g mydata-read.table(a_date.txt, header=TRUE) The script eventually produces a plot, e.g: pdf(file=myfilename.txt) plot(etc) dev.off What I want to do is run this script on several input files in my directory, without having to manually change the input file name each time, and produce the output plot pdf with the input file name as the output file name. It would also be handy if my plot title is also the input file name. I'm relatively new to R so i'm not sure how to approach this. I presume it's some sort of loop function, but i've never implemented one of these before - any advice would be greatly appreciated! Thanks in advance! Thomas -- Thomas Barningham Centre for Ocean and Atmospheric Sciences School of Environmental Sciences University of East Anglia Norwich Research Park Norwich NR4 7TJ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. D I S C L A I M E R Bezoek onze website/Visit our websitehttps://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo -- Thomas Barningham Centre for Ocean and Atmospheric Sciences School of Environmental Sciences University of East Anglia Norwich Research Park Norwich NR4 7TJ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Run script automatically on several input files in the directory and produce separate outputs?
Of course, you probably also need to wrap your code into a function first. R script files are not very good units of code to repeat multiple times. Once you have a function that you can give a data file name to and get a plot, then it is easy to use the lapply function to call that function once for each filename you get back from the list.files function. Reading other emails on this list can be helpful also. In the last day there was a discussion about how to rename files which could give you ideas how to automatically make new filenames to write your plot images into. See the archives mentioned in the link in the footer of this message. E.g. myplotfilecreator - function( fname ) { pngfname - paste0( fname, .png ) # code to create png file pngfname # return output file name when done } inputdir - data # where your input files are fnames - list.files( inputdir, full.names=TRUE ) lapply( fnames, myplotfilecreator ) --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On December 5, 2014 6:20:47 AM PST, ONKELINX, Thierry thierry.onkel...@inbo.be wrote: Dear Thomas, list.files() will be your new best friend. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie Kwaliteitszorg / team Biometrics Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 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 [mailto:r-help-boun...@r-project.org] Namens Thomas Barningham Verzonden: vrijdag 5 december 2014 14:41 Aan: r-help@r-project.org Onderwerp: [R] Run script automatically on several input files in the directory and produce separate outputs? Hi, I have written a script that currently reads in a .txt file where I specify the name e.g mydata-read.table(a_date.txt, header=TRUE) The script eventually produces a plot, e.g: pdf(file=myfilename.txt) plot(etc) dev.off What I want to do is run this script on several input files in my directory, without having to manually change the input file name each time, and produce the output plot pdf with the input file name as the output file name. It would also be handy if my plot title is also the input file name. I'm relatively new to R so i'm not sure how to approach this. I presume it's some sort of loop function, but i've never implemented one of these before - any advice would be greatly appreciated! Thanks in advance! Thomas -- Thomas Barningham Centre for Ocean and Atmospheric Sciences School of Environmental Sciences University of East Anglia Norwich Research Park Norwich NR4 7TJ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. D I S C L A I M E R Bezoek onze website/Visit our websitehttps://drupal.inbo.be/nl/disclaimer-mailberichten-van-het-inbo __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] function to avoid -
Don't have your package mess with (e.g. assign) to the global environment. Also, CRAN won't accept such packages. A good rule of thumb is that if you find yourself using assign(), get(), and -, or assigning explicitly to the global environment, it's a good indicator that you're hiking up the wrong path and that there's probably a better and more scenic route you should follow. ... Hadley's suggested a nice one. Henrik Hi, An other alternative using assign function func - function(){ X - 5 assign(X, X, envir = .GlobalEnv) } Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Tue, Dec 2, 2014 at 8:40 PM, Adams, Jean jvad...@usgs.gov wrote: Glad to see this query and the responses. You all just helped me to eliminate the use of global variables from my R package. I knew they were not recommended, but I didn't know how to get around using them. Thanks! Jean On Tue, Dec 2, 2014 at 10:59 AM, Karim Mezhoud kmezh...@gmail.com wrote: OK thanks as: myenv - new.env(parent = emptyenv()) fun - function(){ fun1 - function(){ myenv$X - 5 } } fun() ls(myenv) #X X #5 Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Tue, Dec 2, 2014 at 5:47 PM, Greg Snow 538...@gmail.com wrote: By At the top level Hadley meant to put that code outside of the function definition. In you source file that line should be very near the top, before any function definitions. Then myenv will not be temporary (well it will go away when you end the R session). Further, when this code is compiled into a package then myenv becomes package local, meaning that functions within the package can access it and the objects inside of it, but it will not interfere with any other packages or the global environment. On Tue, Dec 2, 2014 at 9:32 AM, Karim Mezhoud kmezh...@gmail.com wrote: Thanks Dr Hadley, but when I use a function the myenv remains temporary and I am to face the same problem. fun - function(){ myenv - new.env(parent = emptyenv()) fun1 - function(){ myenv$X - 5 } } ls(myEnv) #character(0) Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ On Tue, Dec 2, 2014 at 4:17 PM, Hadley Wickham h.wick...@gmail.com wrote: At the top level do: myenv - new.env(parent = emptyenv()) Then in your functions do myenv$x - 50 myenv$x etc You also should not be using data() in that way. Perhaps you want R/sysdata.rda. See http://r-pkgs.had.co.nz/data.html for more details. Hadley On Tue, Dec 2, 2014 at 2:28 AM, Karim Mezhoud kmezh...@gmail.com wrote: Dear All, I am writing a GUIpackage that needs global variables. I had many warning message when I checked the code as for example: geteSet: no visible binding for global variable ‘curselectCases’ I would like to write a function that creates a global place for Objects to be loaded as: Fun - function(){ Object - 5 Var2Global - function(Object){ .myDataEnv - new.env(parent=emptyenv()) # not exported isLoaded - function(Object) { exists(Object, .myDataEnv) } getData - function(Object) { if (!isLoaded(Object)) data(Object, envir=.myDataEnv) .myDataEnv[[Object]] } } } To avoid the use of: Object - 5 but it seems not working yet. Object == 5 is not a global variable after running Fun(). Any Idea? Thanks Ô__ c/ /'_;kmezhoud (*) \(*) ⴽⴰⵔⵉⵎ ⵎⴻⵣⵀⵓⴷ http://bioinformatics.tn/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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
Re: [R] Rename multiple files in a directory and write renamed files back to directory
Hi Chel, How can I modify the script such that the numbering starts from 200,... instead of 001? flag=0 does not accept anything other than 0. Thanks, Asong. On Thursday, December 4, 2014 11:17 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I see that a function 'format()' is used in your code. format(c(1,5,32,100), width=3, flag=0) [1] 1 5 32 100 formatC(c(1,5,32,100), width=3, flag=0) [1] 001 005 032 100 I hope this helps. Chel Hee Lee On 12/04/2014 10:54 PM, Zilefac Elvis wrote: Hi Chel, Thanks for the timely reply. It works but a minor problem remains. Here is the modified version of your code: file_names- list.files(pattern=Sim1971-2000_Daily_) new_names - paste(rcp45_Daily_Sim,format(seq(length(file_names)), width=3, flag=00), .dat, sep=) #files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files/contents file.rename(from=file_names, to=new_names) list.files(pattern=*.dat) I changed width =3 and flag=00 because my output has to be 001.dat...200.dat. However, this is what i got: list.files(pattern=*.dat) [1] rcp45_Daily_Sim 1.dat rcp45_Daily_Sim 2.dat rcp45_Daily_Sim 3.dat rcp45_Daily_Sim 4.dat [5] rcp45_Daily_Sim 5.dat rcp45_Daily_Sim 6.dat rcp45_Daily_Sim 7.dat rcp45_Daily_Sim 8.dat [9] rcp45_Daily_Sim 9.dat rcp45_Daily_Sim 10.dat The zeros disappear but I need them. Please help. Asong. On Thursday, December 4, 2014 10:16 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I put five data files (example1.dat, example2.dat, example3.dat, example4.dat, example5.dat, example6.dat) in my working directory. file_names - list.files(pattern=*.dat) file_names [1] example1.dat example2.dat example3.dat example4.dat example5.dat [6] example6.dat new_names - paste(new_example_, + formatC(seq(length(file_names)), width=2, flag=0), + .dat, sep=) new_names [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat file.rename(from=file_names, to=new_names) [1] TRUE TRUE TRUE TRUE TRUE TRUE list.files(pattern=*.dat) [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/04/2014 09:44 PM, Zilefac Elvis via R-help wrote: Hello, I would like to rename multiple files in a directory. Filenames are read using: lfile - list.files(pattern=rcp45_Daily_) files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files dput(lfile) c(rcp45_Daily_Sim001.dat, rcp45_Daily_Sim002.dat) - How can I rename these files (200 in number) using something like: file.rename(lfile, paste0(rcp45_Daily_Sim, 1:200))?The new filenames should be rcp45_Daily_Sim001, rcp45_Daily_Sim002, ..., rcp45_Daily_Sim200. - I would like to write the new file names to the directory. The data files contain huge amounts of data and should not be read into R. Only the file names should change. Many thanks for your helpful answers. Asong. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] RCurl much faster than base R
I'm trying to debug a curious network issue, I wonder if anyone can help me as I (and my local sysadmin) am stumped: This base R command takes ~1 minute to complete: readLines(url(http://bioconductor.org/biocLite.R;)) (biocLite.R is a couple of KB in size) Using RCurl (and so libcurl under the hood) is instantaneous (1s): library(RCurl) getURL(http://bioconductor.org/biocLite.R;) I've not set it to use any proxies (which was my first thought) unless libcurl autodetects them somehow... And the speed is similarly fast using wget or curl on the command line. It just seems to be the base R commands which are slow (including install.packages etc...). Does anyone have hints on how to debug this (if not an answer directly)? AlexG __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Rename multiple files in a directory and write renamed files back to directory
Hi Chel, I got it right. Many thanks. file.rename(file_names, to=paste0(rcp45_Daily_Sim, 200:210)) list.files(pattern=rcp45_Daily_Sim) [1] rcp45_Daily_Sim200 rcp45_Daily_Sim201 rcp45_Daily_Sim202 On Friday, December 5, 2014 9:35 AM, Zilefac Elvis zilefacel...@yahoo.com wrote: Hi Chel, How can I modify the script such that the numbering starts from 200,... instead of 001? flag=0 does not accept anything other than 0. Thanks, Asong. On Thursday, December 4, 2014 11:17 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I see that a function 'format()' is used in your code. format(c(1,5,32,100), width=3, flag=0) [1] 1 5 32 100 formatC(c(1,5,32,100), width=3, flag=0) [1] 001 005 032 100 I hope this helps. Chel Hee Lee On 12/04/2014 10:54 PM, Zilefac Elvis wrote: Hi Chel, Thanks for the timely reply. It works but a minor problem remains. Here is the modified version of your code: file_names- list.files(pattern=Sim1971-2000_Daily_) new_names - paste(rcp45_Daily_Sim,format(seq(length(file_names)), width=3, flag=00), .dat, sep=) #files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files/contents file.rename(from=file_names, to=new_names) list.files(pattern=*.dat) I changed width =3 and flag=00 because my output has to be 001.dat...200.dat. However, this is what i got: list.files(pattern=*.dat) [1] rcp45_Daily_Sim 1.dat rcp45_Daily_Sim 2.dat rcp45_Daily_Sim 3.dat rcp45_Daily_Sim 4.dat [5] rcp45_Daily_Sim 5.dat rcp45_Daily_Sim 6.dat rcp45_Daily_Sim 7.dat rcp45_Daily_Sim 8.dat [9] rcp45_Daily_Sim 9.dat rcp45_Daily_Sim 10.dat The zeros disappear but I need them. Please help. Asong. On Thursday, December 4, 2014 10:16 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I put five data files (example1.dat, example2.dat, example3.dat, example4.dat, example5.dat, example6.dat) in my working directory. file_names - list.files(pattern=*.dat) file_names [1] example1.dat example2.dat example3.dat example4.dat example5.dat [6] example6.dat new_names - paste(new_example_, + formatC(seq(length(file_names)), width=2, flag=0), + .dat, sep=) new_names [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat file.rename(from=file_names, to=new_names) [1] TRUE TRUE TRUE TRUE TRUE TRUE list.files(pattern=*.dat) [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/04/2014 09:44 PM, Zilefac Elvis via R-help wrote: Hello, I would like to rename multiple files in a directory. Filenames are read using: lfile - list.files(pattern=rcp45_Daily_) files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files dput(lfile) c(rcp45_Daily_Sim001.dat, rcp45_Daily_Sim002.dat) - How can I rename these files (200 in number) using something like: file.rename(lfile, paste0(rcp45_Daily_Sim, 1:200))?The new filenames should be rcp45_Daily_Sim001, rcp45_Daily_Sim002, ..., rcp45_Daily_Sim200. - I would like to write the new file names to the directory. The data files contain huge amounts of data and should not be read into R. Only the file names should change. Many thanks for your helpful answers. Asong. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Rename multiple files in a directory and write renamed files back to directory
You could read the help file: ?formatC which says that flag modifies how the numbers are formatted... it does not affect what numbers are used.. that is given by the x argument (typically the first item in the argument list to formatC). In your case I think that came from a call to the seq function, so perhaps you should read ?seq --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On December 5, 2014 7:35:59 AM PST, Zilefac Elvis via R-help r-help@r-project.org wrote: Hi Chel, How can I modify the script such that the numbering starts from 200,... instead of 001? flag=0 does not accept anything other than 0. Thanks, Asong. On Thursday, December 4, 2014 11:17 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I see that a function 'format()' is used in your code. format(c(1,5,32,100), width=3, flag=0) [1] 1 5 32 100 formatC(c(1,5,32,100), width=3, flag=0) [1] 001 005 032 100 I hope this helps. Chel Hee Lee On 12/04/2014 10:54 PM, Zilefac Elvis wrote: Hi Chel, Thanks for the timely reply. It works but a minor problem remains. Here is the modified version of your code: file_names- list.files(pattern=Sim1971-2000_Daily_) new_names - paste(rcp45_Daily_Sim,format(seq(length(file_names)), width=3, flag=00), .dat, sep=) #files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files/contents file.rename(from=file_names, to=new_names) list.files(pattern=*.dat) I changed width =3 and flag=00 because my output has to be 001.dat...200.dat. However, this is what i got: list.files(pattern=*.dat) [1] rcp45_Daily_Sim 1.dat rcp45_Daily_Sim 2.dat rcp45_Daily_Sim 3.dat rcp45_Daily_Sim 4.dat [5] rcp45_Daily_Sim 5.dat rcp45_Daily_Sim 6.dat rcp45_Daily_Sim 7.dat rcp45_Daily_Sim 8.dat [9] rcp45_Daily_Sim 9.dat rcp45_Daily_Sim 10.dat The zeros disappear but I need them. Please help. Asong. On Thursday, December 4, 2014 10:16 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I put five data files (example1.dat, example2.dat, example3.dat, example4.dat, example5.dat, example6.dat) in my working directory. file_names - list.files(pattern=*.dat) file_names [1] example1.dat example2.dat example3.dat example4.dat example5.dat [6] example6.dat new_names - paste(new_example_, + formatC(seq(length(file_names)), width=2, flag=0), + .dat, sep=) new_names [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat file.rename(from=file_names, to=new_names) [1] TRUE TRUE TRUE TRUE TRUE TRUE list.files(pattern=*.dat) [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/04/2014 09:44 PM, Zilefac Elvis via R-help wrote: Hello, I would like to rename multiple files in a directory. Filenames are read using: lfile - list.files(pattern=rcp45_Daily_) files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files dput(lfile) c(rcp45_Daily_Sim001.dat, rcp45_Daily_Sim002.dat) - How can I rename these files (200 in number) using something like: file.rename(lfile, paste0(rcp45_Daily_Sim, 1:200))?The new filenames should be rcp45_Daily_Sim001, rcp45_Daily_Sim002, ..., rcp45_Daily_Sim200. - I would like to write the new file names to the directory. The data files contain huge amounts of data and should not be read into R. Only the file names should change. Many thanks for your helpful answers. Asong. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible
Re: [R] Rename multiple files in a directory and write renamed files back to directory
Your question is not clear to me. Do you wish to start numbers from 200 using 'formatC()'? formatC(seq(from=200, to=1200, by=500), width=5, flag=0) [1] 00200 00700 01200 You can do the same job using function 'sprintf()' as shown in the below: sprintf(%05d, seq(from=200, to=1200, by=500)) [1] 00200 00700 01200 I like to read the documentation by typing help(formatC) help(sprintf) You may find answers what you wish to get. Documentation has been my best friend when using R. I hope this helps. Chel Hee Lee On 12/05/2014 09:35 AM, Zilefac Elvis wrote: Hi Chel, How can I modify the script such that the numbering starts from 200,... instead of 001? flag=0 does not accept anything other than 0. Thanks, Asong. On Thursday, December 4, 2014 11:17 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I see that a function 'format()' is used in your code. format(c(1,5,32,100), width=3, flag=0) [1] 1 5 32 100 formatC(c(1,5,32,100), width=3, flag=0) [1] 001 005 032 100 I hope this helps. Chel Hee Lee On 12/04/2014 10:54 PM, Zilefac Elvis wrote: Hi Chel, Thanks for the timely reply. It works but a minor problem remains. Here is the modified version of your code: file_names- list.files(pattern=Sim1971-2000_Daily_) new_names - paste(rcp45_Daily_Sim,format(seq(length(file_names)), width=3, flag=00), .dat, sep=) #files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files/contents file.rename(from=file_names, to=new_names) list.files(pattern=*.dat) I changed width =3 and flag=00 because my output has to be 001.dat...200.dat. However, this is what i got: list.files(pattern=*.dat) [1] rcp45_Daily_Sim 1.dat rcp45_Daily_Sim 2.dat rcp45_Daily_Sim 3.dat rcp45_Daily_Sim 4.dat [5] rcp45_Daily_Sim 5.dat rcp45_Daily_Sim 6.dat rcp45_Daily_Sim 7.dat rcp45_Daily_Sim 8.dat [9] rcp45_Daily_Sim 9.dat rcp45_Daily_Sim 10.dat The zeros disappear but I need them. Please help. Asong. On Thursday, December 4, 2014 10:16 PM, Chel Hee Lee chl...@mail.usask.ca wrote: I put five data files (example1.dat, example2.dat, example3.dat, example4.dat, example5.dat, example6.dat) in my working directory. file_names - list.files(pattern=*.dat) file_names [1] example1.dat example2.dat example3.dat example4.dat example5.dat [6] example6.dat new_names - paste(new_example_, + formatC(seq(length(file_names)), width=2, flag=0), + .dat, sep=) new_names [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat file.rename(from=file_names, to=new_names) [1] TRUE TRUE TRUE TRUE TRUE TRUE list.files(pattern=*.dat) [1] new_example_01.dat new_example_02.dat new_example_03.dat [4] new_example_04.dat new_example_05.dat new_example_06.dat Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/04/2014 09:44 PM, Zilefac Elvis via R-help wrote: Hello, I would like to rename multiple files in a directory. Filenames are read using: lfile - list.files(pattern=rcp45_Daily_) files - paste(paste(getwd(),lfile,sep=/), list.files(lfile),sep=/)# getwd of these files dput(lfile) c(rcp45_Daily_Sim001.dat, rcp45_Daily_Sim002.dat) - How can I rename these files (200 in number) using something like: file.rename(lfile, paste0(rcp45_Daily_Sim, 1:200))?The new filenames should be rcp45_Daily_Sim001, rcp45_Daily_Sim002, ..., rcp45_Daily_Sim200. - I would like to write the new file names to the directory. The data files contain huge amounts of data and should not be read into R. Only the file names should change. Many thanks for your helpful answers. Asong. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan -- Important Notice: This mailbox is ignored: e-mails are set to be deleted on receipt. Please respond to the mailing list if appropriate. For those needing to send personal or professional e-mail, please use appropriate addresses. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
On 05/12/2014 12:34 PM, Ranjan Maitra wrote: Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan A question like this could only be answered by the maintainer of the package. Have you tried writing there? (You might already know the answer if you've reported the issues to them.) Duncan Murdoch __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Factors and NaN
R-3.1.2 x - factor(c(yes, yes, no, NA, yes, no, NaN)) x [1] yes yes no NA yes no NaN Levels: NaN no yes is.nan(x) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE From the above snippet can you notice that the NaN value is not logically identified in a vector? Can anyone elaborate on this? Thank you for your effort! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Put 2 ablines in an empty plot
plot.new() abline(0,1) abline(1,1) # or as Michael suggest plot(1:10, 1:10, type = n) # then abline(0,1) abline(1,1) Best Matteo Murenu, Cagliari, IT -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: 05 December 2014 10:07 To: Adrien Bonvin Cc: r-help@r-project.org Subject: Re: [R] Put 2 ablines in an empty plot On Dec 5, 2014, at 12:30 AM, Adrien Bonvin wrote: Bonjour Hi everybody, Firs of all, sorry for my terrible English, I would like to know if it's possible to create an empty plot in which i could add two ablines I created on two different plots earlyer in my script. Read there help page for ?plot.default. There is a type parameter that lets you do what you ask. There's also a worked example on ?plot.window As a result I would like to have a plot with only the two ablines (in the same plot) but without the graphs I used to create the ablines in the first place. I hope I explained my problem well enough. Thanks for helping me out, i hope someone has the answer. Adrien Bonvin [[alternative HTML version deleted]] Please read what the posting guide says about html posting. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Subsetting R 3.1.2
x - list(seq = 3:7, alpha = c(a, b, c)) x$alpha [1] a b c x[alpha] $alpha [1] a b c x[c(1,2)] $seq [1] 3 4 5 6 7 $alpha [1] a b c * x[c(1, alpha[2])]* *$NA* *NULL* *$NA* *NULL* How to access a character subset withing a list? Thank you for your effort... [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Difference in cummulative variance depending on print command
Hello, I am trying a factor analysis via R. When running the pricipal axis analysis I do get different tables depending on the print command. This is my factor analysis: fa.pa_cor_3_2- fa(ItemsCor_4, nfactors=3, fm=pa,rotate=oblimin) To get the h2 I did the following print command: print (fa.pa_cor_3_2, digits=2, cut=.3, sort=T) To just get the loadings I did the following print command: print (fa.pa_cor_3_2$loadings, digits=2, cutoff=.3, sort=T) The result of the first print is the following Eigenvalue-cumulative variance table: PA1 PA2 PA3 SS loadings20.59 18.16 5.03 Proportion Var 0.28 0.25 0.07 Cumulative Var 0.28 0.52 0.59 With the second print command I get a different table: PA1 PA2 PA3 SS loadings17.63 15.12 3.14 Proportion Var 0.24 0.20 0.04 Cumulative Var 0.24 0.44 0.49 The loadings are the same for both commands. There is just this slight difference in the cumulative Var. Does anyone have an idea of a cause for the difference? What can I report? Did I post enough information to fully understand my problem? Thanks in Advance Rena __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Factors and NaN
On Dec 5, 2014, at 7:16 AM, Dinesh Chowdhary wrote: R-3.1.2 x - factor(c(yes, yes, no, NA, yes, no, NaN)) x [1] yes yes no NA yes no NaN Levels: NaN no yes is.nan(x) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE From the above snippet can you notice that the NaN value is not logically identified in a vector? Can anyone elaborate on this? It gets converted to a character value. (As always... Read the help page.) x - factor(c(yes, yes, no, NA, yes, no, NaN), exclude=c(NA,NaN) ) x [1] yes yes no NA yes no NA Levels: no yes Thank you for your effort! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Factors and NaN
'NaN' is a reserved keyword that implies 'Not a number'. I see that you use a character vector that includes 'NA' and 'NaN'. The former 'NA' is considered as a missing value; however, the latter 'NaN' is considered as a string 'NaN'. That's why three levels of 'NaN', 'no', 'yes' are shown. Function 'is.nan()' test if a numeric value is 'NaN'. Since you are using a character vector, the result of using 'is.nan()' should be all FALSE. If you wish to make R understand 'NaN' as missing value, it would be a good choice to use reserved keyword 'NA_character' as shown in the below: x - factor(c(yes, yes, no, NA, yes, no, NA_character_)) x [1] yes yes no NA yes no NA Levels: no yes is.na(x) [1] FALSE FALSE FALSE TRUE FALSE FALSE TRUE I hope this helps. Chel Hee Lee On 12/5/2014 9:16 AM, Dinesh Chowdhary wrote: R-3.1.2 x - factor(c(yes, yes, no, NA, yes, no, NaN)) x [1] yes yes no NA yes no NaN Levels: NaN no yes is.nan(x) [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE From the above snippet can you notice that the NaN value is not logically identified in a vector? Can anyone elaborate on this? Thank you for your effort! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Subsetting R 3.1.2
Your question is not clear to me. x$alpha[1:2] [1] a b x$alpha[2] [1] b Is this what you are looking for? I hope this helps. Chel Hee Lee On 12/5/2014 11:12 AM, Dinesh Chowdhary wrote: x - list(seq = 3:7, alpha = c(a, b, c)) x$alpha [1] a b c x[alpha] $alpha [1] a b c x[c(1,2)] $seq [1] 3 4 5 6 7 $alpha [1] a b c * x[c(1, alpha[2])]* *$NA* *NULL* *$NA* *NULL* How to access a character subset withing a list? Thank you for your effort... [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Run script automatically on several input files in the directory and produce separate outputs?
The simplest approach, and a good one for someone new to R, would be something like this: myfiles - c('fileA', 'fileB','fileC) for (nm in myfiles) { cat('now reading input file',nm,'\n') mydat - read.table( paste0(nm,'.txt'), header=TRUE) pdf( paste0(nm, '.pdf') ) plot(etc , main=nm) dev.off() } I stored the file names without the .txt, so that the base part of the name could more easily be used to construct the pdf file name. The paste0() command is used to construct the full input and pdf file names, i.e., with the .txt and .pdf suffices. Fancier tools include using functions like list.files() to, for example, find the names of all the .txt files in your current working directory, but until you understand what I've shown you, I wouldn't tackle those. -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 12/5/14, 5:40 AM, Thomas Barningham stbarning...@gmail.com wrote: Hi, I have written a script that currently reads in a .txt file where I specify the name e.g mydata-read.table(a_date.txt, header=TRUE) The script eventually produces a plot, e.g: pdf(file=myfilename.txt) plot(etc) dev.off What I want to do is run this script on several input files in my directory, without having to manually change the input file name each time, and produce the output plot pdf with the input file name as the output file name. It would also be handy if my plot title is also the input file name. I'm relatively new to R so i'm not sure how to approach this. I presume it's some sort of loop function, but i've never implemented one of these before - any advice would be greatly appreciated! Thanks in advance! Thomas -- Thomas Barningham Centre for Ocean and Atmospheric Sciences School of Environmental Sciences University of East Anglia Norwich Research Park Norwich NR4 7TJ __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] recoding genetic information using gsub
I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/. C/ C/. G/ G/. T/ T/. / ./. /A ./A /C ./C /G ./G /T ./T I've tried to use gsub with a command like the following: gsub(A/,[A/.], GT[,6]) but if genotypes arent like the above, the command will change it to look something like: A/.T T/.G C/.G Is there anyway to be more specific in gsub? Thanks! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] recoding genetic information using gsub
Hi, Briefly, you need to read about regular expressions. It's possible to be incredibly specific, and even to do what you want with a single line of code. It's hard to be certain of exactly what you need, though, without a reproducible example. See inline for one possibility. On Fri, Dec 5, 2014 at 2:24 PM, Kate Ignatius kate.ignat...@gmail.com wrote: I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/. C/ C/. G/ G/. T/ T/. / ./. /A ./A /C ./C /G ./G /T ./T I've tried to use gsub with a command like the following: gsub(A/,[A/.], GT[,6]) I don't understand why you put square brackets in, and you probably want the end marker to distinguish A/ from A/A gsub(A/$,A/., GT[,6]) but if genotypes arent like the above, the command will change it to look something like: A/.T T/.G C/.G Is there anyway to be more specific in gsub? Sarah -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] recoding genetic information using gsub
On 12/5/2014 11:24 AM, Kate Ignatius wrote: I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/. C/ C/. G/ G/. T/ T/. / ./. /A ./A /C ./C /G ./G /T ./T I've tried to use gsub with a command like the following: gsub(A/,[A/.], GT[,6]) Hi Kate -- a different approach is to create a 'map' (named character vector) describing what you want in terms of what you have; the number of possible genotypes is not large. http://stackoverflow.com/questions/15912210/replace-a-list-of-values-by-another-in-r/15912309#15912309 Martin but if genotypes arent like the above, the command will change it to look something like: A/.T T/.G C/.G Is there anyway to be more specific in gsub? Thanks! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. Martin Morgan, PhD Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] recoding genetic information using gsub
Does the following do what you want? raw - c(A/B, /B, A/, / ) tmp - sub(^ */, ./, raw) cleaned - sub(/ *$, /., tmp) cleaned [1] A/B ./B A/. ./. (The * is to allow optional spaces before or after the slash.) Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Dec 5, 2014 at 11:24 AM, Kate Ignatius kate.ignat...@gmail.com wrote: I have genetic information for several thousand individuals: A/T T/G C/G etc For some individuals there are some genotypes that are like this: A/, C/, T/, G/ or even just / which represents missing and I want to change these to the following: A/ A/. C/ C/. G/ G/. T/ T/. / ./. /A ./A /C ./C /G ./G /T ./T I've tried to use gsub with a command like the following: gsub(A/,[A/.], GT[,6]) but if genotypes arent like the above, the command will change it to look something like: A/.T T/.G C/.G Is there anyway to be more specific in gsub? Thanks! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
On Fri, 5 Dec 2014 12:54:17 -0500 Duncan Murdoch murdoch.dun...@gmail.com wrote: On 05/12/2014 12:34 PM, Ranjan Maitra wrote: Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan A question like this could only be answered by the maintainer of the package. Have you tried writing there? (You might already know the answer if you've reported the issues to them.) Thanks very much! I agree. However, I can not tell who the developer/maintainer is, from the www.deducer.org webpage. There are several questions, etc on the associated Google help group (on several topics) but no answers. So I have been fearing the worst, which is a pity: much as I detest this GUI stuff for everything for my personal use, this was a good (and better) option for these specific classes than JMP. Besides, at least 20% of the students would figure out from the GUI that it was far easier and more efficient to simply write out the commands than to submit using the GUI interface, and the GUI would inform them what they could write (and modify). I came to Deducer after looking at a lot of other related software. Well, I guess I was hoping that the developer was lurking here and he or somebody else who knew could answer. Thanks again for responding! Best wishes, Ranjan FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
To find the maintainer, see ?maintainer The maintainer is also listed on the CRAN page. http://cran.r-project.org/web/packages/Deducer/index.html Sarah On Fri, Dec 5, 2014 at 3:11 PM, Ranjan Maitra maitra.mbox.igno...@inbox.com wrote: On Fri, 5 Dec 2014 12:54:17 -0500 Duncan Murdoch murdoch.dun...@gmail.com wrote: On 05/12/2014 12:34 PM, Ranjan Maitra wrote: Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan A question like this could only be answered by the maintainer of the package. Have you tried writing there? (You might already know the answer if you've reported the issues to them.) Thanks very much! I agree. However, I can not tell who the developer/maintainer is, from the www.deducer.org webpage. There are several questions, etc on the associated Google help group (on several topics) but no answers. So I have been fearing the worst, which is a pity: much as I detest this GUI stuff for everything for my personal use, this was a good (and better) option for these specific classes than JMP. Besides, at least 20% of the students would figure out from the GUI that it was far easier and more efficient to simply write out the commands than to submit using the GUI interface, and the GUI would inform them what they could write (and modify). I came to Deducer after looking at a lot of other related software. Well, I guess I was hoping that the developer was lurking here and he or somebody else who knew could answer. Thanks again for responding! Best wishes, Ranjan -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
On 05/12/2014 3:11 PM, Ranjan Maitra wrote: On Fri, 5 Dec 2014 12:54:17 -0500 Duncan Murdoch murdoch.dun...@gmail.com wrote: On 05/12/2014 12:34 PM, Ranjan Maitra wrote: Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan A question like this could only be answered by the maintainer of the package. Have you tried writing there? (You might already know the answer if you've reported the issues to them.) Thanks very much! I agree. However, I can not tell who the developer/maintainer is, from the www.deducer.org webpage. There are several questions, etc on the associated Google help group (on several topics) but no answers. So I have been fearing the worst, which is a pity: much as I detest this GUI stuff for everything for my personal use, this was a good (and better) option for these specific classes than JMP. Besides, at least 20% of the students would figure out from the GUI that it was far easier and more efficient to simply write out the commands than to submit using the GUI interface, and the GUI would inform them what they could write (and modify). I came to Deducer after looking at a lot of other related software. Well, I guess I was hoping that the developer was lurking here and he or somebody else who knew could answer. Since there is an associated R package, you can find the maintainer's email using maintainer(Deducer) in R. That gives me Ian Fellows i...@fellstat.com Duncan Murdoch __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
On Fri, 5 Dec 2014 15:27:10 -0500 Duncan Murdoch murdoch.dun...@gmail.com wrote: On 05/12/2014 3:11 PM, Ranjan Maitra wrote: On Fri, 5 Dec 2014 12:54:17 -0500 Duncan Murdoch murdoch.dun...@gmail.com wrote: On 05/12/2014 12:34 PM, Ranjan Maitra wrote: Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan A question like this could only be answered by the maintainer of the package. Have you tried writing there? (You might already know the answer if you've reported the issues to them.) Thanks very much! I agree. However, I can not tell who the developer/maintainer is, from the www.deducer.org webpage. There are several questions, etc on the associated Google help group (on several topics) but no answers. So I have been fearing the worst, which is a pity: much as I detest this GUI stuff for everything for my personal use, this was a good (and better) option for these specific classes than JMP. Besides, at least 20% of the students would figure out from the GUI that it was far easier and more efficient to simply write out the commands than to submit using the GUI interface, and the GUI would inform them what they could write (and modify). I came to Deducer after looking at a lot of other related software. Well, I guess I was hoping that the developer was lurking here and he or somebody else who knew could answer. Since there is an associated R package, you can find the maintainer's email using maintainer(Deducer) in R. That gives me Ian Fellows i...@fellstat.com Thanks to both you and Sarah Goslee!! I completely forgot about this aspect of R packages. This was so dumb of me! I was looking all over the web trying to figure this out and forgot about the most basic feature. Thanks again! Best wishes, Ranjan Can't remember your password? Do you need a strong and secure password? Use Password manager! It stores your passwords protects your account. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
On Dec 5, 2014, at 12:11 PM, Ranjan Maitra wrote: On Fri, 5 Dec 2014 12:54:17 -0500 Duncan Murdoch murdoch.dun...@gmail.com wrote: On 05/12/2014 12:34 PM, Ranjan Maitra wrote: Hi, I have been using Deducer for the past year for my very basic 100-level introductory statistics classes for students from other disciplines. I really have liked using it for this specific purpose (takes me out of JMP!). However, over the past few months, issues have started cropping up with (some, not all) Windows 7 machines (which I am personally not very familiar with). Most of these problems are cleared when I manually and individually install all the required packages one by one. However, this is tedious to do for me, an instructor, for each and every student, and also means that the main appeal of Deducer: one-click install and GUI is lost. I have also noticed that Deducer's webpage mentions that it works on R 2.10.0 or greater. However, it is not clear if this project is maintained or not, so therefore, before I invest more time in using this for teaching, I was wondering if the software is being maintained and developed. I would like to say that Deducer works as advertised and no hiccups on Fedora 20 Linux for R 3.1.2. Many thanks and best wishes, Ranjan A question like this could only be answered by the maintainer of the package. Have you tried writing there? (You might already know the answer if you've reported the issues to them.) Thanks very much! I agree. However, I can not tell who the developer/maintainer is, from the www.deducer.org webpage. There are several questions, etc on the associated Google help group (on several topics) but no answers. So I have been fearing the worst, which is a pity: much as I detest this GUI stuff for everything for my personal use, this was a good (and better) option for these specific classes than JMP. Besides, at least 20% of the students would figure out from the GUI that it was far easier and more efficient to simply write out the commands than to submit using the GUI interface, and the GUI would inform them what they could write (and modify). I came to Deducer after looking at a lot of other related software. You appear unfamiliar with the maintainer function: maintainer(Deducer) [1] Ian Fellows i...@fellstat.com Well, I guess I was hoping that the developer was lurking here and he or somebody else who knew could answer. Thanks again for responding! Best wishes, Ranjan __ David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Profiling a C/C++ library from R
Thank you very much for the tips, Martin and Duncan! Rprof and operf are helping me a lot!! Also, I am now in R-dev maillist and I see there seems to be more appropriate to this kind of question. Best, Charles On Wed, Dec 3, 2014 at 12:03 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 02/12/2014, 4:43 PM, Charles Novaes de Santana wrote: Dear all, I am running a c++ library (a .so file) from a R code. I am using the function dyn.load(lib.so) to load the library. Do you know a way to profile my C library from R? Or should I compile my C library as an executable and profile it using the typical C-profilers? Thanks in advance for any help! If you want line-level profiling of your C++ code, you'll certainly need to use something that's not built in to R. You can probably do it without recompiling your C++ code, just by profiling the R process. But the details certainly depend on the profiler you choose to use. If you just want to know how much time is being spent in each C++ function called from R, Rprof() should be able to tell you. (It might give misleading information if your C++ code takes too long to execute, and some timer ticks get lost; I'm not sure if the underlying code takes account of that.) Duncan Murdoch -- Um axé! :) -- Charles Novaes de Santana, PhD http://www.imedea.uib-csic.es/~charles [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
Btw, I did hear back immediately from Ian Fellows and it is being maintained as his time permits, though he himself is not a windows user, and possibly therefore the issues. I thanked him for his e-mail and was relieved to note that this is not going away yet. Thanks again to Duncan, Sarah and now David for pointing me to the maintainer() function. Best wishes, Ranjan FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 build a vignette?
Dear expeRts, I know we can build a vignette from .Rmd file, but i find a lot of r packages have R topic documented words then followed an index, then functions'document which are already described in .RD files. I mean that , i don't want to write a vignette , but rather using function documents from .Rd files, how can i do? TKS. -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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] Deducer future?
On Dec 5, 2014, at 4:15 PM, Ranjan Maitra wrote: Btw, I did hear back immediately from Ian Fellows and it is being maintained as his time permits, though he himself is not a windows user, and possibly therefore the issues. I thanked him for his e-mail and was relieved to note that this is not going away yet. Thanks again to Duncan, Sarah and now David for pointing me to the maintainer() function. You might also try: help(package=Deducer) which brings up the help index page and always has a link near the top to the DESCRIPTION file. Best wishes, Ranjan FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 build a vignette?
You are not talking about a vignette. That is the pdf version of the help files, automatically generated from the same Rd files as the HTML versions. If you are not going to write the Rd file directly, you probably want roxygen. Markdown is weak on links and template structures, and Rd files use a lot of them. RStudio makes using roxygen to generate Rd files easy, though raw Rd files aren't that bad. Keep in mind that you will probably end up learning a bit of Rd syntax even if you preprocess with roxygen, so don't be shy about diving in to section 2 of the Writing R Extensions documentation. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On December 5, 2014 1:12:36 PM PST, PO SU rhelpmaill...@163.com wrote: Dear expeRts, I know we can build a vignette from .Rmd file, but i find a lot of r packages have R topic documented words then followed an index, then functions'document which are already described in .RD files. I mean that , i don't want to write a vignette , but rather using function documents from .Rd files, how can i do? TKS. -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 build a vignette?
If you run R CMD check on your package successfully, then that file will be generated as needed automatically. If you install your package for you're own use before sending it to CRAN then you can see the file by following the link on the help index html page for your package. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On December 5, 2014 9:47:36 PM PST, PO SU rhelpmaill...@163.com wrote: Yeah, i can write some roxygen2 which transformed to .RD files. The pdf of a package in the cran is not a vignette? That's to say some packages have not vignettes? And the pdf version is generated by me or cran ? If by me , how can i generate it from my .RD files. i am writing a package, source R codes are already written but i don't very clear about how to subbmmit to cran. -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU At 2014-12-06 11:12:32, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: You are not talking about a vignette. That is the pdf version of the help files, automatically generated from the same Rd files as the HTML versions. If you are not going to write the Rd file directly, you probably want roxygen. Markdown is weak on links and template structures, and Rd files use a lot of them. RStudio makes using roxygen to generate Rd files easy, though raw Rd files aren't that bad. Keep in mind that you will probably end up learning a bit of Rd syntax even if you preprocess with roxygen, so don't be shy about diving in to section 2 of the Writing R Extensions documentation. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On December 5, 2014 1:12:36 PM PST, PO SU rhelpmaill...@163.com wrote: Dear expeRts, I know we can build a vignette from .Rmd file, but i find a lot of r packages have R topic documented words then followed an index, then functions'document which are already described in .RD files. I mean that , i don't want to write a vignette , but rather using function documents from .Rd files, how can i do? TKS. -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/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 -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.