Re: [R] function import file csv Openair

2024-04-30 Thread Avi Gross
Unless the functionality to read in a CSV file had special functionality, it probably is simple enough to read it in using other available functions like read.csv() or others available. Many packages have functions they later remove as not really needed or if others are available. On Tue, Apr 30

Re: [R] Reading very large text files into R

2022-09-30 Thread Avi Gross
Those are valid reasons as examining data and cleaning or fixing it is a major thing to do before making an analysis or plots. Indeed, an extra column caused by something in an earlier column mat have messed up all columns to the right. My point was about replicating a problem like this may requir

Re: [R] How long does it take to learn the R programming language?

2022-09-28 Thread Avi Gross
So is the proper R answer simply Inf? On Wed, Sep 28, 2022, 5:39 PM John Kane wrote: > + 1 > > On Wed, 28 Sept 2022 at 17:36, Jim Lemon wrote: > > > Given some of the questions that are posted to this list, I am not > > sure that there is an upper bound to the estimate. > > > > Jim > > > >

Re: [R] Write text file in Fortran format

2022-09-21 Thread Avi Gross
Javad, It would help if you stopped calling it FORTRAN format. I doubt anyone cares about names as compared to what kind of structure it holds. It likely is some variant on a file commonly used in R such as one that uses tabs or whitespace. It may have lines above with headers or comments and you

Re: [R] Please guide

2022-07-10 Thread Avi Gross via R-help
Cultures differ and we can put up with it but the feedback you get is that plenty of parts of the wider world are not like Pakistan. We simply do not invent honorifics for people who we do not know for sure has earned them, and even then, many people do not want or need a title used when not in

Re: [R] is.na with lists....

2022-07-02 Thread Avi Gross via R-help
People often use sum() to count how many boolean values are true, not length). Sent from the all new AOL app for Android On Sat, Jul 2, 2022 at 2:14 PM, Andrew Simmons wrote: It's supposed to match the length. Perhaps you meant to use which(is.na())? On Sat, Jul 2, 2022, 14:04 akshay kulk

Re: [R] R for linear algebra

2022-06-25 Thread Avi Gross via R-help
to whether it really is something people should continue to use heavily if they want to do lots of work in the field.  -Original Message- From: Avi Gross via R-help Cc: r-help@r-project.org Sent: Sat, Jun 25, 2022 2:09 pm Subject: Re: [R] R for linear algebra John, I am not in any w

Re: [R] R for linear algebra

2022-06-25 Thread Avi Gross via R-help
rom: John Fox To: Avi Gross Cc: r-help@r-project.org Sent: Sat, Jun 25, 2022 1:34 pm Subject: Re: [R] R for linear algebra Dear Avi, The purpose of the matlib package is to *teach* linear algebra and related topics, not to replace or even compete with similar functionality in base R. Cons

Re: [R] R for Linear Algebra

2022-06-23 Thread Avi Gross via R-help
R is a language specially made to do many things with vectors and matrices and arrays with any reasonable number of dimensions and also has a host of functions that do things like make diagonal matrices, calculate determinants and multiply them in several ways,  invert them, get eigenvalues and

Re: [R] rbind of multiple data frames by column name, when each data frames can contain different columns

2022-06-03 Thread Avi Gross via R-help
Complexity has all kinds of costs and tradeoffs. In one sense you are doing a conceptual merge between related but not identical database tables albeit from a set of .CSV files. You do have some  conceptually direct ways using base R or packages like dplyr that  possibly do it in a more complex

Re: [R] categorizing data

2022-05-29 Thread Avi Gross via R-help
Tom, You may have a very different impression of what was asked! LOL! Unless Janet clarifies what seems a bit like a homework assignment, it seems to be a fairly simple and straightforward assignment with exactly three rows/columns and asking how to replace the variables, in a sense, by finding

Re: [R] Restoration of "rite" package of R as R-script editor or the like

2022-05-24 Thread Avi Gross via R-help
This is changing from a discussion about the rite of passage for non-programmers using the defunct "rite" editing software by a software wright who no longer writes, to talking about finding the right software for the purpose. Kidding and wordplay aside, both public and private software is not

Re: [R] Filtering an Entire Dataset based on Several Conditions

2022-05-09 Thread Avi Gross via R-help
Paul, I read through the public replies you received and clearly some of us were not too clear on what you asked. Your subject line was not helpful as my first thought was that you wanted a single column examined for two conditions, as in EITHER less than 3 standard deviations above the mean OR

Re: [R] (no subject)

2022-05-05 Thread Avi Gross via R-help
I get suspicious about patterns. A similar request from a gmail account with another username was made just a day ago on a Python mailing list asking about learning that language. That user has not responded so far to anything people replied.  Hopefully this is not yet another person getting the

Re: [R] flag records

2022-04-26 Thread Avi Gross via R-help
Lots of people here are touchy about homework and I can understand that. But sharing code and saying where you are stuck is a plus for me as compared to asking someone to do it all. So, without commenting on whether your shown code is right, assuming youhave a data.frame object sorted as describe

Re: [R] What are the pros and cons of the various R functions and methods for conducting least median of squares regression analysis?

2022-04-16 Thread Avi Gross via R-help
Kelly, I am not going to answer your question directly as I have no experience with all those packages and others. Your question is very broad as you have not told us what your criteria and needs are. For some purposes, the package to use may be one that has been around, seems to continue to be

Re: [R] Multiplying each row of data.frame by a row in another data.frame

2022-04-09 Thread Avi Gross via R-help
Within standard R, it is common to take objects that are lists (as a data.frame is) apart and apply some function and recombine them. So using my example in an earlier message, and hoping this text-mode message is readable, try something like this to multiply each column of a data.frame by the

Re: [R] Inserting missing seq number

2022-03-29 Thread Avi Gross via R-help
Jeff, There may well be such a function somewhere but I would have requested something less ambitious than a function that does exactly that. As I see it, there are many ways to do what you specifically want, but much depends on exact conditions in your data. Your example shows seq values ascend

Re: [R] Is there a Truth Table Generator in R?

2022-03-13 Thread Avi Gross via R-help
After slogging through lots of posts about a poorly defined request, I am left wondering if I missed the original sender properly explaining what THEY mean by a truth table and what it should look like. Some here seem to know (or are guessing) that the request is to make all combinations of TRUE

Re: [R] How to automatically set R to read the files from a specific location

2022-03-02 Thread Avi Gross via R-help
Just a silly  thought, Paul. If this is really for a class and the file(s) being used are small enough, you can play a game where the data is already in the R program and is simply written into a file at the start in the current directory or a designated area. If that succeeds, you can then ha

Re: [R] setting zeros for the missing interval in data

2022-02-28 Thread Avi Gross via R-help
Hi Jim, Just FYI, your reply to Eliza likely included your attachment but the copy to this list has it stripped. I suspect the world would just work better if forums like this moved from text-only email to something like groups.io that allow richer text and attachments, albeit they do make ima

Re: [R] ggplot2 with an arbitrary number of curves from geom_function + legend?

2022-02-27 Thread Avi Gross via R-help
I would reply but since ggplot was mentioned, I must abstain. ;-) I will say that you can use ggplot in a loop in some cases if you do this: p <- ggplot(...) + ... Then you can in your loop keep adding to p as in: p <- p + geom_whatever() + ... You do at some point need to make p print itself

Re: [R] tidying up

2022-02-27 Thread Avi Gross via R-help
To: Avi Gross Cc: r-help@r-project.org Sent: Sun, Feb 27, 2022 4:52 pm Subject: Re: [R] tidying up Hi Avi, I just sent in an answer to a very simple question. In many cases it seems to me that the real problem isn't apparent from the request. ektaraK appears to have almost no experience w

[R] tidying up

2022-02-27 Thread Avi Gross via R-help
This mailing list seems to steadily get messages that some see as not relevant to this forum. In particular, some see it as wrong to bring up some things here and keep reminding people of some ground rules. So I want to know, briefly, if it is reasonable to ask a person with a question or probl

[R] R WORDLE tool concepts vary

2022-02-24 Thread Avi Gross via R-help
This forum often discusses different ways of looking at a problem that result in often very different R formulations. Many may be RIGHT in a sense but some clearly have tradeoffs or work only in limited circumstances or come from some limited way of thinking. Note this message got to be a bit lo

Re: [R] [External] Funky calculations

2022-02-02 Thread Avi Gross via R-help
uot;in our face" when we used slide rules or hand-crank calculators. I still have slide rules and a Monroe "Portable" calculator -- 5 kg! It's worth bringing them out every so often and being thankful for the power and speed of modern computing, while remembering to watch for the cowpad

Re: [R] [External] Funky calculations

2022-02-01 Thread Avi Gross via R-help
match. I do care what it does in my programs, of course. My goal here was to explain to someone that the anomaly found was not really an anomaly and that careful coding may be required in these situations. -Original Message- From: Richard M. Heiberger To: Avi Gross Cc: Nathan Boeger

Re: [R] [External] Weird behaviour of order() when having multiple ties

2022-01-31 Thread Avi Gross via R-help
"=7:1))[[1]] [1] 0.6 0.5 0.3 0.2 0.1 0.1 0.2 Of course for this simple a need, definitely overkill and I would stick with base R. LOL! -Original Message- From: Ebert,Timothy Aaron To: Avi Gross ; maech...@stat.math.ethz.ch ; stefan.b.fl...@gmail.com Cc: r-help@r-project.org S

Re: [R] Row exclude

2022-01-29 Thread Avi Gross via R-help
rsecting any number of such items. Here is the full code, minus the initialization. rows.keep <- intersect(intersect(grep("[0-9]", dat1$Name, invert = TRUE), grep("[a-zA-Z]", dat1$Age, invert = TRUE)), grep("[a-zA-Z]", dat1$Weight

Re: [R] Row exclude

2022-01-29 Thread Avi Gross via R-help
There are many creative ways to solve problems and some may get you in trouble if you present them in class while even in some work situations, they may be hard for most to understand, let alone maintain and make changes. This group is amorphous enough that we have people who want "help" who are

Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed

2022-01-28 Thread Avi Gross via R-help
c(fact) - 1)[1] 0.2857143 You may get lots of advice on many methods and ways to do things but pick what fits your situation and sometimes you can try to change the situation. For some purposes, categorical data needs to be transformed for proper use in something like machine learning algorithm

Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed

2022-01-28 Thread Avi Gross via R-help
c(fact) - 1)[1] 0.2857143 You may get lots of advice on many methods and ways to do things but pick what fits your situation and sometimes you can try to change the situation. For some purposes, categorical data needs to be transformed for proper use in something like machine learning algorithm

Re: [R] Error in if (fraction <= 1) { : missing value where TRUE/FALSE needed

2022-01-27 Thread Avi Gross via R-help
Timothy, In reply to what you wrote about a benchmark suggesting some storage formats may make the code run slower, it is not a surprise, given what you chose to benchmark. You are using a test of a logical variable in a numeric context when you have code like:     log(a2+0.01) In order to do t

Re: [R] NAs are removed

2022-01-14 Thread Avi Gross via R-help
I do not know what your major problem/issue is but the code you shared seems to be looking for a character value of '2' in what looks like a numeric vector containing the number 2. -Original Message- From: Neha gupta To: Ebert,Timothy Aaron Cc: r-help mailing list Sent: Fri, Jan 14,

Re: [R] (Off-Topic) Time for a companion mailing list for R packages?

2022-01-13 Thread Avi Gross via R-help
I appreciate your thoughts and some history, Marc. My personal goal here is to both learn and if possible, be helpful. I am just bothered when one or two people regularly chime in to remind people that this forum should be pretty much only about base R. One way to satisfy them is to move some dis

Re: [R] (Off-Topic) Time for a companion mailing list for R packages?

2022-01-13 Thread Avi Gross via R-help
ginal Message- From: Kevin Thorpe To: Jeff Newmiller Cc: Avi Gross ; R Help Mailing List Sent: Thu, Jan 13, 2022 7:44 am Subject: Re: [R] (Off-Topic) Time for a companion mailing list for R packages? This is an interesting issue and something I have been thinking about raising with my f

[R] Time for a companion mailing list for R packages?

2022-01-12 Thread Avi Gross via R-help
Respectfully, this forum gets lots of questions that include non-base R components and especially packages in the tidyverse. Like it or not, the extended R language is far more useful and interesting for many people and especially those who do not wish to constantly reinvent the wheel. And repea

Re: [R] how to find the table in R studio

2022-01-12 Thread Avi Gross via R-help
The table you are looking for indeed does not any longer exists. Kai. Anything created within a function generally disappears as soon as it exits as the only pointer to it goes away and garbage collection can eventuially reuse the space. The code you wrote should end with: MyNamedVariable <- f1(

Re: [R] Method Guidance

2022-01-12 Thread Avi Gross via R-help
To be fair, Jim, when people stop and think carefully before sending a message to a forum like this, and then explain their situation and request carefully and in enough detail, often a solution comes to them and they can abort sending! Yes, the question asked is a bit vague. Other than asking fo

Re: [R] splitting data matrix into submatrices

2022-01-06 Thread Avi Gross via R-help
,] workweek <- mymat[!weekends,] Is this any better? -Original Message- From: Avi Gross via R-help To: r-help@r-project.org Sent: Wed, Jan 5, 2022 12:52 pm Subject: Re: [R] splitting data matrix into submatrices Faheem seems to reply to people in private and I replid to him in private bu

Re: [R] splitting data matrix into submatrices

2022-01-05 Thread Avi Gross via R-help
Faheem Jan To: Avi Gross Sent: Tue, Jan 4, 2022 11:44 pm Subject: Re: [R] splitting data matrix into submatrices First I will thank you for your interest and time. As my first day is Sunday, in my data matrix 24 are hourly demand of electricity. As electricity demand is different is working

Re: [R] splitting data matrix into submatrices

2022-01-04 Thread Avi Gross via R-help
If you explain better, we can help. But first consider what you are asking and how it is relected in the data. Is the first component a row number whose meaning is day 1 contains a 1 or perhaps 0 and the next row contains one more? Or is there some kind of date in there? What day of the week i

Re: [R] question about for loop

2021-12-24 Thread Avi Gross via R-help
Suggestion to consider another approach: Once various errors are fixed, the program being done basically sounds like you want to repeat a sequence of actions one per ROW of a data.frame. As it happens, the action to perform is based on a second data.frame given to ggplot, with parts dynamically in

Re: [R] Error Awareness

2021-12-24 Thread Avi Gross via R-help
. For now, I think I will step aside and focus my efforts elsewhere. -Original Message- From: Stephen H. Dawson, DSL Sent: Friday, December 24, 2021 9:49 AM To: Avi Gross ; 'r-help mailing list' Subject: Re: [R] Error Awareness Thank you, Avi. I appreciate your reply. I agre

Re: [R] Error Awareness

2021-12-23 Thread Avi Gross via R-help
Stephen, It is becoming a pattern here. You have been told R allows ways to check for errors as the code is interpreted and this DOES NOT distinguish between development aspects and in the field. It does not matter if a problem is external like a required file not being in place or having a new n

Re: [R] Adding SORT to UNIQUE

2021-12-22 Thread Avi Gross via R-help
Stephen, Why should there be a column header when you take your data and reformat it? cat(format(v1, justify = "right"), sep = "\n") The above is no longer your original data structure and has specified what you want printed. Your column header and other names associated with your original da

Re: [R] Adding SORT to UNIQUE

2021-12-22 Thread Avi Gross via R-help
Stephen, Understanding a bit better where you are coming from, I come back to how people think about things. Languages like R often focus on doing things incrementally. I don't mean the language exactly as much as many of the people using the language. So it is perfectly normal to make multipl

Re: [R] Creating NA equivalent

2021-12-21 Thread Avi Gross via R-help
way suggesting R is deficient for not being designed for things like this, nor that wanting some such feature is a bad thing. What Adrian provided is sort of in between as real NA are stored but also some attributes record what the NA is supposed to represent. -Original Message----- From: J

Re: [R] Creating NA equivalent

2021-12-21 Thread Avi Gross via R-help
I wonder if the package Adrian Dușa created might be helpful or point you along the way. It was eventually named "declared" https://cran.r-project.org/web/packages/declared/index.html With a vignette here: https://cran.r-project.org/web/packages/declared/vignettes/declared.pdf I do not know

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Avi Gross via R-help
Duncan, Let's not go there discussing the trouble with tibbles when the topic asked how to do things in more native R. The reality is that tibbles when used in the tidyverse often use somewhat different ways to select what columns you want including some very quite sophisticated ones like: se

Re: [R] Adding SORT to UNIQUE

2021-12-21 Thread Avi Gross via R-help
Stephen, Languages have their own philosophies and are often focused initially on doing specific things well. Later, they tend to accumulate additional functionality both in the base language and extensions. I am wondering if you have explained your need precisely enough to get the answers you

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Avi Gross via R-help
t will sort the numbers correctly. > > Maybe that's what you are looking for, see the example below. > > > > x <- sample(sprintf("ab%d", 1:20)) # shuffle the vector > > stringr::str_sort(x, numeric = TRUE) # sort considering the numbers

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Avi Gross via R-help
Stephen, Sorry about that. I tried modifying what you had and realize the use of [] returned a data.frame and you need [[]] to return a vector. Try this: sort(unique(Data[[1]])) From: Stephen H. Dawson, DSL Sent: Monday, December 20, 2021 12:32 PM To: Avi Gross ; r-help@r

Re: [R] Adding SORT to UNIQUE

2021-12-20 Thread Avi Gross via R-help
Stephen, You can sort using sort() either before or after doing a unique. Unique removes all duplicates in any order so sorting before may be wasteful. in your data shown below, do this: sort(unique(Data[1])) sort(unique(Data[2])) sort(unique(Data[3])) sort(unique(Data[4])) Even simpler is to de

Re: [R] Sum every n (4) observations by group

2021-12-19 Thread Avi Gross via R-help
Milu, Your data seems to be very consistent in that each value of ID has eight rows. You seem to want to just sum every four so that fits: ID Date Value 1 A 4140 0.000207232 2 A 4141 0.000240141 3 A 4142 0.000271414 4 A 4143 0.000258384 5 A 4144 0.000243640 6 A 4145 0.0002714

Re: [R] Changing time intervals in data set

2021-12-15 Thread Avi Gross via R-help
I think Rich has shared aspects of the data before and may have forgotten we want something here and now. Besides a small sample of what the relevant columns look like and a suggestion of what he wants some new column to look like, we probably need more to understand what he wants. The issue coul

Re: [R] checkpointing

2021-12-13 Thread Avi Gross via R-help
Jeff, I am wondering what it even means to do what you say. In a compiled language, I can imagine wrapping up an executable along with some kind of run-time image (which may actually contain the parts of the executable that includes what has not run yet) and revive it elsewhere. But even there, h

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

2021-12-04 Thread Avi Gross via R-help
The right answer obviously depends on the REQUIREMENTS and they may not have been fully stated. This is a bit like finding the mode of a set of numbers. The most frequent value may not be as representative of the data as the mean or even the median for some purposes, as well as other measures o

Re: [R] Question about Rfast colMins and colMaxs

2021-11-30 Thread Avi Gross via R-help
Stephen, Although what is in the STANDARD R distribution can vary several ways, in general, if you need to add a line like: library(something) or require(something) and your code does not work unless you have done that, then you can imagine it is not sort of built in to R as it starts. Having s

Re: [R] Large data and space use

2021-11-28 Thread Avi Gross via R-help
harder to do as each one does just one thing well. That may also be a plus, especially if pipelined objects are released in progress and not all at the end of the pipeline. From: Richard O'Keefe Sent: Sunday, November 28, 2021 3:54 AM To: Avi Gross Cc: R-help Mailing List Subject: R

[R] Large data and space use

2021-11-27 Thread Avi Gross via R-help
Several recent questions and answers have mad e me look at some code and I realized that some functions may not be great to use when you are dealing with very large amounts of data that may already be getting close to limits of your memory. Does the function you call to do one thing to your object

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

2021-11-20 Thread Avi Gross via R-help
This seems to be a topic that comes up periodically. The various ways in R and other packages for reading in data often come with methods that simply guess wrong or encounter one or more data items in a column that really do not fit so fields may just by default become a more common denominator of

Re: [R] the opposite of pluck() in purrr

2021-11-18 Thread Avi Gross via R-help
As noted, this is not the place to ask about dplyr but the answer you may want is perhaps straight R. If you have a list called weekdays and you know you o not want to take the fifth, then indexing with -5 removes it: > weekdays <- list("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") > weekdays[

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

2021-11-11 Thread Avi Gross via R-help
d Sent: Thursday, November 11, 2021 1:25 PM To: r-help@r-project.org Subject: Re: [R] ggplot2: multiple box plots, different tibbles/dataframes On Thu, 11 Nov 2021, Avi Gross via R-help wrote: > Say I have a data.frame with columns called PLACE and MEASURE others. > The one I call PLACE would

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

2021-11-11 Thread Avi Gross via R-help
As I replied to Rich privately for another message, I suggest that you may well be able to fit what you need in memory, if careful. But my main point is that when you have so much data, you do not need all of it to make a representative graph. A boxplot made using 100,000 data points may well have

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

2021-11-11 Thread Avi Gross via R-help
: multiple box plots, different tibbles/dataframes On Thu, 11 Nov 2021, Avi Gross wrote: > Boxplots like many other things in ggplot can be grouped in various ways. > I often do something like this: Avi, I've designed and used multiple boxplots in many projects. They might show

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

2021-11-11 Thread Avi Gross via R-help
Behalf Of Rich Shepard Sent: Thursday, November 11, 2021 8:50 AM To: r-help@r-project.org Subject: Re: [R] ggplot2: multiple box plots, different tibbles/dataframes On Wed, 10 Nov 2021, Avi Gross via R-help wrote: > I think many here may not quite have enough info to help you. Avi, Actua

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

2021-11-10 Thread Avi Gross via R-help
Rich, I think many here may not quite have enough info to help you. But the subject of multiple plots has come up. There are a slew of ways, especially in the ggplot paradigm, to make multiple smaller plots into a larger display showing them in some number of rows and columns, or other ways. Some

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

2021-11-03 Thread Avi Gross via R-help
I am not clear why Python came up on this forum. Yes, you can do all sorts of stuff in Python (or other languages) in ways similar or not to doing them in R. The topic here was reading in data from multiple CSV files and I saw no mention about whether some columns are supposed to be of type char

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

2021-11-03 Thread Avi Gross via R-help
Gabrielle, Why would you expect that to work? rbind() binds rows of internal R data structures that are some variety of data.frame with exactly the same columns in the same order into a larger object of that type. You are not providing rbind() with the names of variables holding the info but

Re: [R] Is there a hash data structure for R

2021-11-03 Thread Avi Gross via R-help
:47 AM To: r-help@r-project.org Subject: Re: [R] Is there a hash data structure for R On 03-11-2021 00:42, Avi Gross via R-help wrote: > > Finally, someone mentioned how creating a data.frame with duplicate > names for columns is not a problem as it can automagically CHANGE them >

Re: [R] Is there a hash data structure for R

2021-11-02 Thread Avi Gross via R-help
I have several things I considered about this topic. It is, in general, not possible to do some things in one language or another even if you find a bridge. Python lets you place all kinds of things into a dictionary including many static objects like tuples or even other dictionaries. What is all

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
ables: $ F: num 12 13.3 12 $ M: num 15 16.3 15 From: Bert Gunter Sent: Monday, November 1, 2021 8:50 PM To: Val Cc: Avi Gross ; r-help mailing list Subject: Re: [R] by group "A decent example was given and I see Andrew provided a base R reply that should be sufficient.

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
vot_wider(names_from = Sex, values_from = M) %>% as.data.frame %>% round(1) -Original Message- From: Val Sent: Monday, November 1, 2021 8:15 PM To: Avi Gross Cc: r-help mailing list Subject: Re: [R] by group Thank you Avi, One question, I am getting this error from thi

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
later. Good luck. -Original Message- From: Val Sent: Monday, November 1, 2021 7:44 PM To: Avi Gross Cc: r-help mailing list Subject: Re: [R] by group Thank you all! I can assure you that this is not HW. This is a sample of my large data set and I want a simple and efficient approach

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
Jim, Your code gives the output in quite a different format and as an object of class "by" that is not easily convertible to a data.frame. So, yes, it is an answer that produces the right numbers but not in the places or data structures I think they (or if it is HW ...) wanted. Trivial standard c

Re: [R] by group

2021-11-01 Thread Avi Gross via R-help
This is a fairly simple request and well covered by introductory reading material. A decent example was given and I see Andrew provided a base R reply that should be sufficient. But I do not think he realized you wanted something different so his answer is not in the format you wanted: > tapply(d

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

2021-10-29 Thread Avi Gross via R-help
Bert, R is used all over the place, sometimes not visibly. A search shows the NY times using it in 2011, 2009, ...: https://www.nytimes.com/2009/01/07/technology/business-computing/07program.h tml https://blog.revolutionanalytics.com/2011/03/how-the-new-york-times-uses-r-f or-data-visualization

Re: [R] customize the step value

2021-10-29 Thread Avi Gross via R-help
As others have replied, the customary way is to use the seq() function that takes additional arguments besides a from= and a to= such as by= to specify the step size and two others sometimes handy of length.out= and along.with= In your case seq(from=1.5, to=3.5, by=0.5) works as well as the shorte

Re: [R] R vs Numpy

2021-10-28 Thread Avi Gross via R-help
I am not sure your overall question fits into this forum but a brief internet search can find plenty of info. But in brief, R is a language in which much of what numpy does was built in from the start and many things are vectorized. Much of what the python pandas language does is also part of nati

Re: [R] how to include if conditions in dplyr filter function

2021-10-26 Thread Avi Gross via R-help
The error below was fairly clear. The R 'if" statement is not vectorized and takes a single logical argument. It is not normally used in a pipeline unless at that point the data has been reduced to a vector of length 1. I do not want to look at your code further without the data behind it but sugg

Re: [R] Need help in R

2021-10-26 Thread Avi Gross via R-help
There can be people doing homework for a course and as noted, the normal expectation is to use the resources provided including classroom instruction (or the often ZOOM or recordings) as well as textbooks. Forums like this are not a substitute and some nice people will sometimes volunteer not to d

Re: [R] cleanup/replacing a value on condition of another value

2021-10-25 Thread Avi Gross via R-help
I wonder why it is not as simple as: Call mutate on the data and have a condition that looks like: data %>% mutate(cases = ifelse(multiple_cond, NA, cases) -> output -Original Message- From: R-help On Behalf Of Dr Eberhard W Lisse Sent: Monday, October 25, 2021 11:49 AM To: r-help@r-pro

Re: [R] Does intersect preserve order?

2021-10-17 Thread Avi Gross via R-help
intersect() is a generic function so the question is which one does someone want to know if it remains in the same order? But a deeper question is what ORDER? intersect(A, B) intersect(B, A) Note the results have to be the same but not the order unless they start sorted the same way. -Orig

Re: [R] assumptions about how things are done

2021-10-11 Thread Avi Gross via R-help
e want), or it might return a+rev(b). Avi Gross correctly notes that the implementation is not what he wants, but I think that what he wants is possible only in special cases. Regards, Jorgen Harmse.  Message: 2 Date: Sat, 9 Oct 2021 15:35:55 -0400 From: "Avi Gross"

[R] assumptions about how things are done

2021-10-09 Thread Avi Gross via R-help
This is supposed to be a forum for help so general and philosophical discussions belong elsewhere, or nowhere. Having said that, I want to make a brief point. Both new and experienced people make implicit assumptions about the code they use. Often nobody looks at how the sausage is made. The re

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

2021-10-08 Thread Avi Gross via R-help
Ravi, I have no idea what motivated the people who made ifelse() but there is no reason they felt the need to program it to meet your precise need. As others have noted, it probably was built to handle simple cases well and it expects to return a result that is the same length as the input. If som

Re: [R] how to remove factors from whole dataframe?

2021-09-19 Thread Avi Gross via R-help
TE: I threw this together quickly and may well have made errors or not made it bulletproof. Feel free to point out where I am wrong or how to improve it. I also note my approach is partially based on interactions I once had with Adrian Dusa when he shared his package "declared" and he

Re: [R] how to remove factors from whole dataframe?

2021-09-19 Thread Avi Gross via R-help
Glad we have solutions BUT I note that the more abstract question is how to convert any columns that are factors to their base type and that may well NOT be character. They can be integers or doubles or complex or Boolean and maybe even raw. So undoing factorization may require using something

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

2021-09-14 Thread Avi Gross via R-help
handle them become better or at least better understood. -Original Message- From: R-help On Behalf Of Avi Gross via R-help Sent: Wednesday, September 15, 2021 1:23 AM To: R-help@r-project.org Subject: Re: [R] How to remove all rows that have a numeric in the first (or any) column You are

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

2021-09-14 Thread Avi Gross via R-help
wwise: alpha beta alphazoid betazoid > > 1 TRUE TRUE > result[[1,1]] [[1]] [1] "Last" > result[[1,2]] [[1]] [1] "Lasting" > as.data.frame(result) alphabeta alphazoid betazoid 1 Last Lasting TRUE TRUE

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

2021-09-14 Thread Avi Gross via R-help
Calling something a data.frame does not make it a data.frame. The abbreviated object shown below is a list of singletons. If it is a column in a larger object that is a data.frame, then it is a list column which is valid but can be ticklish to handle within base R but less so in the tidyverse.

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

2021-09-14 Thread Avi Gross via R-help
Calling something a data.frame does not make it a data.frame. The abbreviated object shown below is a list of singletons. If it is a column in a larger object that is a data.frame, then it is a list column which is valid but can be ticklish to handle within base R but less so in the tidyverse.

Re: [R] Need fresh eyes to see what I'm missing

2021-09-14 Thread Avi Gross via R-help
Rich, You have helped us understand and at this point, suppose we now are sure about the way missing info is supplied. What you show is not the same as the CSV sample earlier but assuming you know that "Eqp" is the one and only way they signaled bad data. One choice is to fix the original data be

Re: [R] Need fresh eyes to see what I'm missing

2021-09-14 Thread Avi Gross via R-help
Rich, I have to wonder about how your data was placed in the CSV file based on what you report. functions like read.table() (which is called by read.csv()) ultimately make guesses about what number of columns to expect and what the contents are likely to be. They may just examine the first N entr

Re: [R] Need fresh eyes to see what I'm missing

2021-09-14 Thread Avi Gross via R-help
Rich, I reproduced your problem on my re-arranging the code the mailer mangled. I tried variations like not using pipes or changing what it is grouped by and they all show your results on the abbreviated data with the error: `summarise()` has grouped output by 'year'. You can override using the

Re: [R] tidyverse: grouped summaries (with summarize) [RESOLVED]

2021-09-13 Thread Avi Gross via R-help
d thing. -Original Message- From: R-help On Behalf Of Rich Shepard Sent: Monday, September 13, 2021 7:04 PM To: r-help@r-project.org Subject: Re: [R] tidyverse: grouped summaries (with summarize) [RESOLVED] On Mon, 13 Sep 2021, Avi Gross via R-help wrote: > As Eric has pointed out, p

Re: [R] tidyverse: grouped summaries (with summArize)

2021-09-13 Thread Avi Gross via R-help
I think we wandered away into a package rather than base R, but the request seems easy enough. Just FYI, Rich, as you seem not to have incorporated the advice we gave yet about the first argument, your use of group_by() is a tad odd. disc %>% group_by(hour) %>% group_by(day) %>%

Re: [R] tidyverse: grouped summaries (with summerize)

2021-09-13 Thread Avi Gross via R-help
As Eric has pointed out, perhaps Rich is not thinking pipelined. Summarize() takes a first argument as: summarise(.data=whatever, ...) But in a pipeline, you OMIT the first argument and let the pipeline supply an argument silently. What I think summarize saw was something like: summari

Re: [R] tidyverse: grouped summaries (with summerize)

2021-09-13 Thread Avi Gross via R-help
Rich, Did I miss something? The summarise() command is telling you that you had not implicitly grouped the data and it made a guess. The canonical way is: ... %>% group_by(year, month, day, hour) %>% summarise(...) You decide which fields to group by, sometimes including others so they are in

  1   2   >