Pregunta

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 hay solución correcta

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top