1

Teniendo un dataframe parecido a este (con 245 filas y 3 columnas):

per_site_plant_family_abundance:

   Site     Family            Abundance
   L3V      Amaranthaceae      6
   L3V      Brassicaeae        5
   L3V      Malvaceae          13
   L4F      Amaranthaceae      1
   L4F      Polygonaceae       18

Me gustaría obtener una matriz como esta:

        Amaranthaceae     Brassicaeae   Malvaceae   Polygonaceae
L3V         6                  5           13           0
L4F         1                  0            0          18

No encuentro la manera de hacerlo con esta función:

  L<-acast(per_site_plant_family_abundance,Site~Family,fill = 0 );dim(L)

Alguien me podría explicarme donde está mi fallo.

Gracias de antemano.

1 respuesta 1

1

Obtuve mi matriz usando esta función:

 prueba<-per_site_plant_family_abundance %>% 
     spread(Family,Abundance,fill = 0)

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.