Re: [R] File corruption?

2021-04-01 Thread Eric Berger
If your workflow involves debugging and rerunning the code, you may
experience differences between starting from a clean RStudio session and
simply restarting your application. This can be caused by your environment
having variables, shared objects etc defined. It is generally quite quick
to close and open a new RStudio session, so ... when in doubt it's probably
best to do that.

You should be able to organize your workflow so that stopping and starting
RStudio does not require you to rewrite any scripts. (e.g. save your
scripts as you go along)

HTH,
Eric


On Thu, Apr 1, 2021 at 9:45 PM  wrote:

> Hello,
>
> I would like to know if anyone has encounter this problem before and what
> they have done to solve the problem.  I am not sure if the problem has to
> do
> with R itself or with RStudio.  The problem is the following: sometimes
> when
> I am developing code in R, using R studio -script inside a Shiny
> application- at one point my code does not work in the application.  I
> works
> outside the application as a separate script, but it stops working inside
> the application with the rest of the functions. So far, what I have done is
> to start an entire new script and rewrite the entire code and this will
> solve the problem, the code will work fine again.  I wonder if files/script
> get corrupted sometimes and need to be refreshed.
>
>
>
> Thank you
>
>
> [[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.


[R] File corruption?

2021-04-01 Thread giuseppacefalu
Hello,

I would like to know if anyone has encounter this problem before and what
they have done to solve the problem.  I am not sure if the problem has to do
with R itself or with RStudio.  The problem is the following: sometimes when
I am developing code in R, using R studio -script inside a Shiny
application- at one point my code does not work in the application.  I works
outside the application as a separate script, but it stops working inside
the application with the rest of the functions. So far, what I have done is
to start an entire new script and rewrite the entire code and this will
solve the problem, the code will work fine again.  I wonder if files/script
get corrupted sometimes and need to be refreshed.  

 

Thank you


[[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] cox.zph

2021-04-01 Thread Kevin Thorpe
While the statements below about cox.zph are true, plotting the cox.zph result 
does tell you what the HR is doing. I never use one without the other.

-- 
Kevin E. Thorpe
Head of Biostatistics,  Applied Health Research Centre (AHRC)
Li Ka Shing Knowledge Institute of St. Michael's
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016

> On Apr 1, 2021, at 9:00 AM, Bendix Carstensen  
> wrote:
> 
> EXTERNAL EMAIL:
> 
> Further to John Sorkin's post on the cox.zph:
> You get test(s) of whether there is an interaction between a variable, say, 
> sex, and time.
> 
> Suppose it is significant. You will have no clue whether the M/W hazard ratio 
> is increasing or decreasing by time.
> 
> Suppose it is not significant. You will have no clue whether the 
> (non-significant) M/W hazrad ratio exhibits a pattern that is worth looking 
> further into or not.
> 
> In this sense the cox.zph is a perfect tool to allow you to write 'we checked 
> for non proportionality' instead of 'we have no clue of how the M/W ratio 
> varies by time'.
> 
> If you label it what it is, namely a test of interaction, you might realize 
> that you should ESTIMATE the shape and size of the interaction before 
> deriving a test, either ad-hoc by the Shoenfeld residuals or by proper 
> modeling.
> 
> See for example pp 202 ff. in 'Epidemiology with R' by (surprise, surprise) 
> me, published by OUP a few months ago.
> 
> b.r.
> Bendix Carstensen
> Senior Statistician
> Steno Diabetes Center Copenhagen
> Clinical Epidemiology
> Niels Steensens Vej 2-4
> DK-2820 Gentofte
> Denmark
> tel: +45 30 91 29 61
> b...@bxc.dk
> bendix.carsten...@regionh.dk
> http://BendixCarstensen.com
> 
> 
> 
> 
> 
> Region Hovedstaden anvender de personoplysninger, du giver os i forbindelse 
> med din henvendelse. Du kan læse mere om formålet med anvendelsen samt dine 
> rettigheder på vores hjemmeside: www.regionh.dk/persondatapolitik
> 
> __
> 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] Violin plot with mean_sdl

2021-04-01 Thread Bill Dunlap
help(stat_summary) suggests you use the fun.args=list(...) argument to
pass arguments to the fun.* functions.   Try replacing mult=1 by
fun.args=list(mult=1).

It is possible that ggplot2::stat_summary changed its behavior since
that web page was written or that the web page was always wrong.

-Bill

On Wed, Mar 31, 2021 at 11:03 PM Mahmood Naderan-Tahan
 wrote:
>
> Hi,
>
> I followed the example described at [1] but I don't know why I get the 
> following warning
>
>
> > library(ggplot2)
> > library(Hmisc)
> > mydata <- read.csv('test.csv', header=T,row.names=1)
> > mydata
>  V1  V2   V3 V4
> P1 73.6 0.7 74.6  R
> P2 75.2 0.7 75.8  R
> P3  6.5 0.0  7.3  R
> P4 41.4 0.3 39.2  C
> P5  5.4 0.1 18.2  C
> P6 18.8 0.3 30.3  C
> > p <- ggplot(mydata, aes(x=V4, y=V1)) + geom_violin(trim=FALSE)
> > p + stat_summary(fun.data="mean_sdl", mult=1,
> +  geom="crossbar", width=0.2 )
> Warning message:
> Ignoring unknown parameters: mult
>
>
> How can I fix that?
>
>
>
> [1] 
> http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization
>
>
> Regards,
> Mahmood
>
> [[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] [EXT] Calculating the total change in shareprice over a time periond

2021-04-01 Thread e-mail ma015k3113 via R-help
Dear David, thanks so much for your time and suggestion. It has worked now.

Kind regards

Ahson
> On 31 March 2021 at 19:17 David K Stevens  wrote:
> 
> 
> Mr. Blueyonder,
> 
> There are a number of problems with this.
> 
> 1) is the data below really in a data frame? I coerced your table into a 
> data frame, guessing at the structure and when I print out the 1st three 
> rows I get an alignment into proper columns
> 
> COMPANY_NUMBER COMPANY_NAME    CITY YEAR_END_DATE 
> CLOSE_SHARE_PRICE
> 1   22705  CARDIFF PROPERTY PUBLIC LIMITED COMPANY  
> (THE)Egham    30/09/2005    NA
> 2   22705  CARDIFF PROPERTY PUBLIC LIMITED COMPANY  
> (THE)Egham    30/09/2006    NA
> 3   22705  CARDIFF PROPERTY PUBLIC LIMITED COMPANY  
> (THE)Egham    30/09/2007  9.65
> 
> I'd guess that your PLC is actually a 1 column data frame based on how 
> you present it. Because what you gave is so small, I just added commas 
> where they seemed suitable and used
> 
> PLC <- read.csv(file='clipboard',header=T,stringsAsFactors = T)
> 
> to create the data frame above. It's likely that your actual problem is 
> much larger so I'd export the data as a CSV file, and read it into R in 
> a similar way using
> 
> PLC <- read.csv(file='myfile.csv',header=T,stringsAsFactors = T)
> 
> 2) Your code is incorrect as is for two reasons. a) for your approach to 
> work, you'll need to create an empty column CH_SH_PRICE before running 
> the loop, because your loop is trying to place data into a non-existent 
> column b) the code PLC$CH_SH_PRICE(i+1) has to use square brackets, 
> otherwise R thinks PCL$CH_SH_PRICE is a function rather than a reference 
> to column element i+1 as in PLC$CH_SH_PRICE[i+1]
> 
> Also, the functionisTRUE is actually the following
> 
> function (x)
> is.logical(x) && length(x) == 1L && !is.na(x) && x
> 
> Is this really what you want to do, rather than just checking the 
> company number, as inPLC[i,1] == PLC[i+1,1]?
> 
> Assuming (tentatively) I guessed right, here's what I got
> 
> COMPANY_NUMBER    COMPANY_NAME CITY 
> YEAR_END_DATE CLOSE_SHARE_PRICE CH_SH_PRICE
> 1  22705 CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham    
> 30/09/2005    NA  NA
> 2  22705 CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham    
> 30/09/2006    NA  NA
> 3  22705 CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham    
> 30/09/2007  9.65  NA
> 4  22705 CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham    
> 30/09/2008  6.55   -3.10
> 
> Good luck.
> 
> David Stevens
> 
> On 3/31/2021 11:04 AM, e-mail ma015k3113 via R-help wrote:
> > Dear All, I have a data frame which is structured as follows:
> >
> >
> > COMPANY_NUMBER  COMPANY_NAMECITYYEAR_END_DATE   CLOSE_SHARE_PRICE
> > 22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham  
> > 30/09/2005  NA
> > 22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham  
> > 30/09/2006  NA
> > 22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham  
> > 30/09/2007  9.65
> > 22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham  
> > 30/09/2008  6.55
> > 22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham  
> > 30/09/2009  6.55
> > 22705   CARDIFF PROPERTY PUBLIC LIMITED COMPANY (THE)Egham  
> > 30/09/2010  7.5
> > 10395804TOC PROPERTY BACKED LENDING TRUST PLC   Newcastle Upon Tyne 
> > 30/11/2016  NA
> > 10395804TOC PROPERTY BACKED LENDING TRUST PLC   Newcastle Upon Tyne 
> > 30/11/2017  1.04
> > 10395804TOC PROPERTY BACKED LENDING TRUST PLC   Newcastle Upon Tyne 
> > 30/11/2018  1.04
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2000  NA
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2001  NA
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2003  NA
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2004  NA
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2005  NA
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2006  1.09
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2007  1.17
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2008  1.24
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2009  0.9
> > SC192761MARTIN CURRIE GLOBAL PORTFOLIO TRUST PLCEdinburgh   
> > 31/01/2010  1.14
> >
> >
> >
> > I am trying to calculate the 

Re: [R] FD package_dbFD error

2021-04-01 Thread Vesna Gulin

Hi Sara,

Thank you for your advice and apologies for spamming.

I will try to reorganise the arguments and if it doesn't work, will try 
r-sig-ecology.


Kind regards,
Vesna

On 2021-04-01 0:58, Sarah Goslee wrote:

Hi,

While Bert is right that this would be a good question for
r-sig-ecology, I think you might have made a very simple-to-fix
mistake:

According to
https://www.rdocumentation.org/packages/FD/versions/1.0-12/topics/dbFD
if you don't name the arguments, traits should come BEFORE sites.

If that doesn't help, take a look at the site and trait data frames
used in the examples and see if you can figure out where you went
wrong. If you can't, then try r-sig-ecology.

Sarah

On Wed, Mar 31, 2021 at 6:33 PM Vesna Gulin  
wrote:


Hi everyone,

I am trying to conduct dbFD from the FD package, but it keeps giving 
me

the same error:

ex1 <- dbFD(sites, traits)
Error in dbFD(sites, traits) :
   Different number of species in 'x' and 'a'.

Ab, bb, Ci are species names.
I have tried rewriting the species names so many times and ways, but
nothing seems to work. I also checked for blank space but can't seem 
to

find one. Does anyone have and idea what am I doing wrong?

My data consists of two data frames:
sites

   X Ab Bb Ci Cb Cbm Cdo Cm Cdi Dv Edi Ee Ede Es Eb Gc La Mm Op Oc Oh 
Or

Pgr Ps Pgi Pf Pgri Po Pp Rr Ss Sl Ts Tv Tr
1 A  0  0  0  0   0   0  1   0  0   0  0   0  1  0  0  0  1  0  0  0  
0

  0  0   0  00  0  0  0  0  0  0  0  0
2 B  0  0  0  0   0   0  0   0  0   0  0   0  1  0  0  0  0  2  0  0  
0

  0  0   0  00  0  0  0  0  0  0  0  0
3 C  0  0  0  0   0   0  0   0  0   0  0   0  0  0  0  0  0  0  0  0  
0

  0  0   0  00  1  0  0  0  0  0  0  0
4 D  0  0  0  0   0   0  0   0  0   0  0   0  0  0  0  0  0  0  0  0  
0

  0  0   0  00  0  0  0  0  0  0  0  0
5 E  0  0  0  0   0   0  0   3  2   3  0   0  0  0  0  0  0  0  0  4  
0

  0  0   0  00  0  0  0  0  0  0  0  0
6 F  0  0  0  0   0   0  0   0  3   0  1   0  0  4  1  8  0  1  3  2  
0

  0  0   0  00  0  0  0  0  0  0  0  2
7 G  0  0  0  0   0   0  1   1  1   2  0   0  0  0  0  0  0  0  1  4  
0

  0  0   0  00  0  0  0  0  0  0  0  0

traits

  X bodyration  flight feeding   lifestyle 
moisture
1Ab 29.5 0.6203390none herbivorous geo-chortobiont  
xerophilous
2Bb 16.0 1.0625000 reduced  omnivorous chortobiont  
mesophilous
3Ci 23.5 0.5829787full  omnivorous geo-chortobiont  
xerophilous
4Cb 18.0 0.600full herbivorous chortobiont  
mesophilous
5   Cbm 18.0 0.600full herbivorous chortobiont  
mesophilous
6   Cdo 17.5 0.6342857 reduced herbivorous chortobiont  
mesophilous
7Cm 17.5 0.5914286full herbivorous chortobiont  
mesophilous
8   Cdi 21.5 0.5883721 reduced herbivorous chortobiont 
hygrophilous
9Dv 34.0 0.9044118 reduced carnivorous geo-chortobiont  
mesophilous
10  Edi 27.0 0.722none  omnivorous thamnobiont  
xerophilous
11   Ee 25.0 0.640none  omnivorous thamnobiont  
mesophilous
12  Ede 20.5 0.5902439none herbivorous chortobiont  
xerophilous
13   Es 25.5 0.9803922none  omnivorous thamnobiont  
mesophilous
14   Eb 18.0 0.6416667 reduced herbivorous chortobiont  
mesophilous
15   Gc 22.5 0.456none  omnivorousgeobiont  
mesophilous
16   La 13.0 0.9807692none herbivorous chortobiont  
mesophilous
17   Mm 18.0 1.097none  omnivorous geo-chortobiont  
xerophilous
18   Op 12.0 0.667full  omnivorous thamnobiont  
xerophilous
19   Oc 21.0 0.5690476full herbivorousgeobiont  
xerophilous
20   Oh 15.5 0.5967742 reduced herbivorous chortobiont  
mesophilous
21   Or 15.5 0.7193548 reduced herbivorous chortobiont  
mesophilous
22  Pgr 17.0 1.0588235none  omnivorous thamnobiont  
mesophilous
23   Ps 21.5 1.0465116none  omnivorous thamnobiont  
mesophilous
24  Pgi 14.0 0.550none herbivorous chortobiont  
mesophilous
25   Pf 26.5 0.9622642none  omnivorous thamnobiont  
mesophilous
26 Pgri 17.5 1.0428571none  omnivorous thamnobiont  
mesophilous
27   Po 17.0 0.8970588none herbivorous chortobiont  
mesophilous
28   Pp 17.5 0.6542857 reduced herbivorous chortobiont  
mesophilous
29   Rr 17.5 0.8857143 reduced  omnivorous chortobiont  
mesophilous
30   Ss 22.5 0.573full herbivorous chortobiont  
mesophilous
31   Sl 20.5 0.6268293 reduced herbivorous chortobiont  
mesophilous
32   Ts 12.5 0.472 reduced herbivorousgeobiont 
hygrophilous
33   Tv 33.0 0.7803030full carnivorous thamnobiont  
mesophilous
34   Tr 20.0 0.900none  omnivorousgeobiont 
hygrophilous



Thank you in advance and kind regards,
Vesna


--
Vesna Gulin,  Research and Teaching Assistant
Department of Biology
Faculty of Science
University of Zagreb
Rooseveltov trg 6, 1 Zagreb, Croatia

__

Re: [R] pie3D.labels

2021-04-01 Thread Collins Boahen via R-help
 Dear Dr. Lemon,
Thank you for the rapid response and suggestions as well.
BestCollins
On Tuesday, March 30, 2021, 11:46:08 PM GMT+2, Jim Lemon 
 wrote:  
 
 Hi Collins,
pie3D draws a pseudo-3D pie and then places 2D labels around it. If
you put the labels on top of the pie, it is not going to look right.
The labels will be displayed with an orthogonal viewing angle, while
the pie will be tilted. pie3D is one of those functions that I wrote
for those who might otherwise think that if R can't produce 3D pie
charts, then R is no good. You can do fulsomely decorative plots in R,
and if your boss demands a 3D pie chart, you can do it. If you really
want to create a 3D pie chart with 3D labels, do it with a 3D
rendering program like POVray. I'm afraid that I don't have the time
to provide you with an example right now.

Jim

On Tue, Mar 30, 2021 at 11:42 PM Collins Boahen  wrote:
>
> Dear Dr. Lemon,
>
> Thank you for developing such a fantastic package.
>
> I would like to find out if there is a way to insert the labels inside the 
> pie and  manipulate the labels for fit perfectly.
>
> Please any tips or suggestions will be appreciated.
>
> Thank you
>
> Best
> Collins
>
  
[[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] cox.zph

2021-04-01 Thread Bendix Carstensen
Further to John Sorkin's post on the cox.zph:
You get test(s) of whether there is an interaction between a variable, say, 
sex, and time.

Suppose it is significant. You will have no clue whether the M/W hazard ratio 
is increasing or decreasing by time.

Suppose it is not significant. You will have no clue whether the 
(non-significant) M/W hazrad ratio exhibits a pattern that is worth looking 
further into or not.

In this sense the cox.zph is a perfect tool to allow you to write 'we checked 
for non proportionality' instead of 'we have no clue of how the M/W ratio 
varies by time'.

If you label it what it is, namely a test of interaction, you might realize 
that you should ESTIMATE the shape and size of the interaction before deriving 
a test, either ad-hoc by the Shoenfeld residuals or by proper modeling.

See for example pp 202 ff. in 'Epidemiology with R' by (surprise, surprise) me, 
published by OUP a few months ago.

b.r.
Bendix Carstensen
Senior Statistician
Steno Diabetes Center Copenhagen
Clinical Epidemiology
Niels Steensens Vej 2-4
DK-2820 Gentofte
Denmark
tel: +45 30 91 29 61
b...@bxc.dk
bendix.carsten...@regionh.dk
http://BendixCarstensen.com





Region Hovedstaden anvender de personoplysninger, du giver os i forbindelse med 
din henvendelse. Du kan læse mere om formålet med anvendelsen samt dine 
rettigheder på vores hjemmeside: www.regionh.dk/persondatapolitik

__
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 can certain variables be automatically excluded from being saved?

2021-04-01 Thread Ralf Goertz
Am Thu, 1 Apr 2021 08:39:45 -0400
schrieb Duncan Murdoch :

> On 01/04/2021 4:05 a.m., Ralf Goertz wrote:
> > Hi,
> >
> > after having read here about the "seed problem" I wonder if there
> > is a way to automatically exclude certain variables from being
> > saved when the workspace image is saved at the end of an
> > interactive session. I have been using .First() and .Last() for
> > ages but apparently they are of no help as .First() gets called
> > before loading the workspace and .Last() after it has been saved.
> > At least the line
> >
> > if (".Random.seed" %in% ls(all.names=T)) rm(.Random.seed, pos=1)
> >
> > in either of those functions doesn't have the desired effect.
>
> Jim suggested a way to do that, but I don't think it's really a good
> idea:  it just fixes one aspect of the problem, it doesn't solve the
> whole thing.
>
> The real problem is saving the workspace occasionally, but always
> loading it.  The "always loading" part is automatic, so I think the
> real solution should address the "occasionally saving" part.

Yes, that is exactly what I quite often do. I have to work in different
projects and I usually start R in the project directory. When I do
serious stuff I save afterwards. But quite often I want to check
something quickly and then I don't want to clutter up my workspace.

> If you always save the workspace, things are fine.  You'll save the
> seed at the end of one session, and load it at the beginning of the
> next.
>
> If you never save the workspace, things are also fine.  You'll always
> generate a new seed in each session that needs one.
>
> Personally, I believe in the "never save it" workflow.  I think it
> has lots of benefits besides the random seed issue:  you won't get a
> more-and-more cluttered workspace over time, you end up with more
> reproducible results, etc.  However, I can understand that some
> people use a different workflow, so "always save it" is sometimes a
> reasonable choice.
>
> So the real problem is the "sometimes save it" workflow, which is
> **encouraged** by the default q(save = "default") option, which asks
> when interactive.  Changing the default to act like q(save = "no")
> would be my preference (and that's how I configure things), but
> changing it to act like q(save = "yes") would be an improvement over
> the current choice.

I would prefer to be able to only save the history since that is where
the work is done. Usually, my data is easily restored using commands
from the history. I could probably accomplish that by linking .RData to
/dev/null or making it an empty readonly file. However, I would have to
do that in every directory I happen to use R in.

__
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 can certain variables be automatically excluded from being saved?

2021-04-01 Thread Duncan Murdoch

On 01/04/2021 4:05 a.m., Ralf Goertz wrote:

Hi,

after having read here about the "seed problem" I wonder if there is a
way to automatically exclude certain variables from being saved when the
workspace image is saved at the end of an interactive session. I have
been using .First() and .Last() for ages but apparently they are of no
help as .First() gets called before loading the workspace and .Last()
after it has been saved. At least the line

if (".Random.seed" %in% ls(all.names=T)) rm(.Random.seed, pos=1)

in either of those functions doesn't have the desired effect.


Jim suggested a way to do that, but I don't think it's really a good 
idea:  it just fixes one aspect of the problem, it doesn't solve the 
whole thing.


The real problem is saving the workspace occasionally, but always 
loading it.  The "always loading" part is automatic, so I think the real 
solution should address the "occasionally saving" part.


If you always save the workspace, things are fine.  You'll save the seed 
at the end of one session, and load it at the beginning of the next.


If you never save the workspace, things are also fine.  You'll always 
generate a new seed in each session that needs one.


Personally, I believe in the "never save it" workflow.  I think it has 
lots of benefits besides the random seed issue:  you won't get a 
more-and-more cluttered workspace over time, you end up with more 
reproducible results, etc.  However, I can understand that some people 
use a different workflow, so "always save it" is sometimes a reasonable 
choice.


So the real problem is the "sometimes save it" workflow, which is 
**encouraged** by the default q(save = "default") option, which asks 
when interactive.  Changing the default to act like q(save = "no") would 
be my preference (and that's how I configure things), but changing it to 
act like q(save = "yes") would be an improvement over the current choice.


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] How can certain variables be automatically excluded from being saved?

2021-04-01 Thread Jim Lemon
Hi Ralph,
I suppose you could write a wrapper for q():

byebye<-function(drop=".Random.seed",save = "default", status = 0,
runLast = TRUE) {
 if(drop %in% ls(all.names=TRUE)) rm(drop,pos=1)
 q(save=save,status=status,runLast=runLast)
)

warning: untested

Jim

On Thu, Apr 1, 2021 at 7:05 PM Ralf Goertz  wrote:
>
> Hi,
>
> after having read here about the "seed problem" I wonder if there is a
> way to automatically exclude certain variables from being saved when the
> workspace image is saved at the end of an interactive session. I have
> been using .First() and .Last() for ages but apparently they are of no
> help as .First() gets called before loading the workspace and .Last()
> after it has been saved. At least the line
>
> if (".Random.seed" %in% ls(all.names=T)) rm(.Random.seed, pos=1)
>
> in either of those functions doesn't have the desired effect.
>
> __
> 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] How can certain variables be automatically excluded from being saved?

2021-04-01 Thread Ralf Goertz
Hi,

after having read here about the "seed problem" I wonder if there is a
way to automatically exclude certain variables from being saved when the
workspace image is saved at the end of an interactive session. I have
been using .First() and .Last() for ages but apparently they are of no
help as .First() gets called before loading the workspace and .Last()
after it has been saved. At least the line

if (".Random.seed" %in% ls(all.names=T)) rm(.Random.seed, pos=1)

in either of those functions doesn't have the desired effect.

__
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] Violin plot with mean_sdl

2021-04-01 Thread Mahmood Naderan-Tahan
Hi,

I followed the example described at [1] but I don't know why I get the 
following warning


> library(ggplot2)
> library(Hmisc)
> mydata <- read.csv('test.csv', header=T,row.names=1)
> mydata
 V1  V2   V3 V4
P1 73.6 0.7 74.6  R
P2 75.2 0.7 75.8  R
P3  6.5 0.0  7.3  R
P4 41.4 0.3 39.2  C
P5  5.4 0.1 18.2  C
P6 18.8 0.3 30.3  C
> p <- ggplot(mydata, aes(x=V4, y=V1)) + geom_violin(trim=FALSE)
> p + stat_summary(fun.data="mean_sdl", mult=1,
+  geom="crossbar", width=0.2 )
Warning message:
Ignoring unknown parameters: mult


How can I fix that?



[1] 
http://www.sthda.com/english/wiki/ggplot2-violin-plot-quick-start-guide-r-software-and-data-visualization


Regards,
Mahmood

[[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.