My method would be to use parse and deparse and substitute. It would iterate
over each file name and build a new list of file names with the last four
characters removed to have only the left side, and only the last four remaining
to have only the right side. Then a new dataframe would be crea
This discussion has developed in such a way that it seems a better
subject line would be "problem for the hairsplit function". :-)
cheers,
Rolf Turner
--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
A bit too fast there, Duncan... x[[c(1,2)]] is illegal.
On July 9, 2021 5:16:13 PM PDT, Duncan Murdoch wrote:
>On 09/07/2021 6:44 p.m., Bert Gunter wrote:
>> OK, I stand somewhat chastised.
>>
>> But my point still is that what you get when you "extract" depends on
>> how you define "extract." D
My mental model for the `[` vs `[[` behavior is that `[` indexes multiple
results while `[[` indexes only one item. If returning multiple items from a
list the result must be a list. For consistency, `[` always returns a list when
applied to a list. The double bracket drops the containing list.
On 09/07/2021 6:44 p.m., Bert Gunter wrote:
OK, I stand somewhat chastised.
But my point still is that what you get when you "extract" depends on
how you define "extract." Do note that ?"[" yields a help file titled
"Extract or Replace Parts of an object"; and afaics, the term "subset"
is not ex
"But it takes me a while to get familiar R."
Of course. That is true for all of us. Just keep on plugging away and
you'll get it. Probably far better than I before too long.
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (
Thanks Bert,
I'm reading some books now. But it takes me a while to get familiar R.
Best,
KaiOn Friday, July 9, 2021, 03:06:11 PM PDT, Duncan Murdoch
wrote:
On 09/07/2021 5:51 p.m., Jeff Newmiller wrote:
> "Strictly speaking", Greg is correct, Bert.
>
> https://cran.r-project.org/doc/
OK, I stand somewhat chastised.
But my point still is that what you get when you "extract" depends on
how you define "extract." Do note that ?"[" yields a help file titled
"Extract or Replace Parts of an object"; and afaics, the term "subset"
is not explicitly used as Duncan prefers. The relevant
On 09/07/2021 5:51 p.m., Jeff Newmiller wrote:
"Strictly speaking", Greg is correct, Bert.
https://cran.r-project.org/doc/manuals/r-release/R-lang.html#List-objects
Lists in R are vectors. What we colloquially refer to as "vectors" are more precisely referred to
as "atomic vectors". And withou
"Strictly speaking", Greg is correct, Bert.
https://cran.r-project.org/doc/manuals/r-release/R-lang.html#List-objects
Lists in R are vectors. What we colloquially refer to as "vectors" are more
precisely referred to as "atomic vectors". And without a doubt, this "vector"
nature of lists is a ke
"1. a column, when extracted from a data frame, *is* a vector."
Strictly speaking, this is false; it depends on exactly what is meant
by "extracted." e.g.:
> d <- data.frame(col1 = 1:3, col2 = letters[1:3])
> v1 <- d[,2] ## a vector
> v2 <- d[[2]] ## the same, i.e
> identical(v1,v2)
[1] TRUE
> v3
Kai,
> one more question, how can I know if the function is for column
> manipulations or for vector?
i still stumble around R code. but, i'd say the following (and look
forward to being corrected! :):
1. a column, when extracted from a data frame, *is* a vector.
2. maybe your question is "i
Hello all,
I have to learning R from beginning, since my group will get rid of SAS. So, my
question may not be very clear for professional R user. I always dealing with
column in data frame, not data vector.
Many thanks to Greg's example. it is very helpful.
one more question, how can I know if
I trust the escapes to do what they are designed to do. Cat the pattern to the
console if you don't.
On July 7, 2021 10:36:43 PM PDT, Greg Minshall wrote:
>> sub( "\\.[^.]*$", "", fname )
>
>fwiw, i almost always use '[.]' in preference to '.', as it
>seems to be more likely to get throu
> sub( "\\.[^.]*$", "", fname )
fwiw, i almost always use '[.]' in preference to '.', as it
seems to be more likely to get through the various levels of quoting in
different contexts.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and mo
sub( "\\.[^.]*$", "", fname )
On July 7, 2021 6:27:48 PM PDT, Kai Yang via R-help
wrote:
> Hello List,
>I have a one column data frame to store file name with extension. I
>want to create new column to keep file name only without extension.
>I tried to use strsplit("name1.csv", "\\.")[[1]] to d
On Thu, 8 Jul 2021 01:27:48 + (UTC)
Kai Yang via R-help wrote:
> Hello List,
> I have a one column data frame to store file name with extension. I
> want to create new column to keep file name only without extension. I
> tried to use strsplit("name1.csv", "\\.")[[1]] to do that, but it
> j
You would need to loop through the list to use strsplit() -- you are
confused about list structure.
Here's a simple way to do it using regex's -- **assuming that there is
only one period in your names that delineates the extension.** If this
is not true, then this **will fail**. This is vectorized
Hello,
I would suggest something like `tools::file_path_sans_ext` instead of
`strsplit` to remove the file extension. This is also vectorized, so you
won't have to use a `sapply` or `vapply` on it. I hope this helps!
On Wed, Jul 7, 2021 at 9:28 PM Kai Yang via R-help
wrote:
> Hello List,
> I
Hello List,
I have a one column data frame to store file name with extension. I want to
create new column to keep file name only without extension.
I tried to use strsplit("name1.csv", "\\.")[[1]] to do that, but it just retain
the first row only and it is a vector. how can do this for all of
20 matches
Mail list logo