Hello,
Try %in% instead of == in:
m2<-m1[m1$`Classification Description` == levels(m1$`Classification
Description`)[c(1,15,2,4],]
Hope this helps,
Rui Barradas
Às 14:57 de 29/07/2020, Engin Yılmaz escreveu:
Dear
I try to create a new subset from my dataframe.
My dataframe's name is m1.
"Classification Description" column has 15 different factors.
The following code is used creating a subset for 1 factor.
m2<-m1[m1$`Classification Description` == levels(m1$`Classification
Description`)[1],]
My aim is to create a subset with 4 different factors. For example,
levels(m1$`Classification Description`)[1]
levels(m1$`Classification Description`)[15]
levels(m1$`Classification Description`)[2]
levels(m1$`Classification Description`)[4]
I try to following code but it didnt work
m2<-m1[m1$`Classification Description` == levels(m1$`Classification
Description`)[c(1,15,2,4],]
How can I solve This Problem ?
Example from my dataframe
`Record Date` `Classification Description` `Current Month
Budget Amount`
<date> <fct>
<dbl>
1 2019-06-30 Total On-Budget and Off-Budget Results:
NA
2 2019-06-30 Off-Budget Surplus (+) or Deficit (-)
41998597035.
3 2019-06-30 Total Outlays
342428650968.
4 2019-06-30 By Other Means
51648504883.
5 2019-06-30 On-Budget Outlays
292169836521.
6 2019-06-30 Off-Budget Outlays
50258814447.
7 2019-06-30 Total Receipts
333952332514.
8 2019-06-30 On-Budget Surplus (+) or Deficit (-)
-50474915489.
9 2019-06-30 Off-Budget Receipts
92257411482
10 2019-06-30 Total On-Budget and Off-Budget Financing
8476318454
--
Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.
https://www.avast.com/antivirus
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
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.