


Dear R Users,




Reshape seems to be very useful for data-manipulation, but I am struggling with
the function "cast". 

My variable-names are not being recognized by cast()



      cca<-a-cast(mma,sp~area,mean)

            Error:
Casting formula contains variables not found in molten data: "area"



      cca<-a-cast(mma,sp~"area",mean)

            Error:
Casting formula contains variables not found in molten data: "area"





it does works with "..."



      cca<-cast(mma,sp~...,mean)



I  tried many things, including
transforming my names with to.lower. 

       names(mma)<-tolower(names(mma))



What am I doing wrong?







Beneath is a more detailed outprints of the simplified scripts & results (original data.frame has more variables).




str(ma)
     'data.frame':   102860 obs. of  3 variables:
      $ sp    : Factor w/ 12 levels "Abronia","caoba",..: 3 3 3 3 3 3 3 3 3 3 ...
      $ area  : num  49786 6924 21083 27451 1984 ...
      $ dentro: Factor w/ 2 levels "dentro","fuera": 1 1 1 1 1 1 1 1 1 1 ...

mma<-melt(ma,id=c("sp","dentro"),na.rm=T)  

str(mma)
      'data.frame':   102860 obs. of  4 variables:
       $ sp      : Factor w/ 12 levels "Abronia","caoba",..: 3 3 3 3 3 3 3 3 3 3 ...
       $ dentro  : Factor w/ 2 levels "dentro","fuera": 1 1 1 1 1 1 1 1 1 1 ...
       $ variable: Factor w/ 1 level "area": 1 1 1 1 1 1 1 1 1 1 ...
       $ value   : num  49786 6924 21083 27451 1984 ...

cca<-a-cast(mma,sp~"area",mean)
      Error: Casting formula contains variables not found in molten data: "area"

cca<-cast(mma,sp~...,mean)
str(cca)
       List of 3
       $ sp         : Factor w/ 12 levels "Abronia","caoba",..: 1 2 3 4 5 6 7 8 9 10 ...
       $ dentro_area: num [1:12] 58755 26464 32139 31494 36731 ...
       $ fuera_area : num [1:12] 61836 29872 33819 36396 42831 ...
       - attr(*, "row.names")= int [1:12] 1 2 3 4 5 6 7 8 9 10 ...
       - attr(*, "idvars")= chr "sp"
       - attr(*, "rdimnames")=List of 2
       ..$ :'data.frame':    12 obs. of  1 variable:
       .. ..$ sp: Factor w/ 12 levels "Abronia","caoba",..: 1 2 3 4 5 6 7 8 9 10 ...
       ..$ :'data.frame':    2 obs. of  2 variables:
       .. ..$ dentro  : Factor w/ 2 levels "dentro","fuera": 1 2
       .. ..$ variable: Factor w/ 1 level "area": 1 1

David Douterlungne
 		 	   		  
_________________________________________________________________

 Facebook.

cial-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_2:092
	[[alternative HTML version deleted]]


