[R-sig-eco] subsetting data in R

2011-04-24 Thread Manuel Spínola
Dear list members, I have a question regarding too subsetting a data set in R. I created an object for my data: pa = read.csv(espec_indic.csv, header = T, sep=,, check.names = F) levels(pa$influencia) [1] AID AII AP The object has 3 levels for influencia (AP, AID, AII) Now I subset only

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Christian Parker
You are creating a new object, but the columns that are stored as factors are not being 'refactored' so you are retaining the original list of levels. To fix this you can use the factor function after you subset pa2 = subset(pa, influencia==AID) pa2$influencia-as.factor(pa2$influencia) On

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Roman Luštrik
You can also use droplevels() on your new object (as of R 2.12). Cheers, Roman On Sun, Apr 24, 2011 at 3:42 PM, Christian Parker cpar...@pdx.edu wrote: You are creating a new object, but the columns that are stored as factors are not being 'refactored' so you are retaining the original list

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Sarah Goslee
By default, read.csv() turns character variables into factors, using all the unique values as the levels. subset() retains those levels by default, as they are a vital element of the data. If you are studying some attribute of men and women, say height, even if you are only looking at the heights

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Manuel Spínola
Thank you very much for your response, Christian, Roman, and Sarah. Sarah, I am trying your suggestion but I cannot see the levels: pa2 = factor(subset(pa, influencia==AP)$influencia) levels(pa2$influencia) Error in pa2$influencia : $ operator is invalid for atomic vectors Best, Manuel

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Gustavo Carvalho
pa2 - subset(pa, influencia==AP) pa2$influencia - factor(pa2$influencia) levels(pa2$influencia) On Sun, Apr 24, 2011 at 11:24 AM, Manuel Spínola mspinol...@gmail.com wrote: Thank you very much for your response, Christian, Roman, and Sarah. Sarah, I am trying your suggestion but I cannot see

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Manuel Spínola
Thank you Christian. Following your suggestion I got the following result, pa2 = subset(pa, influencia==AP) pa2$influencia-as.factor(pa2$influencia) levels(pa$influencia) [1] AID AII AP On 24/04/2011 07:42 a.m., Christian Parker wrote: You are creating a new object, but the columns that

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Manuel Spínola
Thank you very much Gustavo. That works. Manuel On 24/04/2011 08:30 a.m., Gustavo Carvalho wrote: pa2- subset(pa, influencia==AP) pa2$influencia- factor(pa2$influencia) levels(pa2$influencia) On Sun, Apr 24, 2011 at 11:24 AM, Manuel Spínolamspinol...@gmail.com wrote: Thank you very

Re: [R-sig-eco] subsetting data in R

2011-04-24 Thread Manuel Spínola
Thank you for all the responses. Is there a way to do a complete data set from an object in R? I have a data set with more than 3000 columns. The subsetting is ok but it could be dangerous if you are using other factors to do some analysis as you need to specify the levels for all your factors

Re: [R-sig-eco] Help plotting time series from multiple years?

2011-04-24 Thread Darren Norris
Hi Raphael, Not sure about lattice but the ggplot2 packge has some straight forward examples. see bottom figure on this page http://had.co.nz/ggplot2/scale_date.html plus http://had.co.nz/ggplot2/scale_datetime.html Dates need to be POSIXct ?POSIXct HTH Darren --