Re: [R] Subsetting Data from a Dataframe

2019-05-24 Thread Rui Barradas
Hello, Maybe something like the following is what you want. The code first creates a logical index of columns with at least one NA or "NULL" (character string, not NULL) values. Then extracts only those columns from the dataframe. inx <- sapply(datos, function(x) any(x == "NULL" | is.na(x)))

Re: [R] Subsetting Data from a Dataframe

2019-05-24 Thread Sarah Goslee
Hi Paul, Thanks for the reproducible data. You really only need to provide enough to illustrate your question, but this works. I suspect you have a data import problem - I doubt you really want so many columns to be factors! Probably you need to specify that NULL means something specific, rather

[R] Subsetting Data from a Dataframe

2019-05-24 Thread Paul Bernal
Dear friends, Hope you are all doing well. I would like to know how to retrieve a complete dataframe (all the columns), except for the cases when one of the columns have either nulls or NAs. In this case, I´d like to retrieve all the columns but only the cases (rows) where Var5 has values differe

Re: [R] Subsetting data with svyglm

2015-02-11 Thread Anthony Damico
hi brennan, survey design objects can be subsetted with the same subset() syntax as data.frame objects, so following jeff's advice maybe you want svyglm( formula , design = subset( surveydesign , variable %in% c( 'value a' , 'value b' ) ) ) for some examples of how to construct a survey design wi

Re: [R] Subsetting data with svyglm

2015-02-11 Thread Jeff Newmiller
This seems like a fundamental misunderstanding on your part of how operators, and in particular logical expressions, work in computer languages. Consider some examples: 1+2 has a numeric answer because 1 and 2 are both numeric. 1+"a" has at the very least not a numeric answer because the values

[R] Subsetting data with svyglm

2015-02-11 Thread Brennan O'Banion
I am aware that it is possible to specify a subset with a single logical operator when constructing a model, such as: svyglm(formula, design=data, subset=variable=="value"). What I can't figure out is how to specify a subset with two or more logical operators: svyglm(formula, design=data, subset=v

Re: [R] Subsetting data for split-sample validation, then repeating 1000x

2014-08-22 Thread David L Carlson
values. hist(Out) # for a histogram of the correlation values David C From: Angela Boag [mailto:angela.b...@colorado.edu] Sent: Friday, August 22, 2014 4:01 PM To: David L Carlson Subject: Re: [R] Subsetting data for split-sample validation, then repeating 1000x Hi David, Thanks for the f

Re: [R] Subsetting data for split-sample validation, then repeating 1000x

2014-08-22 Thread David L Carlson
m: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Angela Boag Sent: Thursday, August 21, 2014 4:46 PM To: r-help@r-project.org Subject: [R] Subsetting data for split-sample validation, then repeating 1000x Hi all, I'm doing some within-dataset model valid

[R] Subsetting data for split-sample validation, then repeating 1000x

2014-08-21 Thread Angela Boag
Hi all, I'm doing some within-dataset model validation and would like to subset a dataset 70/30 and fit a model to 70% of the data (the training data), then validate it by predicting the remaining 30% (the testing data), and I would like to do this split-sample validation 1000 times and average th

[R] Subsetting data by ID with different constraints

2014-04-04 Thread Lib Gray
Hello, I have a data set with many individuals all with multiple timed observations, and I would like to subset the data to exclude later timed observations. However, I would like to exclude different amounts of data for each individual. These individuals have two types of data: DV and dose. What

Re: [R] subsetting data file by intoducing a second file

2013-02-12 Thread Eik Vettorazzi
Hi Ozgul, the interesting part is the "select" parameter in subset: subset(bg,select=c_bg[,1]) cheers Am 12.02.2013 15:29, schrieb Ozgul Inceoglu: > Hello, > > I have a very data matrix and I have a file which has the names that I need > to subset. However I cannot manage to subset the main f

Re: [R] subsetting data file by intoducing a second file

2013-02-12 Thread arun
ct.org Cc: Sent: Tuesday, February 12, 2013 9:29 AM Subject: [R] subsetting data file by intoducing a second file Hello, I have a very data matrix and I have a file which has the names that I need to subset. However I cannot manage to subset the main file. ANy idea? bg <- r

Re: [R] subsetting data file by intoducing a second file

2013-02-12 Thread Rui Barradas
Hello, Read the help page ?subset more carefully, it's argument 'select' you should be using: subset(bg, select = c_bg) Hope this helps, Rui Barradas Em 12-02-2013 14:29, Ozgul Inceoglu escreveu: Hello, I have a very data matrix and I have a file which has the names that I need to subse

[R] subsetting data file by intoducing a second file

2013-02-12 Thread Ozgul Inceoglu
Hello, I have a very data matrix and I have a file which has the names that I need to subset. However I cannot manage to subset the main file. ANy idea? bg <- read.table (file.choose(), header=T, row.names) bg Otu00022 Otu00029 Otu00039 Otu00042 Otu00101 Otu00105 Otu00125 Otu00131 Otu

Re: [R] Subsetting data leads to funky plots

2011-11-12 Thread Sarah Goslee
Hi, On Sat, Nov 12, 2011 at 2:04 AM, Vinny Moriarty wrote: > I'm trying out a basic plot, but something about the way I subset my data > leads to problems with the plot. > > > Here is the first bit of my data set > > year,date,location,quadrat_juvenile,photo_location,photo_exists,genus,count,dive

[R] Subsetting data leads to funky plots

2011-11-11 Thread Vinny Moriarty
I'm trying out a basic plot, but something about the way I subset my data leads to problems with the plot. Here is the first bit of my data set year,date,location,quadrat_juvenile,photo_location,photo_exists,genus,count,divers 2005,2005-04-30, 1 Fringing Reef,1, 1 Fringing Reef Coral Transect Po

Re: [R] Subsetting data by eliminating redundant variables

2011-10-19 Thread R. Michael Weylandt
Assuming you are talking about redun() from the Hmisc package, it's much easier than you are making it: n <- 100 x1 <- runif(n) x2 <- runif(n) x3 <- x1 + x2 + runif(n)/10 x4 <- x1 + x2 + x3 + runif(n)/10 x5 <- factor(sample(c('a','b','c'),n,replace=TRUE)) x6 <- 1*(x5=='a' | x5=='c') data1 <- data.

[R] Subsetting data by eliminating redundant variables

2011-10-19 Thread aajit75
Dear All, I am new to R, I have one question which might be easy. I have a large data with more than 250 variable, i am reducing number of variables by redun function as in the example below, n <- 100 x1 <- runif(n) x2 <- runif(n) x3 <- x1 + x2 + runif(n)/10 x4 <- x1 + x2 + x3 + runif(n)/10 x5 <

Re: [R] Subsetting data systematically

2011-06-24 Thread gibberish
idden email] [mailto:r-help-bounces@r- > project.org] On Behalf Of gibberish > Sent: Thursday, 23 June 2011 11:05 a.m. > To: [hidden email] > Subject: [R] Subsetting data systematically > > I would like to subset data from a

Re: [R] Subsetting data systematically

2011-06-22 Thread Peter Alspach
ne 2011 11:05 a.m. > To: r-help@r-project.org > Subject: [R] Subsetting data systematically > > I would like to subset data from a larger dataset and generate a > smaller > dataset. However, I don't want to use sample() because it does it > randomly. > I would like to

[R] Subsetting data systematically

2011-06-22 Thread gibberish
I would like to subset data from a larger dataset and generate a smaller dataset. However, I don't want to use sample() because it does it randomly. I would like to take non-random subsamples, for example, every 2nd number, or every 3rd number. Is there a procedure that does this? Thanks, Nate

Re: [R] Subsetting Data

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 3:38 PM, David Winsemius wrote: On Apr 28, 2011, at 3:13 PM, Abraham Mathew wrote: I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the

Re: [R] Subsetting Data

2011-04-28 Thread David Winsemius
On Apr 28, 2011, at 3:13 PM, Abraham Mathew wrote: I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the Number>=10 condition. I've done this in the past with s

Re: [R] Subsetting Data

2011-04-28 Thread Jonathan Daily
Try this: sum(dat$Number >= 10) On Thu, Apr 28, 2011 at 3:13 PM, Abraham Mathew wrote: > I'm using the subset() function in R. > > dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) > > subset(dat, Number >= 10) > > However, I want to find the number of all rows who meet the Number>=10

[R] Subsetting Data

2011-04-28 Thread Abraham Mathew
I'm using the subset() function in R. dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13)) subset(dat, Number >= 10) However, I want to find the number of all rows who meet the Number>=10 condition. I've done this in the past with something like colSums or rowSums or another similar fun

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Greg Snow
...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Linh Tran > Sent: Saturday, March 05, 2011 11:56 AM > To: r-help@r-project.org > Subject: [R] subsetting data by specified observation number > > Hi members, > > I'd like to thank you

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Linh Tran
Hi, Thank you for the reply. That would only work for the first ID. In addition, the data frame that I'm trying to subset is separate from the data frame that has the position numbers. "failed.3" is the data frame with the position numbers that I would like to keep. "def3" is the data frame that

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Greg Snow
nces@r- > project.org] On Behalf Of Linh Tran > Sent: Saturday, March 05, 2011 11:56 AM > To: r-help@r-project.org > Subject: [R] subsetting data by specified observation number > > Hi members, > > I'd like to thank you guys ahead of time for the help. I'm kind o

Re: [R] subsetting data by specified observation number

2011-03-05 Thread jdnew...@gmail.com
What is wrong with subset( failed.3, position == 2 ) ? -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Linh Tran wrote: Hi members, I'd like to thank you guys ahead of time for the help. I'm kind of stuck. I have a data frame with ID and position numbers: 1> head(faile

[R] subsetting data by specified observation number

2011-03-05 Thread Linh Tran
Hi members, I'd like to thank you guys ahead of time for the help. I'm kind of stuck. I have a data frame with ID and position numbers: 1> head(failed.3) id position 1 19972 4 1000RW_M2 15 1006RW_G2 24 1012RW_M3 28 101609172 30 1016RW_M

Re: [R] subsetting data points within confidence limit

2010-08-13 Thread Greg Snow
, 2010 11:42 AM > To: r-help@r-project.org > Subject: [R] subsetting data points within confidence limit > > Dear R-list > > > > Suppose I have a data set stored in hmet, for which I did get > confidence > limit on a linear regression as shown below. > >

[R] subsetting data points within confidence limit

2010-08-12 Thread Keun-Hyung Choi
Dear R-list Suppose I have a data set stored in hmet, for which I did get confidence limit on a linear regression as shown below. My question is how I can subset only data points which are within the confidence limit. Thank you. Keun-Hyung ---

Re: [R] Subsetting Data Frame based On Specified K Value

2009-09-03 Thread Bill.Venables
3 September 2009 4:44 PM To: r-h...@stat.math.ethz.ch Subject: [R] Subsetting Data Frame based On Specified K Value I have a data that looks like this: http://dpaste.com/88988/plain/ How can I extract/subset the data frame based on selected uniq ID. Let's say I want the first K uniq ID. I want to

[R] Subsetting Data Frame based On Specified K Value

2009-09-02 Thread Gundala Viswanath
I have a data that looks like this: http://dpaste.com/88988/plain/ How can I extract/subset the data frame based on selected uniq ID. Let's say I want the first K uniq ID. I want to be able to specify the parameter "K" here, (i.e. given K=3, we hope to extract dat$V2 = 0,1,2). I'm stuck with thi

Re: [R] subsetting data frame using a vector of column names / values

2009-06-24 Thread Blazej Krzeminski
This "one liner" works great! Thanks (for all replies) > > Try this: > > subset(d, eval(parse(text = paste(paste(columns, values, sep = "=="), > collapse = " & " > >> >> Hello >> >> I have a data frame d with columns "var1", "var2", "var3" >> >> Then I have two vectors: >> columns <- c("var2

Re: [R] subsetting data frame using a vector of column names / values

2009-06-24 Thread Henrique Dallazuanna
Try this: subset(d, eval(parse(text = paste(paste(columns, values, sep = "=="), collapse = " & " On Wed, Jun 24, 2009 at 9:16 AM, Blazej Krzeminski wrote: > Hello > > I have a data frame d with columns "var1", "var2", "var3" > > Then I have two vectors: > columns <- c("var2", "var3") > valu

[R] subsetting data frame using a vector of column names / values

2009-06-24 Thread Blazej Krzeminski
Hello I have a data frame d with columns "var1", "var2", "var3" Then I have two vectors: columns <- c("var2", "var3") values <- c(0, 1) Is there a compact way to subset the data frame using these two vectors and get the result equivalent to: select (d, var2==0 & var3==1) ? Thank You Blazej

Re: [R] Subsetting data where the condition is that the value of some column contains some substring

2009-03-20 Thread Max Bane
Aha, I get it now. I was under the mistaken, intuitive impression that the subset condition was evaluated element-by-element... I guess it must actually work out to a vector of booleans, each element of which gets compared to the corresponding element of the data to be subsetted. That is, in hindsi

Re: [R] Subsetting data where the condition is that the value of some column contains some substring

2009-03-20 Thread David Winsemius
If you use Jim's example and use grep() with ordinary and and then negative indexing, you get these results: > x[grep("her", x$input),] input output corpusFreq pvolOT pvolRatioOT 2 donate(her,thebook) P 48.7 68928 0.1899471 6give(her,it) P 100.0 1

Re: [R] Subsetting data where the condition is that the value of some column contains some substring

2009-03-20 Thread jim holtman
grep and regexpr return different values. regexpr returns a vector of the same length as the input and this can be used to construct a logical subscript. grep return a vector of only the matches, in which case you can have a length of zero if there are no matches. Makes it harder to create the s

Re: [R] Subsetting data where the condition is that the value of some column contains some substring

2009-03-20 Thread Max Bane
Thanks, Jim (and Mark, who replied off-list) -- that does the trick. I had tried using an index expression with grep, but that failed in the same way as the subset method. It is still rather mysterious why this works with regexpr but not with grep :) -Max On Fri, Mar 20, 2009 at 7:57 PM, jim holt

Re: [R] Subsetting data where the condition is that the value of some column contains some substring

2009-03-20 Thread jim holtman
Try using regexpr instead: > x <- read.table(textConnection("input output corpusFreq pvolOT pvolRatioOT + give(mysister,theoldbook) P 47.0 56016 0.1543651 + donate(her,thebook) P 48.7 68928 0.1899471 + give(mysister,thebook) P 73.4 80136 0.2208333 + donate

[R] Subsetting data where the condition is that the value of some column contains some substring

2009-03-20 Thread Max Bane
I have some data that looks like this: > dataP input output corpusFreq pvolOT pvolRatioOT 1 give(my sister, the old book) P 47.0 56016 0.1543651 5 donate(her, the book) P 48.7 68928 0.1899471 9 give(my sister

Re: [R] Subsetting data in a loop

2008-10-29 Thread hadley wickham
?split. Hadley On Wed, Oct 29, 2008 at 3:22 PM, t c <[EMAIL PROTECTED]> wrote: > I need some help with sub-setting my data. I am trying to divide a data > frame into multiple data frames based on the year collected, and stored in a > list with each new data frame labeled with "year X" where X

[R] Subsetting data in a loop

2008-10-29 Thread t c
I need some help with sub-setting my data.  I am trying to divide a data frame into multiple data frames based on the year collected, and stored in a list with each new data frame labeled with "year X" where X is the year the data was collected.  When I run my current code I get nine error messa

Re: [R] Subsetting data by date

2008-07-21 Thread Gabor Grothendieck
26 PM > To: Williams, Robin > Cc: R-help@r-project.org > Subject: Re: [R] Subsetting data by date > > Continuing on, to just get points from May to Sep > > mo <- as.numeric(format(time(z), "%m")) > z.summer <- z[mo >= 5 & mo <= 9] > > If in your case

Re: [R] Subsetting data by date

2008-07-21 Thread John Kane
?subset is one of several ways. You don't need a loop. Loops are BAD in R :) --- On Mon, 7/21/08, Williams, Robin <[EMAIL PROTECTED]> wrote: > From: Williams, Robin <[EMAIL PROTECTED]> > Subject: Re: [R] Subsetting data by date > To: "Gabor Grothendieck"

Re: [R] Subsetting data by date

2008-07-21 Thread John Kane
PM > To: Williams, Robin > Cc: R-help@r-project.org > Subject: Re: [R] Subsetting data by date > > Continuing on, to just get points from May to Sep > > mo <- as.numeric(format(time(z), "%m")) > z.summer <- z[mo >= 5 & mo <= 9] > > If in your case

Re: [R] Subsetting data by date

2008-07-21 Thread Williams, Robin
] -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Monday, July 21, 2008 3:26 PM To: Williams, Robin Cc: R-help@r-project.org Subject: Re: [R] Subsetting data by date Continuing on, to just get points from May to Sep mo <- as.numeric(format(time(z),

Re: [R] Subsetting data by date

2008-07-21 Thread Williams, Robin
Forecasting [EMAIL PROTECTED] -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Monday, July 21, 2008 3:26 PM To: Williams, Robin Cc: R-help@r-project.org Subject: Re: [R] Subsetting data by date Continuing on, to just get points from May to Sep mo <- as.nume

Re: [R] Subsetting data by date

2008-07-21 Thread Gabor Grothendieck
Continuing on, to just get points from May to Sep mo <- as.numeric(format(time(z), "%m")) z.summer <- z[mo >= 5 & mo <= 9] If in your case z is multivariate rather than univariate (as it is in our example) then it would be: z.summer <- z[mo >= 5 & mo <= 9, ] On Mon, Jul 21, 2008 at 9:55 AM, Gabo

Re: [R] Subsetting data by date

2008-07-21 Thread Gabor Grothendieck
Try this: Lines <- "Date,Temp 1-Apr-1997,50 3-Sept-2001,60" library(zoo) # function to reduce 4 char mos to 3 char convert.date <- function(x, format) as.Date(sub("(-...).-", "\\1-", x), format) # z <- read.zoo("myfile.csv", header = TRUE, sep = ",", FUN = convert.date, format = "%d-%b-%Y") z <

[R] Subsetting data by date

2008-07-21 Thread Williams, Robin
Hi all, Firstly I appologise if this question has been answered previously, however searching of the archives and the internet generally has not yielded any results. I am looking in to the effects of summer weather conditions (temperature, humidity etc), on the incidences of a breathing dis

Re: [R] subsetting data-frame by vector of characters

2008-06-13 Thread Wacek Kusnierczyk
james perkins wrote: > Thanks a lot for that. Its the %in% I needed to work out mainly > > large didn't mean anything in particular, just that it gets quite long > with the real data. > I did mean: names = c("John", "Phil", "Robert") > > The only problem is that using the method you suggest is that

Re: [R] subsetting data-frame by vector of characters

2008-06-13 Thread Peter Dalgaard
james perkins wrote: > Thanks a lot for that. Its the %in% I needed to work out mainly > > large didn't mean anything in particular, just that it gets quite long > with the real data. > I did mean: names = c("John", "Phil", "Robert") > > The only problem is that using the method you suggest is that

Re: [R] subsetting data-frame by vector of characters

2008-06-13 Thread james perkins
Thanks a lot for that. Its the %in% I needed to work out mainly large didn't mean anything in particular, just that it gets quite long with the real data. I did mean: names = c("John", "Phil", "Robert") The only problem is that using the method you suggest is that I lose the indexing, ie in t

Re: [R] subsetting data-frame by vector of characters

2008-06-13 Thread Wacek Kusnierczyk
james perkins wrote: > Hi, > > I have a very simple problem but I can't think how to solve it without > using a for loop and creating a large logical vector. However given > the nature of the problem I am sure there is a "1-liner" that could do > the same thing much more efficiently. > > bascially

Re: [R] subsetting data-frame by vector of characters

2008-06-13 Thread Chuck Cleland
On 6/13/2008 10:07 AM, james perkins wrote: Hi, I have a very simple problem but I can't think how to solve it without using a for loop and creating a large logical vector. However given the nature of the problem I am sure there is a "1-liner" that could do the same thing much more efficientl

[R] subsetting data-frame by vector of characters

2008-06-13 Thread james perkins
Hi, I have a very simple problem but I can't think how to solve it without using a for loop and creating a large logical vector. However given the nature of the problem I am sure there is a "1-liner" that could do the same thing much more efficiently. bascially I have a dataframe with charac

Re: [R] Subsetting data frame problem....

2008-01-01 Thread Simon Blomberg
PROTECTED] [mailto:[EMAIL PROTECTED] > On Behalf Of Marko Milicic > Sent: Wednesday, 2 January 2008 11:50 AM > To: r-help@r-project.org > Subject: [R] Subsetting data frame problem > > Dear R users, > > I'm new but already fascinated R user so please forgiv

Re: [R] Subsetting data frame problem....

2008-01-01 Thread Ross Darnell
You could try > complete.case.df <- na.omit(df) Ross Darnell -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Marko Milicic Sent: Wednesday, 2 January 2008 11:50 AM To: r-help@r-project.org Subject: [R] Subsetting data frame problem Dear R

Re: [R] Subsetting data frame problem....

2008-01-01 Thread jim holtman
?complete.cases On Jan 1, 2008 8:50 PM, Marko Milicic <[EMAIL PROTECTED]> wrote: > Dear R users, > > I'm new but already fascinated R user so please forgive for my > ignorance. I have the problem, I read most of help pages but couldn't > find the solution. The problem follows > > I have large

[R] Subsetting data frame problem....

2008-01-01 Thread Marko Milicic
Dear R users, I'm new but already fascinated R user so please forgive for my ignorance. I have the problem, I read most of help pages but couldn't find the solution. The problem follows I have large data set 10,000 rows and more than 100 columns... Say something like var1,var2,var2,var4.