[R] Method Guidance

2022-01-11 Thread Jeff Reichman
0 0 7 0 1 3 8 1 1 0 9 0 0 0 10 0 1 2 Jeff Reichman

Re: [R] splitting data matrix into submatrices

2022-01-04 Thread Jeff Newmiller
he matrix into two submatrices >for weekdays and the other for weekends. So please suggest to me anyway that >how I do this? > >On Wednesday, January 5, 2022, 11:10:34 AM GMT+5, Jeff Newmiller > wrote: > > A lot of new R users fail to grasp what makes data frames more u

Re: [R] splitting data matrix into submatrices

2022-01-04 Thread Jeff Newmiller
A lot of new R users fail to grasp what makes data frames more useful than matrices, or use data frames without even realizing they are not using matrices. This is important because there are more tools for manipulating data frames than matrices. One tool is the split function... if you have a

Re: [R] Multiple Data Import Excel

2022-01-04 Thread Jeff Newmiller
Reading Excel files isn't a feature of base R (the topic here... read the Posting Guide linked below) but the readxl contributed package can help with that. The read_xlsx function has arguments to skip rows, limit the number of rows read in, or specify regions to import such as B2:B2. Read the

Re: [R] compiling from source on RedHat 8

2021-12-31 Thread Jeff Newmiller
Perhaps https://stat.ethz.ch/mailman/listinfo/r-sig-fedora ? On December 31, 2021 9:38:25 AM PST, kap4lin wrote: >Hi, > >Before I proceed with the error output, is this the right list for help on >compiling R from source. If not, please point me in the right direction. > >The error itself is

Re: [R] .Rdata not loading

2021-12-24 Thread Jeff Newmiller
The qsave/qread functions from the qs package are functionally interchangeable with saveRDS/readRDS, but faster and create smaller files. A simple if ( file.exists( "obj1.qs" ) ) { obj1 <- qread( "onj1.qs" ) } else { obj1 <- compute_obj1() qsave( obj1, "obj1.qs" ) } can be

Re: [R] .Rdata not loading

2021-12-23 Thread Jeff Newmiller
This practice (saving and resuming from Rdata files) often ends badly this way. Objects that are "shared" in memory get saved as separate data and may not "fit" when re-loaded. This is why re-running from scratch should always be part of your workflow. There are caching approaches that track

Re: [R] Error Awareness

2021-12-23 Thread Jeff Newmiller
You still are not exhibiting signs of understanding Bert's response, and your question is vague, particularly to the extent that it could be pertinent to the R language (and therefore to the topic of this list). R itself just raises an error condition that custom tryCatch or default handling

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
with the difference between vectors and matrix-like objects and data frames. On December 21, 2021 10:09:14 AM PST, Duncan Murdoch wrote: >On 21/12/2021 12:53 p.m., Duncan Murdoch wrote: >> On 21/12/2021 12:29 p.m., Jeff Newmiller wrote: >>> It is a very rational choice, not a

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
actually run significantly faster. On December 21, 2021 9:28:52 AM PST, "Fox, John" wrote: >Dear Jeff, > >On 2021-12-21, 11:59 AM, "R-help on behalf of Jeff Newmiller" > wrote: > >Intuitive, perhaps, but noticably slower. > >I think that

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
a.m., Jeff Newmiller wrote: >> Intuitive, perhaps, but noticably slower. And it doesn't work on tibbles by >> design. Data frames are lists of columns. > >That's just one of the design flaws in tibbles, but not the worst one. > >Duncan Murdoch > >> >> O

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Jeff Newmiller
Intuitive, perhaps, but noticably slower. And it doesn't work on tibbles by design. Data frames are lists of columns. On December 21, 2021 8:38:35 AM PST, Duncan Murdoch wrote: >On 21/12/2021 11:31 a.m., Duncan Murdoch wrote: >> On 21/12/2021 11:20 a.m., Stephen H. Dawson, DSL wrote: >>>

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Jeff Newmiller
or code chunk then I would hope people would share it, but if possible also provide some equivalent base R code to stay on topic. On December 20, 2021 9:26:24 AM PST, Jeff Newmiller wrote: >What is wrong with > >as.data.frame(lapply( Data, sort, decreasing = TRUE )) > >? >

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Jeff Newmiller
What is wrong with as.data.frame(lapply( Data, sort, decreasing = TRUE )) ? On December 20, 2021 8:58:48 AM PST, "Stephen H. Dawson, DSL via R-help" wrote: >Hi, > > >Running a simple syntax set to review entries in dataframe columns. Here >is the working code. > >Data <-

Re: [R] checkpointing

2021-12-13 Thread Jeff Newmiller
This sounds like an OS feature, not an R feature... certainly not a portable R feature. On December 13, 2021 8:37:30 AM PST, Andy Jacobson via R-help wrote: >Has anyone ever considered what it would take to implement checkpointing in R, >so that long-running processes could be interrupted and

Re: [R] subset data frame problem

2021-12-12 Thread Jeff Newmiller
Use one ampersand, not two. And post plain text. On December 12, 2021 8:30:11 PM PST, Kai Yang via R-help wrote: >Hi R team,I want to delete records from a data frame if Class = '1st' and >Survived = 'No'. I wrote the code below, test <- subset(PD, Class != '1st' && >Survived != 'No') >but

Re: [R] Find tibble row with maximum recorded value

2021-12-03 Thread Jeff Newmiller
cfs is not a function. Don't put parentheses next to it. Use square brackets for indexing. On December 3, 2021 12:55:34 PM PST, Rich Shepard wrote: >I find solutions when the data_frame is grouped, but none when it's not. > >The data: ># A tibble: 813,693 × 9 >site_nbr year mon day

Re: [R] Forwarding missing arguments to the `[` method

2021-12-02 Thread Jeff Newmiller
I think you need a reprex... I don't think your claim is correct as stated. On December 2, 2021 1:00:01 PM PST, Ivan Krylov wrote: >Sorry for sending an unfinished message! > >On Thu, 2 Dec 2021 23:57:11 +0300 >Ivan Krylov wrote: > >> Why can I forward missing i,j to built-in `[` > >Why can I

Re: [R] A technical question on methods for "+"

2021-12-02 Thread Jeff Newmiller
I think the fact that character is a built-in type rather than an S3 class has something to do with it. On December 2, 2021 11:31:47 AM PST, Bert Gunter wrote: >... and probably a dumb one and almost certainly not of interest to >most R users. But anyway... > >?"+" says: >"The unary and binary

Re: [R] readxl/lifecycle/rlang

2021-12-01 Thread Jeff Newmiller
This >package ‘rlang’ successfully unpacked and MD5 sums checked >Warning in install.packages : > cannot remove prior installation of package ‘rlang’ indicates that rlang didn't get re-installed. It is a warning because R seems to think it could still be working, but it isn't verifying that

Re: [R] Question about Rfast colMins and colMaxs

2021-12-01 Thread Jeff Newmiller
Avi: As I understand it, the definition regarding what is on-topic is not targeted at tidyverse... it addresses the futility of trying to support the thousands of problem domains represented by contributed packages in one mailing list without drowning the subscribers in discussions about

Re: [R] readxl

2021-12-01 Thread Jeff Newmiller
Probably some kind of failure occurred during package updating and one or more of the packages readxl depends on was removed but not successfully re-installed. Run install.packages( "lifecycle" ) and then update.packages() and try using your function again. If a similar error occurs,

Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Jeff Newmiller
I don't know anything about this package, but read.csv returns a data frame. How you go about forming a matrix using that data frame depends what is in it. If it is all numeric then as.matrix may be all you need. Half of any R data analysis is data... and the details are almost always crucial.

Re: [R] Syntax help for 'Pivot_longer'

2021-11-28 Thread Jeff Newmiller
This "data_long" appears to be a mess you are not satisfied with, rather than the "data" you started with or a model of what you want. On November 28, 2021 9:06:54 AM PST, Philip Monk wrote: >Thanks for your suggestions, Chris. > >I'm writing from Gmail's web client, and have checked the

Re: [R] Large data and space use

2021-11-27 Thread Jeff Newmiller
First priority is to obtain a correct answer. Second priority is to document it and write tests for it. Third priority is to optimize it. Sometimes it is useful to keep intermediate values around to support supplemental calculations ala "summary", that may or may not lead to using rm where you

Re: [R] Fwd: Package is not available for this version of R.

2021-11-26 Thread Jeff Newmiller
Anyone could write a function named prob.def1, and it is not part of base R so it is off-topic here and there is no way for people on this list to definitively know the answer. As far as Google can tell me it is not from CRAN either. OP should go talk to whoever wrote this code. On November

Re: [R] Help needed to understand an error message produced from furrr and future packages

2021-11-25 Thread Jeff Newmiller
This question is off-topic here (see the Posting Guide, you are asking about a contributed package). Like walking down the street and asking this question, someone might know about it, but most will be puzzled. You should know that multicore is quite sensitive to which kinds of operations you

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Jeff Newmiller
/01/2016", "05/03/2017") >as.Date(x, format = "%d/%m/%Y") > > >which produces this output: > > >> x <- c("28/10/2016", "19/11/2016", "31/12/2016", "16/01/2016", >"05/03/2017") >> as.

Re: [R] Date read correctly from CSV, then reformatted incorrectly by R

2021-11-20 Thread Jeff Newmiller
lcome. :) > >Thanks for your time, > >Philip > >Part-time PhD Student (Environmental Science) >Lancaster University, UK. > >~ > >I asked a question a few weeks ago and put together the answer I needed >from the responses but didn't know how to say thanks on

Re: [R] Renaming multiple objects

2021-11-20 Thread Jeff Newmiller
Agreed... This Is The Way. To interactively sit at the R console and type in commands without keeping those commands in an editor and running them from scratch periodically to insure that they achieve your goals is a only a recipe for mystery, not for data analysis. R is a tool for

Re: [R] ggplot2: multiple box plots, different tibbles/dataframes

2021-11-11 Thread Jeff Newmiller
I strongly recommend that you change your way of thinking when it comes to ggplot: if your data are not yet in one data frame then your data are not yet ready for plotting. It is possible to specify separate data frames for different layers of the plot, but this severely complicates building

Re: [R] (no subject)

2021-11-09 Thread Jeff Newmiller
/11/2021 2:45 p.m., Jeff Newmiller wrote: >> This question isn't a "how to do package development" question... this is >> about a specific package so you should send email to the package developer >> identified by the maintainer() function. > >I think Arnaud i

Re: [R] (no subject)

2021-11-09 Thread Jeff Newmiller
This question isn't a "how to do package development" question... this is about a specific package so you should send email to the package developer identified by the maintainer() function. I can't foresee this request finding a positive response from R Core, but email seems the most correct

Re: [R] Plotly

2021-11-08 Thread Jeff Reichman
Bert Ok I'll give that a shot too. Jeff -Original Message- From: Bert Gunter Sent: Monday, November 8, 2021 1:16 PM To: reichm...@sbcglobal.net Cc: R-help Subject: Re: [R] Plotly As Plotly for R is a product of private company, your query is off topic here (though you may get

Re: [R] Plotly

2021-11-08 Thread Jeff Newmiller
ty.plotly.com/c/graphing-libraries/r/9 > > >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 Mon, No

[R] Plotly

2021-11-08 Thread Jeff Reichman
line chart displaying launches by agency type, with highlighting shared_launches %>% plot_ly(x = ~launch_year, y = ~n, color = ~agency_type) %>% add_lines() %>% highlight() Jeff [[alternative HTML version deleted]] __ R-help@r-

Re: [R] Warning msg after reinstall?

2021-11-07 Thread Jeff Newmiller
The topic here is R language, not operating system surgery. You probably shouldn't hold your breath for a solution to this here. That said, compiling and running without installing for access by the whole system is always an option if you can fix the support libraries. On November 7, 2021

Re: [R] Environmental oddity.

2021-11-06 Thread Jeff Newmiller
In general, the search for symbols for a function Z in a package Y will span only those namespaces that the package Y specifies. The search for symbols in a function whose parent environment is the global environment will start there, thereby opening the door to find masking versions of

Re: [R] Error in loadNamespace(i, c(lib.loc, .libPaths())

2021-11-05 Thread Jeff Newmiller
You are using github packages. Post your question on the corresponding packege Issues page on GitHub. Such questions are not related to the topic of the R language (read the Posting Guide, which also indicates that this plain text mailing list will strip formatting from your emails, so do send

Re: [R] extracting a R object from an R image

2021-11-05 Thread Jeff Newmiller
IMO you are being a bit too literal. It is absolutely possible to load the file into a dedicated environment and use the $ or [[]] extraction operator to access a specific object in that environment. ?load ?new.env Or, you can attach the file, copy to a new variable, and detach. (see examples

Re: [R] Date

2021-11-04 Thread Jeff Newmiller
. On November 4, 2021 5:30:22 PM PDT, Val wrote: >Jeff, > >The date from y data file looks like as follow in the Linux environment, >My_date >2019-09-16 >2021-02-21 >2021-02-22 >2017-10-11 >2017-10-10 >2018-11-11 >2017-10-27 >2017-10-30 >2019-05-20 > >On Thu,

Re: [R] Date

2021-11-04 Thread Jeff Newmiller
You are claiming behavior that is not something R does, but is something Excel does constantly. Compare what your data file looks like using a text editor with what R has imported. Absolutely do not use a spreadsheet program to do this. On November 4, 2021 2:43:25 PM PDT, Val wrote: >IHi All,

Re: [R] Fwd: Merging multiple csv files to new file

2021-11-03 Thread Jeff Newmiller
>(Maybe the R Studio free trial/usage is underpowered for my project?) - R is a computer language, as well as a program for interpreting R source code. - RStudio Desktop is an editor with "features" intended to make using R easy. It cannot "do" anything without R being installed. - R is

Re: [R] Fwd: Merging multiple csv files to new file

2021-11-03 Thread Jeff Newmiller
Data type in a CSV is always character until inferred otherwise... it is not necessary nor even easier to manipulate files with Python if you are planning to use R to manipulate the data further with R. Just use the colClasses="character" argument for read.csv. On November 3, 2021 9:47:03 AM

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Jeff Newmiller
Sorry... untested code... use which... not where. On November 1, 2021 10:29:13 AM PDT, Rich Shepard wrote: >On Mon, 1 Nov 2021, Jeff Newmiller wrote: > >> More explicitly... look at rows past the first row. If your csv has 300 >> rows and column 1 has something non-

Re: [R] tidyverse: read_csv() misses column

2021-11-01 Thread Jeff Newmiller
More explicitly... look at rows past the first row. If your csv has 300 rows and column 1 has something non-numeric in row 299 then the whole column gets imported as character data. Try cor_disc[[ 1 ]] |> as.numeric() |> is.na() |> where() to find suspect rows. You may want to read about the

Re: [R] R vs Numpy

2021-10-31 Thread Jeff Newmiller
If you are looking for expertise in answering questions about NumPy, the pool of experts will be smaller here than in a forum whose topic is NumPy. I don't know what "BIO" means... if it alludes to biostatistics then there is a whole separate Bioconductor project that specializes in applying R

Re: [R] Probably off topic but I hope amusing

2021-10-29 Thread Jeff Newmiller
AFAIK NaN originated in the floating point standard IEEE754-1985 as a range of bit patterns that have all 1 bits in the exponent, and the convention to convert such bit patterns to the string "NaN" is an obvious way to handle output of such patterns, regardless of language. Pasting a % symbol

Re: [R] generate random numeric

2021-10-29 Thread Jeff Newmiller
It is difficult to do "truly random" number generation with computers, but fortunately number sequences that appear random but progress consistently from an initial seed value (?set.seed) are actually much more useful for analysis purposes than true randomness is. On October 28, 2021 11:39:07

Re: [R] R vs Numpy

2021-10-28 Thread Jeff Newmiller
This is dangerously close to off topic, or at least it could be fuel for divisive argument rather than informed discussion (most readers here might be short on details of NumPy and long on details regarding R). Have you used a search engine? Google found

Re: [R] docker containers and R

2021-10-27 Thread Jeff Newmiller
Docker containers are built from some starting point defined using docker conventions. They have nothing to do with how you may have installed or configured R on your computer, other than perhaps what you learned but forgot about all that stuff. So the answer depends on what docker image you

Re: [R] R code in RData

2021-10-27 Thread Jeff Newmiller
Sounds right, though the OP appears to be assuming that the code used to generate the data objects in the file will also be there, and we need to be more definitive about that: it is not. Depending how the code was constructed, there may be useful information in the functions that were stored

Re: [R] Need help in R

2021-10-26 Thread Jeff Newmiller
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. One of the items mentioned in the Posting Guide is that homework questions are not okay... we don't know what your instructor is looking for, and

Re: [R] Dates as headers causing confusion but needed to convert to Julian days for ANOVA

2021-10-25 Thread Jeff Newmiller
I use check.names=FALSE more often than not, and I almost never end up changing them "anyway". Back-ticks as quotes are very effective at allowing unusual column names to be used in R code. (The only exception I have to this is when programatically building formulas the eval step gets quite

Re: [R] Dates as headers causing confusion but needed to convert to Julian days for ANOVA

2021-10-25 Thread Jeff Newmiller
You did not say which function you used to import the csv file, but it looks like you probably used read.csv without setting the check.names argument to FALSE. Whether you change that out not, once you have reshaped the data, you can use a format specifier with as.Date to extract a date. (See

Re: [R] small object but huge RData file exported

2021-10-21 Thread Jeff Newmiller
That depends what was in the active environment when you created that formula. You would probably benefit from reading https://adv-r.hadley.nz/environments.html about now, though you are about to enter a complex interaction between functions, formulas and environments. A rational option is

Re: [R] here Package

2021-10-17 Thread Jeff Reichman
Andrew Thank you so much. That was an easy fix. I you have some time I’d like some more info on the close function close(con) Jeff From: Andrew Simmons Sent: Sunday, October 17, 2021 3:35 PM To: reichm...@sbcglobal.net Cc: R-help Mailing List Subject: Re: [R] here Package

[R] here Package

2021-10-17 Thread Jeff Reichman
ng it in other locations still no luck so I'm wondering if I can even use it in this application Jeff [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/li

Re: [R] Subset command

2021-10-15 Thread Jeff Newmiller
I don't see a "second one". Looks like you forgot the subset function call? On October 15, 2021 6:23:56 PM PDT, Steven Yen wrote: >The following "subset command works. I was hoping the second would as >well but it does not. > >My definition of exclude is rejected. > >Help please? Thanks. > > >

Re: [R] How to use ifelse without invoking warnings

2021-10-08 Thread Jeff Newmiller
I don't think it is avoidable... ifelse cannot figure out which elements will exist in the second and third arguments until they are evaluated, so it cannot make use of the TRUE/FALSE information until both possible output vectors have been evaluated, which is a performance hit and yields

Re: [R] Unusual Error Loading tidyverse

2021-10-07 Thread Jeff Newmiller
lse. If >> "somewhere else" isn't first in .libPaths(), R won't see the new installs. >> >> Duncan Murdoch >> >> On 24/09/2021 2:04 p.m., Kevin Thorpe wrote: >>> I did try installing xml2 and it appeared to complete. I will ask him to >>> tr

Re: [R] Rename variables starting with digits

2021-10-06 Thread Jeff Newmiller
>Also, I checked my options and I have my email set to plain text... The warning inserted by the mailing list at the bottom of your message below > [[alternative HTML version deleted]] indicates that you may still need to understand your mail client better. On October 6, 2021 10:30:49 AM

Re: [R] RSQLite slowness

2021-10-06 Thread Jeff Newmiller
Since the sqlite package is contributed, it is NOT related to "core R", and is in fact technically off-topic on this list. FWIW all SQL implementations work better with indexes, but AFAIK the R data frame support does nothing with indexes. This may be related to your question, or not. I am not

Re: [R] Package installation help: Stuck at "** byte-compile and prepare package for lazy loading"

2021-09-30 Thread Jeff Newmiller
This is a microcosm of why installing "all CRAN" packages is a bad idea. Now extend this to the other 5% of 16000+ packages that will have unclear requirements, and when you have all those installed try to update just one of the packages because one of your users has learned of a bug in that

Re: [R] how to combine logic test on vectors in R?

2021-09-30 Thread Jeff Newmiller
No it shouldn't work. unique returns zero or more results so == with a constant will be a logical vector zero or more elements long, which is inappropriate for &&. Use the any function perhaps. On September 30, 2021 8:51:02 AM PDT, Luigi Marongiu wrote: >Yes, but the && should work within

Re: [R] How to install package meta on Linux Ubuntu 21?,

2021-09-29 Thread Jeff Newmiller
This is called hijacking a thread. Bad etiquette. You need to pay attention to column types and NA values. Only do regular expression manipulations on character data, and NA is never something you can do string operations on. On September 29, 2021 7:24:41 PM PDT, giuseppacef...@gmail.com

Re: [R] Rcpp package problems

2021-09-29 Thread Jeff Newmiller
Do read the Posting Guide ... this is the wrong venue for detailed discussions of contributed packages. For this topic I suggest [1], though you may want to make sure you have updated all of your packages with no errors and that this behavior still occurs before going there. You should also

Re: [R] Unusual Error Loading tidyverse

2021-09-24 Thread Jeff Newmiller
Seems like they should install the xml2 package before proceeding to load whatever (tidyverse). This kind of "dependency missing" problem tends to be a recurring problem particularly on Windows but in general when some deeply-embedded dependency fails to load or is removed in preparation for

Re: [R] alternative to subset(dataframe, select = - column) in R

2021-09-24 Thread Jeff Newmiller
The subset function subset( new, select = -ID ) uses non-standard evaluation... it "knows" that when you write the language symbol ID it may match to one of the column names in new, and the `-` in the select argument will be noticed before R tries to change the sign of a variable ID in your

Re: [R] ggplot2 bar chart: order display for each group

2021-09-20 Thread Jeff Newmiller
I could, but this question is off topic on this mailing list. Read the Posting Guide before you post again. Help for ggplot2 can be found in many places... start your search here https://cran.r-project.org/web/packages/ggplot2/index.html. (Hint: your data should be a factor.) On September 20,

Re: [R] problem solution

2021-09-19 Thread Jeff Newmiller
This question is not clear. What do you mean by solution file? You can find documentation for individual datasets by typing a question mark (?) followed by the the name of the dataset. Sample datasets are included in packages. There are several packages included with R that have some datasets.

Re: [R] Cacheing of functions from libraries other than the base in Rmarkdown

2021-09-19 Thread Jeff Newmiller
need cacheing for this >work but I don't know >about data cacheing packages. Might be one of those things where my learning >time might outweigh >time saved but I lost a fair bit of time by being stupid with this so perhaps >not. > >- Original Message - >> From: "

Re: [R] Cacheing of functions from libraries other than the base in Rmarkdown

2021-09-19 Thread Jeff Newmiller
I avoid knitr (Rmarkdown uses knitr) caching like the plague. If I want caching, I do it myself (with or without the aid of one of a data caching package). On September 19, 2021 10:28:49 AM PDT, "Berry, Charles" wrote: >Chris, > > >> On Sep 18, 2021, at 12:26 PM, Chris Evans wrote: >> >>

Re: [R] ReadItem: Error

2021-09-18 Thread Jeff Reichman
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, Sep 18, 2021 at 9:00 AM Jeff Reichman wrote: > > Anyone see what I might be doing wrong? Corrupted rds f

[R] ReadItem: Error

2021-09-18 Thread Jeff Reichman
Anyone see what I might be doing wrong? Corrupted rds file maybe. The error would suggest I'm using an older version of R except I'm running both the latest RStudio and R versions. # Load in the tidyverse, raster, and sf packages library(tidyverse) library(raster) library(sf) # Read the climate

Re: [R] Improvement: function cut

2021-09-17 Thread Jeff Newmiller
Re your objection that "the user has to suspect that some values were not included" applies equally to your proposed warn option. There are a lot of ways to introduce NAs... in real projects all analysts should be suspecting this problem. On September 17, 2021 3:01:35 PM PDT, Leonard Mada via

Re: [R] Good practice for database with utf-8 string in package

2021-09-16 Thread Jeff Newmiller
Agree with Bert per your stated problem, but want to point out that you don't have control over the locale in which your users will be trying to display the encoded strings in your data. I am no expert in this, but you will need to become one in order to understand your own problem and any

Re: [R] show structure of selected columns of dataframe

2021-09-15 Thread Jeff Newmiller
Really? str( df[ , grep(".*_a*.", names(df)) ] ) On September 15, 2021 7:53:17 AM PDT, Luigi Marongiu wrote: >Hello, >I have a dataframe and I would like to browse the information of its >structure only for a subset of columns (since there are hundreds of >them). >For instance, I tried with

Re: [R] How to remove all rows that have a numeric in the first (or any) column

2021-09-14 Thread Jeff Newmiller
=temp) >> mydf >alpha beta..Hello. beta.1 beta.1.1 beta..bye. >1 1Hello 1 1.1bye >2 2Hello 1 1.1bye >3 3Hello 1 1.1bye >4 4Hello 1 1.1bye > >But a tibble handl

Re: [R] How to remove all rows that have a numeric in the first (or any) column

2021-09-14 Thread Jeff Newmiller
: chr "Joyce Pearl Javier" > $ : chr "Ayza Padilla" > $ : num 9 > $ : chr "Walfredson Calderon" > $ : chr "Stephanie Anne Militante" > $ : chr "Rennua Oquilan" > $ : num 10 > $ : chr "Neil John Nery" > $ : chr "Ma

Re: [R] How to remove all rows that have a numeric in the first (or any) column

2021-09-14 Thread Jeff Newmiller
An atomic column of data by design has exactly one mode, so if _any_ values are non-numeric then the entire column will be non-numeric. What does str(VPN_Sheet1$HVA) tell you? It is likely either a factor or character data. On September 14, 2021 7:01:53 PM PDT, Gregg Powell via R-help wrote:

Re: [R] Fastest way to extract rows of smaller matrix many times by index to make larger matrix? and multiply columsn of matrix by vector

2021-09-14 Thread Jeff Newmiller
That is about as fast as it can be done. However you may be able to avoid doing it at all if you fold V2 into a matrix instead. Did you mean to use matrix multiplication in your calculation of M3? On September 13, 2021 11:48:48 PM PDT, nevil amos wrote: >Hi is there a faster way to "extract"

Re: [R] ggsave() with width only

2021-09-06 Thread Jeff Newmiller
be necessary to answer it if you change your approach. On September 6, 2021 7:29:34 AM PDT, Ivan Calandra wrote: >Thank you Jeff for your answer. > >I do use rmarkdown but I do not write papers completely with it. I do >output a report in HTML but I also like to export the plots as PDF so

Re: [R] ggsave() with width only

2021-09-06 Thread Jeff Newmiller
I use an rmarkdown file to generate consistent output figures and tables for html or Word. I just use Rnw files directly if I am generating LaTeX. I do not use R files for building output... and I never use ggsave. So you might consider altering your approach to bypass the question entirely.

Re: [R] Calculate daily means from 5-minute interval data

2021-09-05 Thread Jeff Newmiller
6.34 9.2 2020-11-01 01:15:00 >9 2020-11-01 01:30 PDT 20300 16.37 9.2 2020-11-01 01:30:00 >10 2020-11-01 01:30 PST 20100 16.31 9.2 2020-11-01 01:30:00 >11 2020-11-01 01:45 PDT 20300 16.35 9.2 2020-11-01 01:45:00 >12 2020-11-01 01:45 PST 20100 16.29 9.2 2020-11-01 0

Re: [R] Multivariate tobit regression

2021-09-05 Thread Jeff Newmiller
Quite probably, but not via this mailing list. Do read the Posting Guide mentioned in the footer. http://cran.nexr.com/web/views/Econometrics.html may suggest options. On September 5, 2021 3:43:21 AM PDT, Franklin Feukam via R-help wrote: >Please can I have the package of Multivariate Tobit

Re: [R] Managing NA values in aggregate

2021-09-04 Thread Jeff Newmiller
Literal translation... aggregate( mydf$value , mydf[ , "year_month", drop=FALSE ] , function( x ) if ( all( is.na( x ) ) ) NA else sum( x, na.rm = TRUE ) ) On September 4, 2021 9:06:57 AM PDT, Stefano Sofia wrote: >Dear R-list users, >I encountered a silly problem

Re: [R] Calculate daily means from 5-minute interval data

2021-09-04 Thread Jeff Newmiller
On Fri, 3 Sep 2021, Rich Shepard wrote: On Thu, 2 Sep 2021, Jeff Newmiller wrote: Regardless of whether you use the lower-level split function, or the higher-level aggregate function, or the tidyverse group_by function, the key is learning how to create the column that is the same for all

Re: [R] Calculate daily means from 5-minute interval data

2021-09-02 Thread Jeff Newmiller
Regardless of whether you use the lower-level split function, or the higher-level aggregate function, or the tidyverse group_by function, the key is learning how to create the column that is the same for all records corresponding to the time interval of interest. If you convert the sampdate to

Re: [R] Calculate daily means from 5-minute interval data

2021-08-31 Thread Jeff Newmiller
mean(cfs, na.rm = TRUE) , Count = n() ) ) On August 31, 2021 2:11:05 PM PDT, Rich Shepard wrote: >On Sun, 29 Aug 2021, Jeff Newmiller wrote: > >> The general idea is to create a "grouping" column with repeated values for >&

Re: [R] Calculate daily means from 5-minute interval data

2021-08-29 Thread Jeff Newmiller
IMO assuming periodicity is a bad practice for this. Missing timestamps happen too, and there is no reason to build a broken analysis process. On August 29, 2021 7:09:01 PM PDT, Richard O'Keefe wrote: >Why would you need a package for this? >> samples.per.day <- 12*24 > >That's 12 5-minute

Re: [R] Calculate daily means from 5-minute interval data

2021-08-29 Thread Jeff Newmiller
You may find something useful on handling timestamp data here: https://jdnewmil.github.io/ On August 29, 2021 9:23:31 AM PDT, Jeff Newmiller wrote: >The general idea is to create a "grouping" column with repeated values for >each day, and then to use aggregate to compute your

Re: [R] Calculate daily means from 5-minute interval data

2021-08-29 Thread Jeff Newmiller
The general idea is to create a "grouping" column with repeated values for each day, and then to use aggregate to compute your combined results. The dplyr package's group_by/summarise functions can also do this, and there are also proponents of the data.table package which is high performance

Re: [R] ggplot geom_line problem

2021-08-28 Thread Jeff Newmiller
Maybe you will find that coord_cartesian( ylim=c(-30,30) ) works better since it doesn't filter out data before rendering. On August 28, 2021 6:45:11 PM PDT, p...@philipsmith.ca wrote: >I am preparing a time series plot using the ggplot function. It includes >an area plot outlined at its edges

Re: [R] Finding if numbers fall within a range

2021-08-28 Thread Jeff Newmiller
You messed up the dput somehow... but I think this works: m <- t(structure(c(1, 57, 59, 271, 279, 59, 179, 279, 278, 359, 52, 118, 178, 239, 334), .Dim = c(5L, 3L))) brk <- c( 0, 60, 120, 180, 240, 300 ) mc <- matrix( findInterval( m, brk ), ncol = ncol(m) ) m mc DBI <- apply( mc, 1,

Re: [R] uniroot

2021-08-27 Thread Jeff Newmiller
Yes. This kind of issue is covered in any decent undergraduate course in numerical methods... it is not specific to R. It is also related to FAQ 7.31. https://en.m.wikipedia.org/wiki/Root-finding_algorithms

Re: [R] Selecting elements

2021-08-20 Thread Jeff Newmiller
Well, I don't think language is as much of a problem as your failure to compose your messages using plain text format. Your examples are all mushed together since the mailing list removes formatting. See what we see below for example. On August 20, 2021 12:27:50 PM PDT, Silvano Cesar da Costa

Re: [R] Selecting elements

2021-08-20 Thread Jeff Newmiller
Agreed. Need the rest of a complete example. On August 19, 2021 11:27:59 PM PDT, PIKAL Petr wrote: >Hallo > >I am confused, maybe others know what do you want but could you be more >specific? > >Let say you have such data >set.seed(123) >Var.1 = rep(LETTERS[1:4], 10) >Var.2 = sample(1:40,

Re: [R] Getting different results with set.seed()

2021-08-19 Thread Jeff Newmiller
When you provide an actual minimal reproducible example we will be able to help you. 2000 lines is excessive to demonstrate the problem. Based on your description, I think you are doing some computations before you set seed, and your results depend partly on the values computed prior to the

Re: [R] Package for "design graphs"

2021-08-17 Thread Jeff Newmiller
Perhaps igraph or DiagrammeR? On August 16, 2021 9:55:50 AM PDT, mad...@gmail.com wrote: >Hi, > >in our course littrature a "design graph" of two factors R and S with >associated maps s : I -> S and f : I -> S where I is some finite index >set, is a graph with factor labeles as vertices and lines

<    1   2   3   4   5   6   7   8   9   10   >