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
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
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
You can use replicate() or a for (i in 1:1000){} loop to do your replications,
but you have other issues first.
1. You are sampling with replacement which makes no sense at all. Your 70%
sample will contain some observations multiple times and will use less than 70%
of the data most of the tim
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
Hi,
bg<- read.table(text="
Otu00022 Otu00029 Otu00039 Otu00042 Otu00101 Otu00105 Otu00125 Otu00131
Otu00137 Otu00155 Otu00158 Otu00172 Otu00181 Otu00185 Otu00190 Otu00209 Otu00218
Gi20Jun11 0.001217 0 0.001217 0 0.00 0 0
0 0.001217 0 0
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
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
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.
Thanks!
From: Peter Alspach-2 [via R]
[mailto:ml-node+3618799-1094957657-247...@n4.nabble.com]
Sent: Wednesday, June 22, 2011 9:27 PM
To: Bendik, Nathan
Subject: Re: Subsetting data systematically
Tena ko
Tena koe Nate
You can use the fact that R recycles. If yourData is a dataframe, then (as
examples):
yourData[c(TRUE,FALSE),] will give you every second row, starting with the
first. Similarly,
yourData[c(FALSE,TRUE,FALSE),] will give every third row, starting with the
second; and
yourData[c(
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
Here is one way:
> tmp1 <- data.frame(Species=c('setosa','virginica','versicolor'),
+ row=c(7,20,18) )
>
> tmp.iris <- iris
> tmp.iris$row <- ave(iris$Sepal.Length, iris$Species, FUN=seq_along)
>
> out.iris <- merge(tmp.iris, tmp1, by=c('Species','row'))
>
>
> out.iris
Species row Sepal.L
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
Will failed.3 have each id exactly once? Or could it have multiple lines for a
given id?
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
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
Why would you want to do this? Confidence intervals tell you about the
uncertainty of the mean of y give x, not the individual data points. It may
make more sense to use prediction intervals that tell you about individuals
rather than means, but that still means throwing away alpha% of legitim
Is this what you want?
> dat <- read.table("http://dpaste.com/88988/plain/";,
comment.char="", header = TRUE)
> names(dat)
[1] "X.ID" "VALUE" "FREQUENCY"
> subset(dat, X.ID %in% 0:2 & !duplicated(X.ID))
X.ID VALUE FREQUENCY
1 0 0.00 3
321 0.67 1
65
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
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
?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
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 <
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
Or use complete.cases
df.complete <- df[complete.cases(df),]
Simon.
On Wed, 2008-01-02 at 13:21 +1000, Ross Darnell wrote:
> You could try
>
>
> > complete.case.df <- na.omit(df)
>
>
> Ross Darnell
>
>
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> On B
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 users,
?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
45 matches
Mail list logo