I have some trouble while trying to get a subset of an initial dataframe as in the end it corrupts my dataframe! Here is an example of what is happening:
Let consider a dataframe :
>test=data.frame("v1"=c(1,2,3,4,-5,-3),"v2"=c(1,2,3,4,5,6))
> print(test)
v1 v2
1 1 1
2 2 2
3 3 3
4 4 4
5 -5 5
6 -3 6
Then I want to take the subset where var1 value is strictly below, let's say -2:
> subtest=test[test$v1<-2,]
> print(subtest)
v1 v2
2 2 2
> print(test)
v1 v2
1 2 1
2 2 2
3 2 3
4 2 4
5 2 5
6 2 6
Not only did the subset operation didn't work but it actually corrupt my initial database by replacing all the v1 values by 2 !