0

Hi I have a problem with

#  Place  Factor Value
#1 place1 fac1   10
#2 place1 fac2   20
#3 place1 fac3   30
#4 place1 fac5   50
#5 place2 fac1   40
#6 place2 fac2   50
#7 place2 fac3   60
#8 place2 fac4   60

I want to make this data to

#  Factor place1 place2
#1 fac1   10     40
#2 fac2   20     50
#3 fac3   30     60
#4 fac4   0      60
#5 fac5   50     0

I tried to use

read.zoo(data,index='Factor',split='Place)

but it doesn't work.

with this error message

Error in read.zoo(c, index = "SIGUN", split = "MCLASSNAME") : index has 2420 bad entries at data rows: 1 2 3 4 ...

Pragyaditya Das
  • 1,648
  • 6
  • 25
  • 44
Ray HS Jo
  • 25
  • 6
  • 2
    You could use `dcast` i.e. `reshape2::dcast(df1, Factor~Place)` or with `xtabs` i.e. `xtabs(Value~ Factor + Place, df1)` – akrun Nov 24 '17 at 06:34
  • 1
    you can also use `spread` from `tidyr` library i.e `tidyr::spread(data=A,key=Place,value=Value,fill = 0)` – Onyambu Nov 24 '17 at 06:54

0 Answers0