Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wordpress-firewall.php on line 245

Warning: sizeof(): Parameter must be an array or an object that implements Countable in /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wordpress-firewall.php on line 245

Warning: Cannot modify header information - headers already sent by (output started at /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wordpress-firewall.php:245) in /homepages/9/d213665487/htdocs/clickandbuilds/CoalGeology/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 62
Modifying Vectors in R – Example Code – Coal Geology and Mining: Consulting Services

Modifying Vectors in R – Example Code

In this example, we have created a vector X and later changed all values of vector x>10 = 4.

 

> x <- c(17, 14, 4, 5, 13, 12, 10)
> x[x>10]
[1] 17 14 13 12
> x
[1] 17 14 4 5 13 12 10
> x[x>10]<-4
> x
[1] 4 4 4 5 4 4 10

Leave a Comment

Your email address will not be published. Required fields are marked *