[英]How Do I Create a New Data Frame Using Rows of Equal Length Above a Certain # From Larger Data Frame in R?
[英]how can I create a new data frame using exact rows from the old data frame in R Studio?
我需要 select 舊數據框中的確切行並創建一個新的。 我需要選擇包含成對數字的行(如 11、22、33、44、55、66、77、88 和 99)。 我怎樣才能做到這一點?
我嘗試使用過濾器:
paired1 <- filter(paired1$Var1=='22')
# Error in UseMethod("filter") :
# no applicable method for 'filter' applied to an object of class "logical"
與:
> with (paired1, sum (Freq[Var1 == '11' & '22']))
# Error in Var1 == "11" & "22" :
# operations are possible only for numeric, logical or complex types
對於兩位數:
paired1[paired1$var1 %in% seq(11, 99, 11),]
我們可能會使用
subset(paired1, !nchar(sub("(\\d)\\1+", "", var1)))
-輸出
var1
4 99
5 11
7 44
8 777
9 555
paired1 <- data.frame(var1 = c(12, 13, 25, 99, 11, 42, 44, 777, 555, 3))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.