[R] Use generic functions, e.g. print, without UseMethod?

2023-08-11 Thread Sigbert Klinke
Hello, I have defined a function 'equations(...)' which returns an object with class 'equations'. I also defined a function 'print.equations' which prints the object. But I did not use 'equations <- function(x, ...) UseMethod("equations"). Two questions: 1.) Is this a sensible approach? 2.)

Re: [R] Use generic functions, e.g. print, without UseMethod?

2023-08-11 Thread Ivan Krylov
On Fri, 11 Aug 2023 09:20:03 +0200 Sigbert Klinke wrote: > I have defined a function 'equations(...)' which returns an object > with class 'equations'. > But I did not use 'equations <- function(x, ...) > UseMethod("equations"). Two questions: > > 1.) Is this a sensible approach? Quite. If the

[R] Puzzled by results from base::rank()

2023-08-11 Thread Chris Evans via R-help
I understand that the default ties.method is "average".  Here is what I get, expanding a bit on the help page example. Running R 4.3.1 on Ubuntu 22.04.2. > x2 <- c(3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5) > rank(x2)  [1]  4.5  1.5  6.0  1.5  8.0 11.0  3.0 10.0  8.0  4.5  8.0 OK so the ties, each of wi

Re: [R] Use generic functions, e.g. print, without UseMethod?

2023-08-11 Thread Rui Barradas
Às 08:20 de 11/08/2023, Sigbert Klinke escreveu: Hello, I have defined a function 'equations(...)' which returns an object with class 'equations'. I also defined a function 'print.equations' which prints the object. But I did not use 'equations <- function(x, ...) UseMethod("equations"). Two

Re: [R] Puzzled by results from base::rank()

2023-08-11 Thread Gerrit Eichner
Dear Chris, the members of the triplet would be ranked 4, 5 and 6 (in your example), so the *mean of their ranks* is correctly 5. For any set of k tied values the ranks of its elements are averaged (and assigned to each of its k members). Hth -- Gerrit --

Re: [R] Puzzled by results from base::rank()

2023-08-11 Thread Ebert,Timothy Aaron
I have entered values into Excel, and sorted them. I am assuming you are asking why the value 3 in x2 is ranked 4.5 versus in x5 it has a rank of 5. X2 looks like this Value RankOrder 1 1.5 1 1 1.5 2 2 3 3 3 4.5 4 3 4.5 5 4 6 6

Re: [R] group consecutive dates in a row

2023-08-11 Thread Stefano Sofia
Thank you for your hints. All of them have been useful, and you solved my problem. I understood the role of rle, but I think that for my task its use is not fundamental. I will put more attention on looking for the existing documentation. Thank you again Stefano (oo) --oOO--( )--O

[R] Different TFIDF settings in test set prevent testing model

2023-08-11 Thread James C Schopf
Hello, I'd be very grateful for your help. I randomly separated a .csv file with 1287 documents 75%/25% into 2 csv files, one for training an algorithm and the other for testing the algorithm. I applied similar preprocessing, including TFIDF transformation, to both sets, but R won't let me mak

Re: [R] Different TFIDF settings in test set prevent testing model

2023-08-11 Thread Bert Gunter
I know nothing about tf, etc., but can you not simply read in the whole file into R and then randomly split using R? The training and test sets would simply be defined by a single random sample of subscripts which is either chosen or not. e.g. (simplified example -- you would be subsetting the row

Re: [R] Different TFIDF settings in test set prevent testing model

2023-08-11 Thread Ivan Krylov
В Fri, 11 Aug 2023 10:20:27 + James C Schopf пишет: > > train_text_dtm <- > > DocumentTermMatrix(Corpus(VectorSource(all_train_tokens))) > > test_text_dtm <- > > DocumentTermMatrix(Corpus(VectorSource(all_test_tokens))) I understand the need to prepare the test dataset separately (e.g. in

Re: [R] Different TFIDF settings in test set prevent testing model

2023-08-11 Thread James C Schopf
Thank you Bert and Ivan, I was building the SVM model in hopes of applying it to future cases and hoped that the model would be able to deal with new words it hadn't encountered during training. But I tried Bert's suggestion by converting all of the data to tokens, creating a DTM, transformin

[R] geom_smooth

2023-08-11 Thread Thomas Subia via R-help
Colleagues, Here is my reproducible code for a graph using geom_smooth set.seed(55) scatter_data <- tibble(x_var = runif(100, min = 0, max = 25)    ,y_var = log2(x_var) + rnorm(100)) library(ggplot2) library(cowplot) ggplot(scatter_data,aes(x=x_var,y=y_var))+   geom_point()+

Re: [R] geom_smooth

2023-08-11 Thread Rui Barradas
Às 05:17 de 12/08/2023, Thomas Subia via R-help escreveu: Colleagues, Here is my reproducible code for a graph using geom_smooth set.seed(55) scatter_data <- tibble(x_var = runif(100, min = 0, max = 25)    ,y_var = log2(x_var) + rnorm(100)) library(ggplot2) library(cowplot)

Re: [R] geom_smooth

2023-08-11 Thread Berwin A Turlach
G'day Thomas, On Sat, 12 Aug 2023 04:17:42 + (UTC) Thomas Subia via R-help wrote: > Here is my reproducible code for a graph using geom_smooth The call "library(tidyverse)" was missing. :) > I'd like to add a black boundary around the shaded area. I suspect > this can be done with geom_rib

Re: [R] geom_smooth

2023-08-11 Thread CALUM POLWART
+ geom_ribbon(stat = "smooth", se = TRUE, alpha = 0, # or, use fill = NA colour = "black", linetype = "dotted") Does that work? On Sat, 12 Aug 2023, 06:12 Rui Barradas, wrote: > Às 05:17 de 12/08/2023, Thomas Subia via R-help escreveu: >