0

I'd like to create a new variable with the contents of an existing variable in R...

So far, I've tried:

 dataset2018$income2 = 
 dataset2018$income.valueOf();

However, I'm getting the following error "Error: attempt to apply non-function"

Grateful for any suggestions.

Thanks.

  • Try `dataset2018$income2 <- dataset2018$income` – Allan Cameron Feb 20 '20 at 15:42
  • 1
    What are you trying to do with `dataset2018$income.valueOf();`? That doesn't look like common R syntax. – camille Feb 20 '20 at 15:42
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 20 '20 at 15:44

1 Answers1

0

If I understand you correctly:

cars$new <- cars$speed

Or, for your example:

 dataset2018$income2 <- dataset2018$income.valueOf

The error stems from the empty brackets after the column name, which is only used for functions

Joris
  • 417
  • 4
  • 17