[R] Changing frequency values to 1 and 0

Jessica Streicher j.streicher at micromata.de
Wed Jan 16 17:26:13 CET 2013


Sorry, but i don't get the problem at all.

Could you provide a bit of y by using dput()?

Can you provide an example of how you want the data to look like after the transformation?

On 16.01.2013, at 16:42, Andrea Goijman wrote:

> Dear list,
> 
> I'm working with a large data set, where I grouped several species in one
> group (guild). Then I reshaped my data as shown below. Now, I just want to
> have "Rep" only as 1 or 0.
> 
> I'm not being able to change the values of rep>=1 to 1... tried many things
> and I'm not being successful!
> 
> 
>> melting=melt(occ.data,id.var=c("guild", "Site", "Rep", "Año"),
> measure.var="Pres")
>> y=cast(melting, Site ~ Rep ~ guild ~ Año)
> Aggregation requires fun.aggregate: length used as default
> 
>> y[1:10,,"gui4a",1:2]
> , , Año = 2003
> 
>      Rep
> Site   1 2 3 4 5
>  1021 0 0 0 0 0
>  1022 0 0 0 0 0
>  1023 0 0 0 0 0
>  1024 0 0 0 0 0
>  1025 0 0 0 0 0
>  1026 0 0 0 0 0
> *  1051 3 1 2 3 5*
> *  1052 4 3 5 2 3*
> *  1053 4 3 3 3 2*
> *  1054 1 2 1 3 0*
> 
> , , Año = 2004
> 
>      Rep
> Site   1 2 3 4 5
>  1021 2 5 5 5 4
>  1022 6 3 2 2 2
>  1023 4 1 1 2 2
>  1024 0 1 2 2 0
>  1025 0 1 0 1 0
>  1026 2 1 0 0 1
>  1051 2 1 3 1 2
>  1052 2 4 1 1 2
>  1053 2 4 2 2 1
>  1054 4 3 3 2 3
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list