make a column of numbers negative in r in r

You can make a column of numbers negative in R by multiplying the column by -1. Here is an example:

# Create a sample data frame
df <- data.frame(numbers = c(1, 2, 3, 4, 5))

# Make the numbers in the column negative
df$numbers <- df$numbers * -1

print(df)
158 chars
8 lines

In this example, we create a data frame with a column named numbers containing some numbers. Then, we multiply the numbers column by -1 to make all the numbers negative.

related categories

gistlibby LogSnag