Re: [R] Pipe operator

2023-01-03 Thread avi.e.gross
Tim, There are differences and this one can be huge. The other pipe operators let you pass the current object to a later argument instead of the first by using a period to represent where to put it. The new one has a harder albeit flexible method by creating an anonymous function. -Original

Re: [R] Pipe operator

2023-01-03 Thread avi.e.gross
John, The topic has indeed been discussed here endlessly but new people still stumble upon it. Until recently, the formal R language did not have a built-in pipe functionality. It was widely used through an assortment of packages and there are quite a few variations on the theme including differe

Re: [R] Integer division

2022-12-20 Thread avi.e.gross
Documentation specifics aside, and I am not convinced that is an issue here, there is a responsibility on programmers on how to use routines like this by testing small samples and seeing if the results match expectations. Since negative numbers were possible, that would have been part of such te

Re: [R] Amazing AI

2022-12-19 Thread avi.e.gross
Boris, What you are telling us is not particularly new or spectacular in a sense. It has often been hard to grade assignments students do when they choose an unexpected path. I had one instructor who always graded my exams (in the multiple courses I took with him) because unlike most of the sheep,

Re: [R] interval between specific characters in a string...

2022-12-03 Thread avi.e.gross
This may be a fairly dumb and often asked question about some functions like strsplit() that return a list of things, often a list of ONE thing that be another list or a vector and needs to be made into something simpler.. The examples shown below have used various methods to convert the result

Re: [R] interval between specific characters in a string...

2022-12-02 Thread avi.e.gross
Evan, there are oodles of ways to do many things in R, and mcu of what the tidyverse supplies can often be done as easily, or easier, outside it. Before presenting a solution, I need to make sure I am answering the same question or problem you intend. Here is the string you have as an example: s

Re: [R] add specific fields in for loop

2022-11-15 Thread avi.e.gross
Kai, I have read all the messages exchanged so far and what I have not yet seen is a clear explanation of what you want to do. I mean not as R code that may have mistakes, but as what your goal is. Your code below was a gigantic set of nested if statements that is not trivial to parse.

Re: [R] add specific fields in for loop

2022-11-15 Thread avi.e.gross
Kai, As Bert pointed out, it may not be clear what you want. As a GUESS, you have some arbitrary data.frame object with multiple columns and you want to do something on selected columns. Consider changing your idea to be in several stages for simplicity and then optionally later rewriting it.

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

2022-09-30 Thread avi.e.gross
Tim and others, A point to consider is that there are various algorithms in the functions used to read in formatted data into data.frame form and they vary. Some do a look-ahead of some size to determine things and if they find a column that LOOKS LIKE all integers for say the first thousand lines

Re: [R] Converting a Date variable from character to Date

2022-09-29 Thread avi.e.gross
I am not replying to the earlier request just to the part right below my message. A simple suggestion when sending people code is to add NOTHING except proper comments. Can we assume the extra asterisks are superfluous and not in your code? I mean your column is named "Period" and not "*Period"

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

2022-09-29 Thread avi.e.gross
Has anyone noticed something a tad unusual? Someone shows up and seemingly politely asks a totally open-ended question and supplies NO DETTAILS about their personal status and experience that would be needed to tell hem whether it would take various amounts of time for him to learn enough R

Re: [R] Write text file in Fortran format

2022-09-22 Thread avi.e.gross
Javad, After reading the exchanges, I conclude you are asking a somewhat different question than some of us expected and I see some have zoomed in on what you seem to want. You seem to want to make a very focused change and save the results to be as identical as what you started with. You also

Re: [R] Remove line from data file

2022-09-19 Thread avi.e.gross
David, As others have said, there are many possible answers for a vague enough question. For one-time data it is often easiest to simply change the data source as you say you did in EXCEL. Deleting the 18th row can easily be done in R and might make sense if you get daily data and decided the

Re: [R] removing non-table lines

2022-09-18 Thread avi.e.gross
Adding to what Nick said, extra lines like those described often are in some comment format like beginning with "#" or some consistent characters that can be filtered out using comment.char='#' for example in read.csv() or comment="string" in the tidyverse function read_csv(). And, of course yo

Re: [R] Getting minimum value of a column according a factor column of a dataframe

2022-08-25 Thread avi.e.gross
The requirements keep being clarified and it would have been very useful to know more in advance. To be clear. My earlier suggestion was based on JUST wanting the minimum for each unique version of Code. Then you wanted it in the original order so that was handled by carefully making that a

Re: [R] Getting minimum value of a column according a factor column of a dataframe

2022-08-25 Thread avi.e.gross
Yes, Timothy, the request was not seen by all of us as the same. Indeed if the request was to show a subset of the original data consisting of only the rows that were the minimum for each Code and also showed ties, then the solution is a tad more complex. I would then do something along the lines

Re: [R] Getting minimum value of a column according a factor column of a dataframe

2022-08-25 Thread avi.e.gross
I read all the replies and am not sure why nobody used what I see as simpler and more direct. Assuming the ORDER of the output matters, it tends to be controlled by the order of the factor called Code so I have simple code like this: --- # Load required libraries library(dplyr) # Simulate r

Re: [R] Getting minimum value of a column according a factor column of a dataframe

2022-08-24 Thread avi.e.gross
Javad, If I understood you, you want to use one of many methods to GROUP BY one column and take the minimum within each group. If your data is set up right, perhaps using factors, there are base R versions but many would also suggest using dplyr/tidyverse methods such as piping your data to group

Re: [R] Need help

2022-08-04 Thread avi.e.gross
Another exceedingly polite questioner. Cultural differences! I think we can skip discussing if we are doing well, and get to the point. To start with, I got thrown by these two lines: a=rnorm(1000, 110, 5) s = length(a) This does not relate to the difficulty, but is a sort of sloppy use as a

Re: [R] Need to insert various rows of data from a data frame after particular rows from another dataframe

2022-07-27 Thread avi.e.gross
Ranjeet, As others have said, you have not shown enough to get decent answers. What you describe sounds quite routine and is the first step many have to do when gathering data from disparate sources that were done by different people without much consideration it has to follow some specific pat

Re: [R] mice: selecting small subset of variables to impute from dataset with many variables (> 2500)

2022-07-14 Thread avi.e.gross
Tim, Your reply is reasonable if you want to read in EVERYTHING and use various nice features of the select() function in the dplyr package of the tidyverse that let you exclude a bunch of columns based on names starting or ending or containing various characters or not being of type integer and s

Re: [R] How to parse a really silly date with lubridate

2022-07-14 Thread avi.e.gross
To be clear, I take no credit for the rather extraordinary function cll shown below: mutate(Date = lubridate::dmy_hm(Date)) I would pretty much never have constructed such an interesting and rather unnecessary line of code. ALL the work is done within the parentheses: Date = lubridate::dmy_hm

Re: [R] Does the function "c" have a character limit?

2022-07-13 Thread avi.e.gross
To be clear, Everything has limits beyond which it is not expected to have to deal with. Buffers often pick a fixed size and often need complex code to keep grabbing a bigger size and copy and add more, or arrange various methods to link multiple memory areas into a growing whole, such as having

Re: [R] How to parse a really silly date with lubridate

2022-07-13 Thread avi.e.gross
Eberhard, Others have supplied ways to do this using various date management functions. But I want to add another option that may make sense if the dates are not all quite as predictable. You can use your own regular expressions in R as in most languages, that try to match each entry to one or

Re: [R] Does the function "c" have a character limit?

2022-07-13 Thread avi.e.gross
If I follow this thread, it looks clear that the problem is superficial and not really about the c() function as it is below sea level. Is this also a problem if you replace c() with max () or list() as I think it may be? Then it is more about what length the interpreter is able to handle every

<    1   2