Re: [R] regular pentagon
Is this homework? We don't do homework here. -- Bert Oh, and my answer is yes I do. Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Fri, Mar 7, 2014 at 1:22 PM, Yuanzhi Li yuanzhi...@usherbrooke.ca wrote: Hello, everyone, Do you have any idea to get a set of random points within a regular pentagon? Thanks in advance! Yuanzhi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] fitting the lognormal and binomial into a gumbel copula
require(copula) # I specify the copula gmb-gumbelCopula(4,dim=2) # The bivariate CDF is generated myCDF-mvdc(gmb,margins=c(lnorm,nbinom),paramMargins=list(list(meanlog=11.69,sdlog=0.7781),list(mu=16,size=2.6))) # A random sample of the bivariate risk data is generated as a matrix. The univariate parameters had been fitted using fitdistrplus y-cbind(rlnorm(1000,11.69,0.7781),rnbinom(1000,mu=16,size=2.6)) # the model is fitted and runs Fitted-fitMvdc(x,myCDF,c(4,meanlog=12,sdlog=0.9,mu=16,size=3)) # but when i attempt to call the model i get the following error Fitted Error: object 'Fitted' not found Why does this happen and the model runs Charles. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] package opVar
Hello, I was attempting to install the package opVAr and got the following message Warning message: package 'opVar' is not available (for R version 3.0.2) Is this package available at all. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package opVar
Hello, There is no package opVar in the available CRAN packages list. Regards, Pascal On Sat, Mar 8, 2014 at 6:06 PM, Charles Thuo tcmui...@gmail.com wrote: Hello, I was attempting to install the package opVAr and got the following message Warning message: package 'opVar' is not available (for R version 3.0.2) Is this package available at all. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Calling a R function in RDOTNET inside C#.
Hi all , I had connected R and C# using RDoTNET, I want to call every packages of R in there and functions ,anybody have a code snippets to help me out , as the coding here is hard to understand. Thank You, PS ASHIS DEB [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data Frame to list?
Arun et al. Thanks, This is exactly what I need. All the best, KW -- On Mar 7, 2014, at 10:59 PM, arun smartpink...@yahoo.com wrote: Try: oof1 - list() oof1[foo$name] - foo$num A.K. On Friday, March 7, 2014 10:43 PM, Keith S Weintraub kw1...@gmail.com wrote: Folks, I have a data frame as follows: foo-structure(list(name = c(A, B, C), num = c(3L, 2L, 1L)), .Names = c(name, num), row.names = c(NA, -3L), class = data.frame) str(foo) 'data.frame': 3 obs. of 2 variables: $ name: chr A B C $ num : int 3 2 1 foo name num 1A 3 2B 2 3C 1 I want to convert this to a list like so: oof-list(A = 3, B = 2, C = 1) str(oof) List of 3 $ A: num 3 $ B: num 2 $ C: num 1 oof $A [1] 3 $B [1] 2 $C [1] 1 Any Suggestions? Thanks, KW -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] obtaining prediction intervals from lrm() in rms library
Depending on how you use the logistic regression this can be a silly question. Remember that the prediction interval is where you predict new observations to be. If you fit your logistic regression on data that is 0 or 1 (or FALSE/TRUE, etc.) then predictions for new data will be predictions of 0 or 1 (the confidence interval gives the interval for the probability or proportion, so it makes sense). Since new values can only be 0 or 1 the only possible prediction intervals are 0-0, 0-1, and 1-1, so they don't tend to be very interesting. One case where the question is not silly is if you are modeling a binomial with multiple possible events in a group, e.g. each subject took a 100 question quiz and you modeled the proportion correct, now you want to predict the number correct for a new subject on the 100 point quiz. Now a prediction interval makes sense because while the confidence interval is on the proportion correct, the prediction interval would be on how many questions most subjects would get correct taking into account all the uncertainty (both in the proportion and in the binomial around that proportion). However, this interval is not often called for and is more complex to calculate than the simple linear regression prediction interval, the combination of those 2 facts is probably why it is not implemented for lrm objects. The simplest way I know to create these prediction intervals is actually a Bayesian approach (or Bayes like) where you generate a probability from the posterior, then generate a random value from the binomial using that probability, repeat a bunch of times, then take the range of the middle 95% (or whatever percentage) as the prediction interval. On Fri, Mar 7, 2014 at 9:45 AM, David Paul david.alan.pa...@gmail.com wrote: Hi, Apologies if this is a silly question -- I am just now learning how to use some of the basic functions in the rms library. I have been using foo.dist - datadist(foo.frame) options(datadist='foo.dist') lrm.model - lrm(binary.outcome ~ rcs(contin.var,5)+categ.var, data = foo.frame, x=TRUE) lrm.predict - predict(lrm.model, type = fitted) to obtain the predicted probabilities from a logistic regression model, but now I need the associated 95% prediction intervals associated with these predicted probabilities. I've read the examples in the ?lrm help page, and from the information about predict from http://cran.r-project.org/web/packages/rms/rms.pdf I have tried predict(lrm.model, conf.int = 0.95, conf.type = c(individual)) but I get the error message Error in predictrms(object, ..., type = type, se.fit = se.fit) : conf.type=individual requires that fit be from ols From the same PDF, I have read the predict.lrm pages and was not able to figure out how to get prediction intervals. Many thanks in advance for some help, David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] posting for R-help on the predict function and categorical variables in R
How predict works depends on the method written for that type of object. The zeroinfl function is not in any of the standard packages, so it must be in another package, but you did not tell us which. Since it is from a package other than the main ones, it may work similarly to the regular predict functions, or it may work completely different. Have you tried reading the help pages for zeroinfl and the predict method for it? Have you worked through any vignettes for that package? On Fri, Mar 7, 2014 at 10:16 AM, Roman, Sally (MRC) sally.ro...@mrc.virginia.gov wrote: Hi - I would like to post to the R-help mailing list. Here is my post: -This is more of a general question about how the predict function treats categorical variables and how to interpret the output from predict. I have a zeroinfl model to predict the number of animals encountered: b9-zeroinfl(Count ~ as.factor (Area) + as.factor(Season)|1, dist=negbin,data = total) where Count is the number of animals and the explanatory variables are Area and Season, both are coded as factors in the model. Area has three levels and Season has 4 levels. Coding the two as factors allows for R to create dummy variables for each variable for use in the model. When I use the predict function to predict the number of animals for a larger data set, I want to make sure I'm understanding what is happening. My newdata for predict is: newdata- as.data.frame(Season, Area) Both variables are coded as factors and the dataframe is in a long format. There are records for each combination of Season and Area that correspond to trips taken over the course of 8 years. There are 113,804 rows of data in the newdata data,frame. str(newdata) 'data.frame': 113804 obs. of 2 variables: $ Season: Factor w/ 4 levels 1,2,3,4: 1 1 1 1 1 1 1 1 1 1 ... $ Area : Factor w/ 3 levels 625,631,Bay: 3 3 3 3 3 3 3 3 3 3 ... Example: Season Area 1 1 Bay 2 1 625 3 1 631 4 2 Bay 5 2 625 6 2 631 7 3 Bay 8 3 625 9 3 631 10 4 Bay 11 4 625 12 4 631 1. Do I need to create dummy variables for all levels for the two variables for input into predict, or does predict function act like zeroinfl where if the variables are coded as factors, this is done automatically by R. 2. Predict returns values of 0.0461 - 0.6015. If I am trying to predict the number of animals how do I interpret this? Since no predicted values are greater than 1 and I need whole numbers, I rounded the predicted data so that any value less than 0.5 was equal to 0 and any value greater than 0.5 was equal to 1. Does this seem correct? Thanks for any help. Sally Roman Fisheries Management Specialist Virginia Marine Resources Commission 2600 Washington Avenue, 3rd Floor Newport News, VA 23607 Phone: 757-247-2243 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gregory (Greg) L. Snow Ph.D. 538...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Selecting a maximum value in same ID
Lee wrote Hi, I am struggling with this issue and need some helps. The data set 'DF' includes persons' IDs and other variables A, B, and C. Each Person has multiple values in A, B, and C. What I am trying to do is 1) selecting a maximum value of B within same ID, and 2) making a new data set (DF.2) that select rows aligning with the maximum value of B. DF and DF.2 are below. I've used functions combining which.max, subset, and loop, but it did not work. If you have ideas, please help. DF IDABC 1 12 36 2 1 15 30 2 2 56 11 2 233 30 2 383 23 2 3587 2 4752 2 482 36 2 577 35 2 575 23 2 673 10 2 676 35 2 775 14 2 721 30 2 814 11 2 846 11 2 875 11 2 830 36 2 921 35 2 975 23 2 DF.2 IDABC 1 12 36 2 233 30 2 383 23 2 482 36 2 577 35 2 676 35 2 721 30 2 830 36 2 921 35 2 Thank you in advance, Lee How about using ddply? library(plyr) txt -ID A B C 1 12 36 2 1 15 30 2 2 56 11 2 2 33 30 2 3 83 23 2 3 58 7 2 4 75 2 2 4 82 36 2 5 77 35 2 5 75 23 2 6 73 10 2 6 76 35 2 7 75 14 2 7 21 30 2 8 14 11 2 8 46 11 2 8 75 11 2 8 30 36 2 9 21 35 2 9 75 23 2 d - read.table(textConnection(txt), header = TRUE) closeAllConnections() ddply(d,~ID,function(x){x[which.max(x$B),]}) # Returns ID A B C 1 1 12 36 2 2 2 33 30 2 3 3 83 23 2 4 4 82 36 2 5 5 77 35 2 6 6 76 35 2 7 7 21 30 2 8 8 30 36 2 9 9 21 35 2 HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/Selecting-a-maximum-value-in-same-ID-tp4686492p4686500.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] multiple plots
slavia wrote Hi, I have some values that I need to represente in the same plot. For exemple, if I have, c-c(200,205,210,215,220,225,230,235) a-c(0.032,0.44,0.86,0.65,0.53,0.213,0.46,0.231) b-c(0.325,0.657,0.784,0.236,0.798,0.287,0,748,0.785) d-c(0.786,0.217,0.538,0.513,0.870,0.326,0.647,0.217) c is a independente variable (represented in x axis) and a, b, d are diferente dependente varible (represented in a y axes). a, b and d should be diferent lines, How can I do that? Thank you Think there was a typo in the vector b where 0,748 should have been 0.748. To overlay lines on the same plot you could try the lines function. # Corrected Data c-c(200,205,210,215,220,225,230,235) a-c(0.032,0.44,0.86,0.65,0.53,0.213,0.46,0.231) b-c(0.325,0.657,0.784,0.236,0.798,0.287,0.748,0.785) d-c(0.786,0.217,0.538,0.513,0.870,0.326,0.647,0.217) # Plot plot(c,a, type=o, col=red, ylim=c(min(a,b,d),max(a,b,d))) lines(c,b, type=o,col=blue) lines(c,d, type=o,col=green) HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/multiple-plots-tp4686489p4686501.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] multiple plots
Hi, Check ?matplot() matplot(c,cbind(a,b,d),type=l,ylab=Dependent Var) #BTW, there is a typo in 'b'. (0,748). A.K. Hi, I have some values that I need to represente in the same plot. For exemple, if I have, c-c(200,205,210,215,220,225,230,235) a-c(0.032,0.44,0.86,0.65,0.53,0.213,0.46,0.231) b-c(0.325,0.657,0.784,0.236,0.798,0.287,0,748,0.785) d-c(0.786,0.217,0.538,0.513,0.870,0.326,0.647,0.217) c is a independente variable (represented in x axis) and a, b, d are diferente dependente varible (represented in a y axes). a, b and d should be diferent lines, How can I do that? Thank you __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Selecting a maximum value in same ID
Hi, You could do this either: DF[unlist(with(DF,tapply(B,list(ID),FUN=function(x) x %in% max(x,] #or DF[unlist(with(DF,by(B,ID,FUN=function(x) x%in% max(x,] #or library(plyr) DF[ddply(DF,.(ID),summarize,B %in% max(B))[,2],] A.K. Hi, I am struggling with this issue and need some helps. The data set 'DF' includes persons' IDs and other variables A, B, and C. Each Person has multiple values in A, B, and C. What I am trying to do is 1) selecting a maximum value of B within same ID, and 2) making a new data set (DF.2) that select rows aligning with the maximum value of B. DF and DF.2 are below. I've used functions combining which.max, subset, and loop, but it did not work. If you have ideas, please help. DF ID A B C 1 12 36 2 1 15 30 2 2 56 11 2 2 33 30 2 3 83 23 2 3 58 7 2 4 75 2 2 4 82 36 2 5 77 35 2 5 75 23 2 6 73 10 2 6 76 35 2 7 75 14 2 7 21 30 2 8 14 11 2 8 46 11 2 8 75 11 2 8 30 36 2 9 21 35 2 9 75 23 2 DF.2 ID A B C 1 12 36 2 2 33 30 2 3 83 23 2 4 82 36 2 5 77 35 2 6 76 35 2 7 21 30 2 8 30 36 2 9 21 35 2 Thank you in advance, Lee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] BoxPlot basic help
Hi, May be this helps: dat - read.table(text=Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43,sep=,header=TRUE,stringsAsFactors=FALSE) boxplot(Basic~Designation,data=dat,col=2:3) #or library(ggplot2) ggplot(dat,aes(x=Designation,y=Basic,fill=Designation))+geom_boxplot() A.K. Hello - I've been away from stat programming for a very long time and am just getting back into it. I'm not used to a non GUI interface which is where I'm running into problems with R. I have a data set that i'd like to use to create boxplots. the dataset sample looks as follows Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43 I have my grouping variable under 'designation' that i would like to use to create the boxplot. Could i request some help on the syntax to use after i have read this data file into a variable, say 'data' to group the information as per the grouping variable ? how do i define the grouping variable and use it in the boxplot command ? Any information would be greatly appreciated. in addition, if you could also point me to some basic training guides, that would be helpful as well. Thanks! Raol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] BoxPlot basic help
You asked for basic training guides... 1. An Introduction to R ships with R. Did you miss it? 2. Google is your friend. There are a ton on the web. Search! -- Bert Bert Gunter Genentech Nonclinical Biostatistics (650) 467-7374 Data is not information. Information is not knowledge. And knowledge is certainly not wisdom. H. Gilbert Welch On Sat, Mar 8, 2014 at 9:18 AM, arun smartpink...@yahoo.com wrote: Hi, May be this helps: dat - read.table(text=Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43,sep=,header=TRUE,stringsAsFactors=FALSE) boxplot(Basic~Designation,data=dat,col=2:3) #or library(ggplot2) ggplot(dat,aes(x=Designation,y=Basic,fill=Designation))+geom_boxplot() A.K. Hello - I've been away from stat programming for a very long time and am just getting back into it. I'm not used to a non GUI interface which is where I'm running into problems with R. I have a data set that i'd like to use to create boxplots. the dataset sample looks as follows Designation Basic ASA .25 ASA .28 ASA .32 TASA .45 TASA .33 TASA .43 I have my grouping variable under 'designation' that i would like to use to create the boxplot. Could i request some help on the syntax to use after i have read this data file into a variable, say 'data' to group the information as per the grouping variable ? how do i define the grouping variable and use it in the boxplot command ? Any information would be greatly appreciated. in addition, if you could also point me to some basic training guides, that would be helpful as well. Thanks! Raol __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package opVar
Pascal Oettli kridox at ymail.com writes: Hello, There is no package opVar in the available CRAN packages list. Regards, Pascal On Sat, Mar 8, 2014 at 6:06 PM, Charles Thuo tcmuigai at gmail.com wrote: [snip] Warning message: package 'opVar' is not available (for R version 3.0.2) You do have to be careful with capitalization (although I think CRAN will try to guess). However, googling R CRAN opvar package brings up this: http://www.milanor.net/blog/wp-content/uploads/2012/05/ ROperationalRisk.201205.FabioPiacenza.pdf (url broken) which refers to an opVar package but says explicitly that it is not available on CRAN. Maybe contact the author? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package environment versus namespace environment
Duncan, Thank you for the informative link. So, do the loaded namespaces have an ordering akin to the package search path that determines that functions in the base namespace can see objects in the utils namespace? (I noticed that loadedNamespaces() just comes back in alphabetical order.) Regards Ben On 03/07/2014 11:46 AM, Duncan Murdoch wrote: On 07/03/2014 10:16 AM, Benjamin Tyner wrote: Hello, I realize that a function in environment: base (for example, function head1 below) is unable to see (without resorting to ::, anyway) objects in utils (for example, head below), since package:base is after package:utils on the search path. However, I'm wondering what is the machinery that allows a function in environment: namespace:base (for example, function head2 below) to be able to see head just fine, without needing to resort to ::. See Luke Tierney's article in R News, Name space management for R. Luke Tierney, R News, 3(1):2-6, June 2003 [1]http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf There's a link to it from the R help system. Run help.start(), then look at Technical papers in the Miscellaneous Material section. I believe most of what it says is still current; the only thing I can see at a glance that is no longer correct is that in those days namespaces were optional in packages. Now all packages have namespaces. Duncan Murdoch I'm also wondering more generally, why there is a need (practically speaking) for a distinction between the environment associated with a package and the environment associated with the namespace. $ export R_PROFILE=/home/btyner/Rprofile.site $ cat /home/btyner/Rprofile.site sys.source(/home/btyner/head1.R, envir = baseenv()) sys.source(/home/btyner/head2.R, envir = .BaseNamespaceEnv) $ cat /home/btyner/head1.R head1 - function(x) head(x) $ cat /home/btyner/head2.R head2 - function(x) head(x) $ Rscript -e head1(letters) Error in head1(letters) : could not find function head Execution halted $ Rscript -e head2(letters) [1] a b c d e f $ Rscript -e sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets base Regards Ben __ [2]R-help@r-project.org mailing list [3]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [4]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- References 1. http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf 2. mailto:R-help@r-project.org 3. https://stat.ethz.ch/mailman/listinfo/r-help 4. http://www.R-project.org/posting-guide.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Saving R files
Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Saving R files
Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving R files
Hi David, Please keep the list copied, that will give someone else an opportunity to respond to you as well (I've cc'd the list here). On Sat, Mar 8, 2014 at 8:42 PM, IU parkh...@imap.iu.edu wrote: Thank you---but can't you tell from what I wrote that I DID read ?save, and didn't see the answer to my question there. To be honest, no. You say you guessed at the the syntax based on what you read in ?rm. Why you would do that instead of referring directly to ?save is made me suspect that you didn't actually read the documentation, especially since the relevant arguments are the same in both functions. At any rate, what is it you find unclear about the documentation for the save function? It all seems pretty clear to me, but then I've been reading R documentation for some time. Perhaps if you explain what you didn't understand someone can help you clarify. And thanks for the reminder about the FAQ. Sure, anytime. Best, Ista DFP (iPad) On Mar 8, 2014, at 8:31 PM, Ista Zahn istaz...@gmail.com wrote: Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package environment versus namespace environment
See Suraj Gupta's online article 'How R Searches and Finds Stuff' from March 29, 2012: http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/ It's a very useful write up on this topic. /Henrik On Sat, Mar 8, 2014 at 3:42 PM, Benjamin Tyner bty...@gmail.com wrote: Duncan, Thank you for the informative link. So, do the loaded namespaces have an ordering akin to the package search path that determines that functions in the base namespace can see objects in the utils namespace? (I noticed that loadedNamespaces() just comes back in alphabetical order.) Regards Ben On 03/07/2014 11:46 AM, Duncan Murdoch wrote: On 07/03/2014 10:16 AM, Benjamin Tyner wrote: Hello, I realize that a function in environment: base (for example, function head1 below) is unable to see (without resorting to ::, anyway) objects in utils (for example, head below), since package:base is after package:utils on the search path. However, I'm wondering what is the machinery that allows a function in environment: namespace:base (for example, function head2 below) to be able to see head just fine, without needing to resort to ::. See Luke Tierney's article in R News, Name space management for R. Luke Tierney, R News, 3(1):2-6, June 2003 [1]http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf There's a link to it from the R help system. Run help.start(), then look at Technical papers in the Miscellaneous Material section. I believe most of what it says is still current; the only thing I can see at a glance that is no longer correct is that in those days namespaces were optional in packages. Now all packages have namespaces. Duncan Murdoch I'm also wondering more generally, why there is a need (practically speaking) for a distinction between the environment associated with a package and the environment associated with the namespace. $ export R_PROFILE=/home/btyner/Rprofile.site $ cat /home/btyner/Rprofile.site sys.source(/home/btyner/head1.R, envir = baseenv()) sys.source(/home/btyner/head2.R, envir = .BaseNamespaceEnv) $ cat /home/btyner/head1.R head1 - function(x) head(x) $ cat /home/btyner/head2.R head2 - function(x) head(x) $ Rscript -e head1(letters) Error in head1(letters) : could not find function head Execution halted $ Rscript -e head2(letters) [1] a b c d e f $ Rscript -e sessionInfo() R version 3.0.1 (2013-05-16) Platform: x86_64-pc-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets base Regards Ben __ [2]R-help@r-project.org mailing list [3]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [4]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- References 1. http://cran.r-project.org/doc/Rnews/Rnews_2003-1.pdf 2. mailto:R-help@r-project.org 3. https://stat.ethz.ch/mailman/listinfo/r-help 4. http://www.R-project.org/posting-guide.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Saving R files
The penultimate line in ?rm is rm(list = ls()). I don't see anything that specific in ?save, and that's why I asked. Perhaps there's language in ?save that implies that to those more experienced in R than I am, but I'm not that experienced. David On 3/8/2014 10:07 PM, Ista Zahn wrote: Hi David, Please keep the list copied, that will give someone else an opportunity to respond to you as well (I've cc'd the list here). On Sat, Mar 8, 2014 at 8:42 PM, IU parkh...@imap.iu.edu wrote: Thank you---but can't you tell from what I wrote that I DID read ?save, and didn't see the answer to my question there. To be honest, no. You say you guessed at the the syntax based on what you read in ?rm. Why you would do that instead of referring directly to ?save is made me suspect that you didn't actually read the documentation, especially since the relevant arguments are the same in both functions. At any rate, what is it you find unclear about the documentation for the save function? It all seems pretty clear to me, but then I've been reading R documentation for some time. Perhaps if you explain what you didn't understand someone can help you clarify. And thanks for the reminder about the FAQ. Sure, anytime. Best, Ista DFP (iPad) On Mar 8, 2014, at 8:31 PM, Ista Zahn istaz...@gmail.com wrote: Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Saving R files
On Sat, Mar 8, 2014 at 11:14 PM, David Parkhurst parkh...@imap.iu.edu wrote: The penultimate line in ?rm is rm(list = ls()). I don't see anything that specific in ?save, and that's why I asked. Perhaps there's language in ?save that implies that to those more experienced in R than I am, but I'm not that experienced. Yes--see e.g., the second paragraph of the description in ?save: ‘save.image()’ is just a short-cut for ‘save my current workspace’, i.e., ‘save(list = ls(all = TRUE), file = .RData)’. It is also what happens with ‘q(yes)’. The documentation of the arguments list to save (especially the list argument) will also tell you that you can pass a character vector of object names to be saved. Such a vector can be returned from 'ls()'. Best, Ista David On 3/8/2014 10:07 PM, Ista Zahn wrote: Hi David, Please keep the list copied, that will give someone else an opportunity to respond to you as well (I've cc'd the list here). On Sat, Mar 8, 2014 at 8:42 PM, IU parkh...@imap.iu.edu wrote: Thank you---but can't you tell from what I wrote that I DID read ?save, and didn't see the answer to my question there. To be honest, no. You say you guessed at the the syntax based on what you read in ?rm. Why you would do that instead of referring directly to ?save is made me suspect that you didn't actually read the documentation, especially since the relevant arguments are the same in both functions. At any rate, what is it you find unclear about the documentation for the save function? It all seems pretty clear to me, but then I've been reading R documentation for some time. Perhaps if you explain what you didn't understand someone can help you clarify. And thanks for the reminder about the FAQ. Sure, anytime. Best, Ista DFP (iPad) On Mar 8, 2014, at 8:31 PM, Ista Zahn istaz...@gmail.com wrote: Hi David, Did you actually read the help file for 'save'? The answer to your fist question is there. The answer to your second question is in section 2.16 of the 'R for Windows FAQ'. Best, Ista On Sat, Mar 8, 2014 at 7:45 PM, David Parkhurst parkh...@imap.iu.edu wrote: Sometimes I don't understand the details of writeups I get, with ?save and the like. Anyway, that's my problem now. Can I do this (in Windows 7) to save everything that comes up with ls(), guessed at by what I find with ?rm: save(list=ls(),file=C:\am\myfiles\ProjectA.RData) Or would I need forward slashes, but this would otherwise work? If not, how could I accomplish this goal? David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] regular pentagon
On 08/03/14 10:22, Yuanzhi Li wrote: Hello, everyone, Do you have any idea to get a set of random points within a regular pentagon? Thanks in advance! You can easily do this using the spatstat package. cheers, Rolf Turner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.