R2022
R2022

Reputation: 1

How to multiply every element of a vector individually by a single value in R

Sorry for the super basic question, am new here and to coding:

For example I have a vector: v <- c(12, 26, 77, 54) and I want to multiply each element by 100 so the output will be c(1200, 2600, 7700, 5400).

How would I go about this?

Have tried using 'prod' function and "*"

Upvotes: 0

Views: 236

Answers (1)

TarJae
TarJae

Reputation: 78907

Just multiply the whole vector by 100:

v <- c(12, 26, 77, 54) * 100
v
[1] 1200 2600 7700 5400

Upvotes: 2

Related Questions