Got it, thank you!
On Tue, 10 Aug 2021, 00:12 David Winsemius, wrote:
>
> On 8/9/21 12:22 PM, Luigi Marongiu wrote:
> > Thank you! it worked fine! The only pitfall is that `NA` became
> > ``. This is essentially the same thing anyway...
>
>
> It's not "essentially the same thing". It IS the same
On 8/9/21 12:22 PM, Luigi Marongiu wrote:
Thank you! it worked fine! The only pitfall is that `NA` became
``. This is essentially the same thing anyway...
It's not "essentially the same thing". It IS the same thing. The print
function displays those '<>' characters flanking NA's when the cl
Thank you! it worked fine! The only pitfall is that `NA` became
``. This is essentially the same thing anyway...
On Mon, Aug 9, 2021 at 5:18 PM Ivan Krylov wrote:
>
> Thanks for providing a reproducible example!
>
> On Mon, 9 Aug 2021 15:33:53 +0200
> Luigi Marongiu wrote:
>
> > df[df[['vect[2]'
Thanks for providing a reproducible example!
On Mon, 9 Aug 2021 15:33:53 +0200
Luigi Marongiu wrote:
> df[df[['vect[2]']] == 2, 'vect[2]'] <- "No"
Please don't quote R expressions that you want to evaluate. 'vect[2]'
is just a string, like 'hello world' or 'I want to create a new column
named "
You are right, vect will contain the names of the columns of the real
dataframe buyt the actual simulation of the real case is more like
this:
```
> df = data.frame(A = 1:5, B = c(1, 2, NA, 2, NA), C = c("value is blue",
> "Value is red", "empty", " value is blue", " Value is green"), D = 9:13, E
On Mon, 9 Aug 2021 13:16:02 +0200
Luigi Marongiu wrote:
> df = data.frame(VAR = ..., VAL = ...)
> vect = letters[1:5]
What is the relation between vect and the column names of the data
frame? Is it your intention to choose rows or columns using `vect`?
> df[df[['vect[2]']] == 2, 'vect[2]']
'..
Thank you but I think I got it wrong:
```
> df = data.frame(VAR = letters[1:5], VAL = c(1, 2, NA, 2, NA)); df
VAR VAL
1 a 1
2 b 2
3 c NA
4 d 2
5 e NA
> vect = letters[1:5]
> df[df[['vect[2]']] == 2, 'vect[2]'] <- "No"; df
VAR VAL vect[2]
1 a 1
2 b 2
3 c NA
On Mon, 9 Aug 2021 10:26:03 +0200
Luigi Marongiu wrote:
> vect = names(df)
> sub_df[vect[1]]
> df$column[df$column == value] <- new.value
Let's see, an equivalent expression without the $ syntax is
`df[['column']][df[['column']] == value] <- new.value`. Slightly
shorter, matrix-like syntax woul
Thank you very much, but that would make even more work due to the
duplication...
On Mon, Aug 9, 2021 at 10:53 AM Jim Lemon wrote:
>
> Hi Luigi,
> It looks to me as though you will have to copy the data frame or store
> the output in a new data frame.
>
> Jim
>
> On Mon, Aug 9, 2021 at 6:26 PM Lu
Hi Luigi,
It looks to me as though you will have to copy the data frame or store
the output in a new data frame.
Jim
On Mon, Aug 9, 2021 at 6:26 PM Luigi Marongiu wrote:
>
> Hello,
> I would like to recursively select the columns of a dataframe by
> strong the names of the dataframe in a vector
10 matches
Mail list logo