Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Jeff Newmiller
> I was thrown off by the fact that after mutating it looked like the column > data type had been changed. It was changed... in a new copy of the data frame that, because it was at the top-level interactive prompt and not being saved, was printed and then discarded. On July 25, 2020 5:11:03 P

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread H
On 07/25/2020 04:17 PM, Jeff Newmiller wrote: > False. Mutate is similar in structure to the base function `within`. Which is > why you have to assign the altered data frame back onto itself. > > On July 25, 2020 12:59:06 PM PDT, "Patrick (Malone Quantitative)" > wrote: >> Jeff, >> >> mutate(),

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Duncan Murdoch
Were you thinking of the %<>% operator? That's a magrittr thing, where x %<>% y acts like x <- x %>% y . Duncan Murdoch On 25/07/2020 4:18 p.m., Patrick (Malone Quantitative) wrote: Oh, right--I puzzled out my mistake. On Sat, Jul 25, 2020 at 4:17 PM Jeff Newmiller wrote: False. Mutate is

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Patrick (Malone Quantitative)
Oh, right--I puzzled out my mistake. On Sat, Jul 25, 2020 at 4:17 PM Jeff Newmiller wrote: > False. Mutate is similar in structure to the base function `within`. Which > is why you have to assign the altered data frame back onto itself. > > On July 25, 2020 12:59:06 PM PDT, "Patrick (Malone Quan

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Jeff Newmiller
False. Mutate is similar in structure to the base function `within`. Which is why you have to assign the altered data frame back onto itself. On July 25, 2020 12:59:06 PM PDT, "Patrick (Malone Quantitative)" wrote: >Jeff, > >mutate(), which is I think part of dplyr, also violates this, for what

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Patrick (Malone Quantitative)
Jeff, mutate(), which is I think part of dplyr, also violates this, for what it's worth. I suspect the breaking point is that mutate() is intended to create new columns in the dataframe, not alter existing ones. On Sat, Jul 25, 2020 at 3:52 PM Jeff Newmiller wrote: > R is largely a functional l

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Jeff Newmiller
R is largely a functional language. You do something to an input and end up with an output that has no effect on the input. This is actually a highly desirable feature. If you want your df variable to reflect changes made then you need to assign your result back into it. df <- df %>% mutate(v

Re: [R] Modifying dataframe with mutate()

2020-07-25 Thread Patrick (Malone Quantitative)
This seems needlessly complicated. df$v1 <- as.double(df$v1) Or as.numeric() On Sat, Jul 25, 2020 at 3:31 PM H wrote: > In a statement like: > > df %>% mutate(v1 = as.double(v1)) > > I expect the variable v1 in dataframe df to have been converted into a > double. However, when I do: > > str(df

[R] Modifying dataframe with mutate()

2020-07-25 Thread H
In a statement like: df %>% mutate(v1 = as.double(v1)) I expect the variable v1 in dataframe df to have been converted into a double. However, when I do: str(df) v1 still shows as int. Do I need to save the modified dataframe after mutating a variable? ___

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/25/2020 03:01 PM, Rui Barradas wrote: > Hello, > > OK, now it's reproducible, thanks. > align = "hv" works like I had suggested. > > The full code is now > > library(ggplot2) > library(cowplot) > > s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, > Sepal.Width)) + g

Re: [R] One year return not year to date

2020-07-25 Thread Rui Barradas
Hello, I believe the error message comes from the last line, getQuote returns a data.frame with a Date column and log(aaa) will try to log a date. Error. log(aaa[-1]) works, maybe the OP wants to revise the code and then come back to this or other thread. Hope this helps, Rui Barradas Às 1

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread Rui Barradas
Hello, OK, now it's reproducible, thanks. align = "hv" works like I had suggested. The full code is now library(ggplot2) library(cowplot) s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, Sepal.Width)) + geom_point() v <- ggplot(data = subset(iris, Species == 'setosa'

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/25/2020 12:36 PM, Rui Barradas wrote: > Hello, > > Inline. > > Às 16:54 de 25/07/2020, H escreveu: >> On 07/24/2020 05:56 PM, Rui Barradas wrote: >>> Hello, >>> >>> I've just tried it. >>> >>> library(ggplot2) >>> #library(grid) >>> library(cowplot) >>> >>> s <- ggplot(data = subset(iris, Spe

Re: [R] One year return not year to date

2020-07-25 Thread Bert Gunter
What is the error message? Knowing this may help others diagnose the problem. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Jul 25, 2020 at 8:41 AM Pedro

Re: [R] [External] Re: help with web scraping

2020-07-25 Thread William Michels via R-help
Dear Spencer Graves (and Rasmus Liland), I've had some luck just using gsub() to alter the offending "" characters, appending a "___" tag at each instance of "" (first I checked the text to make sure it didn't contain any pre-existing instances of "___"). See the output snippet below: > library(R

Re: [R] [External] Re: help with web scraping

2020-07-25 Thread Spencer Graves
Dear Rasmus Liland et al.: On 2020-07-25 11:30, Rasmus Liland wrote: On 2020-07-25 09:56 -0500, Spencer Graves wrote: Dear Rasmus et al.: It is LILAND et al., is it not? ... else it's customary to put a comma in there, isn't it? ... The APA Style recommends "Sharp et al., 2007": https:

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread Rui Barradas
Hello, Inline. Às 16:54 de 25/07/2020, H escreveu: On 07/24/2020 05:56 PM, Rui Barradas wrote: Hello, I've just tried it. library(ggplot2) #library(grid) library(cowplot) s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, Sepal.Width)) + geom_point() v <- ggplot(dat

Re: [R] [External] Re: help with web scraping

2020-07-25 Thread Rasmus Liland
On 2020-07-25 09:56 -0500, Spencer Graves wrote: > Dear Rasmus et al.: It is LILAND et al., is it not? I do not belong to a large Confucian family structure (putting the hunter-gatherer horse-rider tribe name first in all-caps in the email), else it's customary to put a comma in there, isn't

Re: [R] Arranging ggplot2 objects with ggplotGrob()

2020-07-25 Thread H
On 07/24/2020 05:56 PM, Rui Barradas wrote: > Hello, > > I've just tried it. > > library(ggplot2) > #library(grid) > library(cowplot) > > s <- ggplot(data = subset(iris, Species == 'virginica'), aes(Sepal.Length, > Sepal.Width)) + geom_point() > v <- ggplot(data = subset(iris, Species == 'setosa')

[R] One year return not year to date

2020-07-25 Thread Pedro páramo
Hi all, I want to calculate interanual (not year to date) variation of a stock, I am able to obtain year to date with annualReturn, but no way to obtain the interanual increase. It says me no numerical output. Can anyone guide me to obtain it. library(PerformanceAnalytics) library(dplyr) library

Re: [R] [External] Re: help with web scraping

2020-07-25 Thread Spencer Graves
Dear Rasmus et al.: On 2020-07-25 04:10, Rasmus Liland wrote: > On 2020-07-24 10:28 -0500, Spencer Graves wrote: >> Dear Rasmus: >> >>> Dear Spencer, >>> >>> I unified the party tables after the >>> first summary table like this: >>> >>> url <- >>> "https://s1.sos.mo.gov/CandidatesOnWeb/Disp

Re: [R] Error in Rose Method (class balancing)

2020-07-25 Thread Rasmus Liland
On 2020-07-23 13:10 -0700, Jeff Newmiller wrote: > > I would recommend trying to use dput() > to remove the need for the file Awesome! I've been looking for dput() for a long time. Thank you! signature.asc Description: PGP signature __ R-help@r-p

Re: [R] Error in Rose Method (class balancing)

2020-07-25 Thread Neha gupta
OK thanks a lot David, I hope it will work for me. Best regards Neha On Saturday, July 25, 2020, David Winsemius wrote: > > On 7/24/20 3:08 AM, Neha gupta wrote: > > O, I am very sorry for that, I have now included > > output of dput is: structure(list(unique_id = c("L116", "L117", "L496",

Re: [R] Fortune nomination .... Re: Looping through a dataframe

2020-07-25 Thread Michael Dewey
Dear Chris Just send it to the maintainer Achim Zeileis to whom I have cc'ed this in case he is not reading the list at the moment. Michael On 25/07/2020 06:21, Chris Evans wrote: I really don't want to put too many Emails to the list but I had the same reaction to that lovely line ... so n

Re: [R] prevent XML::readHTMLTable from suppressing

2020-07-25 Thread Rasmus Liland
On 2020-07-24 22:59 -0500, Spencer Graves wrote: > Hello, All: > > Thanks to Rasmus Liland, William > Michels, and Luke Tierney with my > earlier web scraping question.  With > their help, I've made progress.  > Sadly, I still have a problem:  One > field has "", which gets > suppressed by X

Re: [R] curl options?

2020-07-25 Thread Rasmus Liland
On 2020-07-24 13:34 -0700, Roy Mendelssohn - NOAA Federal wrote: | On Jul 24, 2020, at 1:21 PM, Roy Mendelssohn - NOAA Federal wrote: | | On Jul 23, 2020, at 4:20 PM, Rasmus Liland wrote: | | | On 2020-07-23 14:56 -0700, Roy Mendelssohn - NOAA Federal via R-help wrote: | | | | I am trying to ge

Re: [R] [External] Re: help with web scraping

2020-07-25 Thread Rasmus Liland
On 2020-07-24 10:28 -0500, Spencer Graves wrote: > Dear Rasmus: > > > Dear Spencer, > > > > I unified the party tables after the > > first summary table like this: > > > > url <- > > "https://s1.sos.mo.gov/CandidatesOnWeb/DisplayCandidatesPlacement.aspx?ElectionCode=750004975"; > > M_sos