print(elasticband)
strech distance tension
1 67 148 5
2 98 120 10
3 34 173 15
4 50 60 20
5 45 263 25
6 42 141 30
7 89 166 35
So I have this data frame, and I want to be able to alter a single column (For example, square everything in the tension column) without affecting the others like elasticband**2
Any tips?
P.S. I'm not too good at this, so the simpler the fix the better
> transform(elasticband, tension2=tension^2)
strech distance tension tension2
1 67 148 5 25
2 98 120 10 100
3 34 173 15 225
4 50 60 20 400
5 45 263 25 625
6 42 141 30 900
7 89 166 35 1225
other alternatives are:
elasticband$tension2 <- elasticband[, "tension"]^2
Or
elasticband$tension2 <- elasticband$tension^2
If you only want a vector as output
elasticband[, "tension"]^2
Or
elasticband$tension^2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With