similar to: Removing variables from data frame with a wile card

Displaying 14 results from an estimated 14 matches similar to: "Removing variables from data frame with a wile card"

2023 Jan 14
2
Removing variables from data frame with a wile card
Thanks to all. Very helpful. Steven from iPhone > On Jan 14, 2023, at 3:08 PM, Andrew Simmons <akwsimmo at gmail.com> wrote: > > ?You'll want to use grep() or grepl(). By default, grep() uses extended > regular expressions to find matches, but you can also use perl regular > expressions and globbing (after converting to a regular expression). > For example: >
2023 Jan 14
1
Removing variables from data frame with a wile card
mydata[, -grep("^yr",colnames(mydata))] On Sat, Jan 14, 2023 at 8:57 AM Steven T. Yen <styen at ntu.edu.tw> wrote: > I have a data frame containing variables "yr3",...,"yr28". > > How do I remove them with a wild card----something similar to "del yr*" > in Windows/doc? Thank you. > > > colnames(mydata) > [1]
2023 Jan 14
1
Removing variables from data frame with a wile card
You'll want to use grep() or grepl(). By default, grep() uses extended regular expressions to find matches, but you can also use perl regular expressions and globbing (after converting to a regular expression). For example: grepl("^yr", colnames(mydata)) will tell you which 'colnames' start with "yr". If you'd rather you use globbing:
2023 Jan 14
3
Removing variables from data frame with a wile card
Steven, Just want to add a few things to what people wrote. In base R, the methods mentioned will let you make a copy of your original DF that is missing the items you are selecting that match your pattern. That is fine. For some purposes, you want to keep the original data.frame and remove a column within it. You can do that in several ways but the simplest is something where you sat the
2023 Feb 12
2
Removing variables from data frame with a wile card
x["V2"] is more efficient than using drop=FALSE, and perfectly normal syntax (data frames are lists of columns). I would ignore the naysayers, or put a comment in if you want to accelerate their uptake. As I understand it, one of the main reasons tibbles exist is because of drop=TRUE. List-slice (single-dimension) indexing works equally well with both standard and tibble types of data
2023 Jan 14
1
Removing variables from data frame with a wile card
You rang sir? library(tidyverse) xx = 1:10 yr1 = yr2 = yr3 = rnorm(10) dat1 <- data.frame(xx , yr1, yr2, y3) dat1 %>% select(!starts_with("yr")) or for something a bit more exotic as I have been trying to learn a bit about the "data.table package library(data.table) xx = 1:10 yr1 = yr2 = yr3 = rnorm(10) dat2 <- data.table(xx , yr1, yr2, yr3) dat2[, !names(dat2)
2023 Jan 14
1
Removing variables from data frame with a wile card
Hello Avi, while something like d$something <- ... may seem like you're directly modifying the data it does not actually do so. Most R objects try to be immutable, that is, the object may not change after creation. This guarantees that if you have a binding for same object the object won't change sneakily. There is a data structure that is in fact mutable which are environments. For
2023 Jan 15
2
Removing variables from data frame with a wile card
I am new to this thread. At the risk of presenting something that has been shown before, below I demonstrate how a column in a data frame can be dropped using a wild card, i.e. a column whose name starts with "th" using nothing more than base r functions and base R syntax. While additions to R such as tidyverse can be very helpful, many things that they do can be accomplished simply
2023 Jan 15
0
Removing variables from data frame with a wile card
Valentin, You are correct that R does many things largely behind the scenes that make some operations fairly efficient. >From a programming point of view, though, many people might make a data.frame and not think of it as a list of vectors of the same length that are kept that way. So if they made a copy of the original data with fewer columns, they might be tempted to think the original
2007 Mar 05
1
Matrix/dataframe indexing
Hi all, I am hoping someone can help me out with this: If I have dataframe of years and ages and the first column and first row are filled with leading values: Df<- age1 age2 age3 Yr1 1 0.4 0.16 Yr2 1.5 0 0 Yr3 0.9 0 0 Yr4 1 0 0 Yr5 1.2 0 0 Yr6 1.4 0 0 Yr7 0.8 0 0 Yr8 0.6 0 0 Yr9 1.1 0 0 Now the rest of the cells need to be filled according to the previous year and age
2006 Sep 20
1
Simulation help
I'm trying to simulate trend data over a five year period. I want different trend profiles...the simplest being a linear trend. I've been using the following code: patBdta1 <- NULL for(i in 1:100) patBdta1 <- rbind(patBdta1,c(yr1= mean(rbinom(50,1,.50)), yr2 =mean(rbinom(50,1,.51)), yr3 =mean(rbinom(50,1,.52)),
2023 Feb 13
2
Removing variables from data frame with a wile card
x[?V2?] would retain columns of x headed by V2. What I need is the opposite??I need a data grime with those columns excluded. Steven from iPhone > On Feb 13, 2023, at 9:33 AM, Rolf Turner <r.turner at auckland.ac.nz> wrote: > > ? >> On Sun, 12 Feb 2023 14:57:36 -0800 >> Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote: >> >> x["V2"]
2007 Mar 19
1
Wile: Error when executing "make" in SimplyMepis 3.4.3
Hello, I got the following error message when I executed "make". Can anyone help me on this issue? Thanks! Mike make[1]: Entering directory `/home/zheng/Desktop/wine-0.9.28/tools' make[1]: `makedep' is up to date. make[1]: Leaving directory `/home/zheng/Desktop/wine-0.9.28/tools' make[1]: Entering directory `/home/zheng/Desktop/wine-0.9.28/libs' make[2]: Entering
2008 Jun 04
1
Error Wile starting AsterFax
Hi All, I am getting following error when i start AsterFax: Please help me to solve this issue: [root at prefroam asterfax]# ./asterfax.sh log4j: Threshold ="null". log4j: Retreiving an instance of org.apache.log4j.Logger. log4j: Setting [au.com.noojee.asterfax] additivity to [false]. log4j: Level value for au.com.noojee.asterfax is [DEBUG]. log4j: