Question

I have the number of likes for each specific user in one csv file and I want to copy them into another csv file using R which has a list of users in a different order.

File 1     ------->    File 2

user  likes            user   likes
A     20               A
B     15               B
D     30               C
E     7                D
H     19               E
                       F
                       G
                       H

Thanks in advance

No correct solution

OTHER TIPS

This is easy: read in the data, reorder it using order and write it to file using write.csv.

f1 <- read.csv('file1.csv')
write.csv(f1[order(f1$user),],'file2.csv')

In the future, though, remember to show the code you've already tried so we know where you're starting from.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top