Re: [R] summarize_all Function

2020-10-01 Thread Bill Dunlap
The warning gives some suggestions.  E.g., replace funs(sum,prod) with
list(sum=sum,prod=prod).

% R CMD Rscript -e 'library(dplyr,warn.conflicts=FALSE);
data.frame(X=1:3,Y=c(11,13,17)) %>% summarize_all(funs(sum,prod))'
  X_sum Y_sum X_prod Y_prod
1 641  6   2431
Warning message:
`funs()` is deprecated as of dplyr 0.8.0.
Please use a list of either functions or lambdas:

  # Simple named list:
  list(mean = mean, median = median)

  # Auto named with `tibble::lst()`:
  tibble::lst(mean, median)

  # Using lambdas
  list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
This warning is displayed once every 8 hours.
Call `lifecycle::last_warnings()` to see where this warning was generated.

% R CMD Rscript -e 'library(dplyr,warn.conflicts=FALSE);
data.frame(X=1:3,Y=c(11,13,17)) %>% summarize_all(list(sum=sum,prod=prod))'
  X_sum Y_sum X_prod Y_prod
1 641  6   2431

On Thu, Oct 1, 2020 at 10:29 AM Jeff Reichman 
wrote:

> r-help Forum
>
>
>
> I'm using the dplyr:: summarize_all(funs(sum)) function and am receiving a
> warning message that the `funs()` is deprecated as of dplyr 0.8.0. Ok what
> should I be using to summarize  all columns by sum?
>
>
>
> Jeff
>
>
> [[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] summarize_all Function

2020-10-01 Thread Rui Barradas

Hello,

Any of the two will do, the first is now preferred.


library(dplyr)

mtcars %>%
  summarise(across(everything(), sum))

mtcars %>%
  summarise_all(sum)   # no need for `funs()`


Hope this helps,

Rui Barradas

Às 18:29 de 01/10/20, Jeff Reichman escreveu:

r-help Forum

  


I'm using the dplyr:: summarize_all(funs(sum)) function and am receiving a
warning message that the `funs()` is deprecated as of dplyr 0.8.0. Ok what
should I be using to summarize  all columns by sum?

  


Jeff


[[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] summarize_all Function

2020-10-01 Thread Jeff Reichman
r-help Forum

 

I'm using the dplyr:: summarize_all(funs(sum)) function and am receiving a
warning message that the `funs()` is deprecated as of dplyr 0.8.0. Ok what
should I be using to summarize  all columns by sum?

 

Jeff


[[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] How to decrease size of points?

2020-10-01 Thread Avi Gross via R-help
It is better to understand the requirements before suggesting a way to do it.

My GUESS is that the questioner  wants the circles of different sizes based on 
a factor but the natural choices start too high for their needs/taste. So they 
want a base size of 0.8 that is either the minimum or maximum size. I offer a 
verbal solution but end with possibly a simple solution using other 
functionality.

So I am proposing a solution but only if the above is what you want. If it is 
something else, state it clearly.

So say you want the sizes to go from 0.8 to 1.2. The approach offered can be 
tweaked to do the following in English.

Calculate the number of unique levels of the factor in the data. Make sure the 
factor is (re)ordered to have those N levels and in the right order.

Create a vector of N values but they should not all be 0.8. They should have 
the first one be 0.8, and the second would have added to that something like  
(1.2 - 0.8)/N and the next has double that added and so on. With the proper 
calculations, you get a smoothly increasing value for a size for the circles in 
a vector of the right size. Many other methods can be used like multiplying the 
preceding size by 1.1 and you can play rounding games or anything else. In the 
end, you have a_vector looking a bit like c(0.8, 0.84, 0.88, 0.92, ... 1.16, 
1.20) or whatever.

Now note the word "manual" in scale_size_manual(values = a_vector)

It means you are doing things manually rather than allowing ggplot to choose 
them automatically. Saying size=variable is now not useful or even wanted. You 
are choosing manually.

Just give it the vector of increasing sizes you wanted and it should use them 
in that order as long as the factor you use is in the order you want. If it is 
a categorical variable with your required order, there are ways to get what you 
want either by making it ordered or re-ordering the factors so the hidden index 
values of 1,2,3 ... correspond.

I have not tried this and am not supplying actual code, just the concept.  But 
this approach feels too long and cumbersome given how common a need like the 
one I think you want might be.

A much better solution would be a way to specify a baseline minimum and perhaps 
maximum and let the underlying ggplot print method figure things out. If the 
manual pages are correct, it may make sense to use other "scale" functions that 
allow you to specify a minimum and maximum size 


https://www.rdocumentation.org/packages/ggplot2/versions/1.0.1/topics/scale_size

scale_size_continuous(..., range = c(1, 6))
scale_size(..., range = c(1, 6))
scale_size_discrete(..., range = c(1, 6))

I see examples that suggest it works the way I want:

(p <- qplot(mpg, cyl, data=mtcars, size=cyl))
...
p + scale_size(range = c(0, 10))
p + scale_size(range = c(1, 2))

In the above you both ask ggplot to adjust the size to match the 
variable/column called cylinder and also provide a range for those values to be 
distributed between.

Sounds like a plan to try?

-Original Message-
From: R-help  On Behalf Of Medic
Sent: Wednesday, September 30, 2020 3:01 PM
To: Rui Barradas ; r-help@r-project.org
Subject: Re: [R] How to decrease size of points?

№1 Medic:
The code works as I want, but the points (circles) on the plot are too big. How 
to decrease them? Where to insert (for instance) size = 0.8 for points 
(circles) on plot?

p1 <- p + geom_point(aes(size = Stage), alpha = 1/3) + xlab ("X") +
ylab("Y") + geom_smooth()

Stage is factor, x and y - continuous
===
№2 Rui Barradas:
add the scale_size
p1 + scale_size_manual(values = 0.8)
===
№3 Medic:
Thanks Rui, but I got:
Error: Insufficient values in manual scale. 12 needed but only 1 provided.
(or Error: Continuous value supplied to discrete scale) ===
№4 Rui Barradas:
Try
nsize <- length(unique(df1$Stage))
before the plot and then
p1 + scale_size_manual(values = rep(0.8, nsize)) ===
№5 Medic:
Rui, your example is very good!
Now your code works, but not as I want.

Why did I use:
geom_point(aes(size = Stage)...?
In order to receive points of DIFFERENT size!

And what does your code do?
It assigns the same fixed size to ALL points.

I don't need this.
I sincerely thank you and closing the topic!

__
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] (no subject)

2020-10-01 Thread Peter Dalgaard
Then please follow the link in the footer. Other recipients can't help you.


> On 1 Oct 2020, at 09:30 , Marte Lilleeng  wrote:
> 
> I want to unsubscribe from this list.
> 
> -- 
> Mvh Marte Synnøve Lilleeng
> tlf 97 74 38 12
> 
>   [[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.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
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] (no subject)

2020-10-01 Thread Marte Lilleeng
I want to unsubscribe from this list.

-- 
Mvh Marte Synnøve Lilleeng
tlf 97 74 38 12

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