I have an csv file full of time differences, some positive and some negative. I need to be able to work with each of these almost 300 variables in R (see image for an excerpt). I've tried various things but so far was unable to convert them to time values in R.
Asked
Active
Viewed 142 times
0
-
Which things have you tried? You should explain them in the question – Javier Lopez Tomas Jan 07 '20 at 15:56
-
1Welcome to Stack Overflow. Read and include features from [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), especially the part about reproducing and pasting your data. The dataset is not available for us to demonstrate with; think of using a smaller example that can be included in your question. – wibeasley Jan 07 '20 at 16:09
1 Answers
0
As I understand your question, you could use ifelse()
to create a covariate for negative vs positive values
Assuming your data set is named d
d$neg_vs_pos <- iselse(d$values<0,0,1)
Now, d$neg_vs_pos==0
for all negative values and d$neg_vs_pos==1
all positive values.
So, you can use a subset
neg_val <- subset(d,d$neg_vs_pos==0)
pos_val <- subset(d,d$neg_vs_pos==1)
However, not entirely sure what you'are asking.
Did this solve the problem?

cmirian
- 2,572
- 3
- 19
- 59