[R] Best place to ask questions about non-R Base topics, ex. dplyr, dbplyr, etc. ?

2022-10-26 Thread Kelly Thompson
__ 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

[R] getting to a point where packages are installed and "ready to use", without unnecessarily reinstalling packages

2022-10-25 Thread Kelly Thompson
I have R packages I want to use. Q. What is the "best" way to get to a point where all of the packages are installed and "ready to use", AND where I only install or re-install a package if doing so is needed? #I searched the web for insights and found these:

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Kelly Thompson
aracter vector should look like > > c("[", "packages_i_want_to_use", "1") > > You can try this yourself with quote(packages_i_want_to_use[1]) which returns > its first argument, unevaluated. > > On Mon, Oct 24, 2022, 12:46 Kelly Thompson wrote:

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Kelly Thompson
library(), does not evaluate its first argument > UNLESS you add character.only = TRUE > > require( packages_i_want_to_use[1], character.only = TRUE) > > > On Mon, Oct 24, 2022, 12:26 Kelly Thompson wrote: >> >> # Below, when using require(), why do I get the error message &

[R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Kelly Thompson
# Below, when using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ? # This is my reproducible code: #create a vector with the names of the packages I want to use packages_i_want_to_use <- c('base', 'this_pac_does_not_exist') # Here I get

Re: [R] getting data from a "vertical" table into a "2-dimensional" grid

2022-10-21 Thread Kelly Thompson
95282 > 1997 13601 NA 134757 12398NA > 1998 30537 51117 31333 20204NA > 1999 39240 87845 62479NA 98804 > > If this is not what you wanted, you may need to explain further or > await a response from someone more insightful than I. > > Cheers, > Bert > >

Re: [R] getting data from a "vertical" table into a "2-dimensional" grid

2022-10-21 Thread Kelly Thompson
As my end result, I want a matrix or data frame, with one row for each year, and one column for each category. On Fri, Oct 21, 2022 at 6:23 PM Kelly Thompson wrote: > > # I think this might be a better example. > > # I have data presented in a "vertical" da

Re: [R] getting data from a "vertical" table into a "2-dimensional" grid

2022-10-21 Thread Kelly Thompson
rix(data = data_expanded$sum_of_sales, nrow = length(unique(data_expanded$year)), ncol = length(unique(data_expanded$category)) , byrow = TRUE, dimnames = list( unique(data_expanded$year), unique(data_expanded$category) ) ) data_original data_expanded mat On Fri, Oct 21, 2022 at 5:03 PM Kelly Thompson w

[R] getting data from a "vertical" table into a "2-dimensional" grid

2022-10-21 Thread Kelly Thompson
### #I have data presented in a "vertical" data frame as shown below in data_original. #I want this data in a matrix or "grid", as shown below. #What I show below seems like one way this can be done. #My question: Are there easier or better ways to do this, especially in Base R, and also in R

[R] From within R, what are "good" ways to run SQL code contained in a text file?

2022-05-18 Thread Kelly Thompson
I am interested in this topic and found this post on StackOverflow, https://stackoverflow.com/questions/44853322/how-to-read-the-contents-of-an-sql-file-into-an-r-script-to-run-a-query This response seems especially useful, https://stackoverflow.com/a/44886192/10816734 I'm curious about the

Re: [R] "apply" a function that takes two or more vectors as arguments, such as cor(x, y), over a "category" or "grouping variable" or "index"?

2022-04-09 Thread Kelly Thompson
2 at 5:32 AM Rui Barradas wrote: > > Hello, > > Another option is ?by. > > > by(my_df[-1], my_df$my_category, cor) > by(my_df[-1], my_df$my_category, \(x) cor(x)[1,2]) > > > Hope this helps, > > Rui Barradas > > Às 02:26 de 09/04/2022, Kelly Thompson escrev

[R] What is the intended behavior, when subsetting using brackets [ ], when the subset criterion has NA's?

2022-04-06 Thread Kelly Thompson
I noticed that I get different results when subsetting using subset, compared to subsetting using "brackets" when the subset criteria have NA's. Here's an example #START OF EXAMPLE my_data <- 1:5 my_data my_subset_criteria <- c( F, F, T, NA, NA) my_subset_criteria #subsetting using subset

[R] calculating quintile values of numeric data?

2019-01-22 Thread Kelly Thompson
I’d like to take numeric data, and calculate numeric “quintiles” with integer values in from 1 – 5 , with values in the lowest 20% of values having a value of 1, the >20 - <= 40% of values having a value of 2, the >40% - <=60% of values having a value of 3, etc. How can I use quantcut, or another