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)))
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.
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 <
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
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
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
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
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
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
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
...@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
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
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
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
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
, 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.
>
>
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
---
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
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
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
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
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
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
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
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
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
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
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
?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
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
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
?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"
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
]
-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),
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
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
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 <
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
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
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
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
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
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
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
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
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
?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
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.
63 matches
Mail list logo