Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can I create a new data frame using exact rows from the old data frame in R Studio?

I need to select the exact rows from the old data frame and create a new one. I need to choose rows which contain paired numbers (as 11, 22, 33, 44, 55, 66, 77, 88 and 99). How can I do this?

I tried using filter:

paired1 <- filter(paired1$Var1=='22')
# Error in UseMethod("filter") : 
#  no applicable method for 'filter' applied to an object of class "logical"

And with:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

> with (paired1, sum (Freq[Var1 == '11' & '22']))
# Error in Var1 == "11" & "22" : 
#  operations are possible only for numeric, logical or complex types

>Solution :

For two digit numbers:

paired1[paired1$var1 %in5 seq(11, 99, 11),]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading