On Fri, 28 Oct 2022 16:42:41 +0100
Rui Barradas wrote:
> This behavior, partial matching of column or list members names when
> extracting with `$` is practically a FAQ.
> See the latest R-Help thread on it after the release of R 4.0
>
>
>
Dear Andrew,
Thank you for the fast reply. I forgot about strwrap. Though my problem
is slightly different.
I do have the actual vector. Of course, I could first join the strings -
but this then involves both a join and a split (done by strwrap). Maybe
its possible to avoid the join and
> strwrap(text)
[1] "What is the best way to split/cut a vector of strings into lines of"
[2] "preferred width? I have come up with a simple solution, albeit naive,"
[3] "as it involves many arithmetic divisions. I have an alternative idea"
[4] "which avoids this problem. But I may miss some
I would suggest using strwrap(), the documentation at ?strwrap has
plenty of details and examples.
For paragraphs, I would usually do something like:
strwrap(x = , width = 80, indent = 4)
On Fri, Oct 28, 2022 at 5:42 PM Leonard Mada via R-help
wrote:
>
> Dear R-Users,
>
> text = "
> What is the
Dear R-Users,
text = "
What is the best way to split/cut a vector of strings into lines of
preferred width?
I have come up with a simple solution, albeit naive, as it involves many
arithmetic divisions.
I have an alternative idea which avoids this problem.
But I may miss some existing
Thank you for the comment. I don�t like the vertical sprawl either, but I
assumed for the examples that the variable names were supposed to be very long
or were stand-ins for complicated sub-expressions. Sometimes it�s better to put
sub-expression results into temporary variables (and possibly
Às 14:52 de 28/10/2022, Sergei Ko escreveu:
Hi All,
Just noticed that R returns results for non-existent name if you have
another variable with the same beginning when you subset with $.
See the code below:
name_0 <- "ID"
name_1 <- "name"
name_2 <- "name1"
v0 <- 1:200
v1 <- c(rep(0,100),
I appreciate this thread on coding. My preference for reading is to have
complete sentences.
I can read this:
{ if (x On Behalf Of Jorgen Harmse via
R-help
Sent: Friday, October 28, 2022 10:39 AM
To: r-help@r-project.org
Subject: Re: [R] unexpected 'else' in " else"
[External Email]
Richard
Richard O'Keefe's remarks on the workings of the interpreter are correct, but
the code examples are ugly and hard to read. (On the other hand, anyone who has
used the debugger may be de-sensitised to horrible code formatting.) The use of
whitespace should if possible reflect the structure of
Does this explain it: (from ?Extract)
name
A literal character string or a name (possibly backtick quoted). For
extraction, this is normally (see under ‘Environments’) **partially
matched** to the names of the object.
-- Bert
On Fri, Oct 28, 2022 at 6:53 AM Sergei Ko wrote:
>
> Hi All,
>
>
Hi All,
Just noticed that R returns results for non-existent name if you have
another variable with the same beginning when you subset with $.
See the code below:
name_0 <- "ID"
name_1 <- "name"
name_2 <- "name1"
v0 <- 1:200
v1 <- c(rep(0,100), rep(1,100))
v2 <- c(rep(0,50), rep(1,150))
df <-
Perfect, thank you!
On Fri, Oct 28, 2022 at 11:53 AM Rui Barradas wrote:
>
> Às 10:43 de 28/10/2022, Luigi Marongiu escreveu:
> > Hello,
> > I have a data frame with a string column. All data that are neither
> > "POS" nor "NEG" should've replaced by an NA. How can I implement that
> > (even
Às 10:43 de 28/10/2022, Luigi Marongiu escreveu:
Hello,
I have a data frame with a string column. All data that are neither
"POS" nor "NEG" should've replaced by an NA. How can I implement that
(even with extra libraries)? My attempts actually wipe out POS and
NEG...
Thank you
```
df =
Hello,
I have a data frame with a string column. All data that are neither
"POS" nor "NEG" should've replaced by an NA. How can I implement that
(even with extra libraries)? My attempts actually wipe out POS and
NEG...
Thank you
```
df = data.frame(a = 1:5, b = c("", "31.35", "POS",
Hi Andrew,
thanks a lot, that fully explains it.
Sorry for the HTML text. For the record I put the original code again
below.
Best regards
Hilmar
On 27.10.22 18:34, Andrew Simmons wrote:
> $ does not evaluate its second argument, it does something like
> as.character(substitute(name)).
>
>
15 matches
Mail list logo