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
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
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
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,
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
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
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.
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.
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
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"
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
101 - 125 of 125 matches
Mail list logo