[R] Subset problem

Petr PIKAL petr.pikal at precheza.cz
Wed Mar 7 12:01:08 CET 2012


Hi

> 
> Good Morning
> 
>     I have a small question regarding the function subset.
> I am copying data from one table but I just want to collect data from a
> user.
> When do I take the view, presents the results I want.
> 
> The problem arises when can I make the tab. for RES_ID, introduces me to
> zero results do not envision noVIEW
> 

You did not provide reproducible example nor structure of you data. From 
what you explain I think that problem can be in factors behaviour. Factors 
retain all levels until they are explicitly told to drop them.

See
?factor

Also your output from table is rather strange.
Maybe

table(factor(x.sub$RES_ID))

can help you. Without reproducible example it is difficult to evaluate 
your problem correctly.

Regards
Petr

> 
>  val_user='16'
>   x.sub <- data.frame(subset(Dataset,Dataset$USER==val_user))
>   View(x.sub)
> lev_ID<-levels(x.sub$RES_ID)
>   res<-table(x.sub$RES_ID)
>   res
> E000- 0
> F160- 0
> XFRT- 33
> XVVR- 0
> SWEX- 23
> SWRS- 0
> 
> just wanted to see the data with values ​​greater than 0 in the 
example only
> two results
> 
> because when create the graph create empty space
>  barplot(table(x.sub$RES_ID),width =1,angle=45,inside = TRUE, plot = 
TRUE,
> axis.lty = 0, offset = 0,add = FALSE, main="hist
> C",col=rainbow(x.sub$CALLEDSTATIONID))
> 
>   Thanks
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Subset-
> problem-tp4452837p4452837.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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