xtabs() produces a matrix with dimnames (actually a S3 class "table"
object, whchi is an array of integers -- in this case, a 2-d arrray, i.e. a
matrix). Spend some time with a basic R tutorial to learn how to index
matrices/arrays. This should be part of your basic R skill set.
Cheers,
Bert
Be
Thank you Bert and Jim,
Jim, FYI , I have an error message generated as
Error in allstates : object 'allstates' not found
Bert, it is working. However, If I want to chose to include only mos years
example, 2003,2004,2007 and continue the analysis as before. Where should
I define the years to g
... and similar to Jim's suggestion but perhaps slightly simpler (or not!):
> cross <- xtabs( Y ~ stat + year, data = tdat)
> keep <- apply(cross, 1, all)
> keep <- names(keep)[keep]
> cross[keep,]
year
stat 2003 2004 2006 2007 2009 2010
AL 38 21 20 12 16 15
NY 50 51 57
Hi Val,
This may help:
tdat$allpresent<-FALSE
for(state in allstates)
tdat$allpresent[tdat$stat == state]<-
all(allyears %in% tdat$year[tdat$stat==state])
tdat2<-tdat[tdat$allpresent,]
xtabs(Y~stat+year,tdat2)
table(tdat2$stat,tdat2$year)
Jim
On Fri, May 18, 2018 at 10:48 AM, Val wrote:
> H
Hi All,
I have a sample of data set show as below.
tdat <- read.table(textConnection("stat year Y
AL 200325
AL 200313
AL 200421
AL 200620
AL 200712
AL 200916
AL 201015
FL 200663
FL 200714
FL 200725
FL 200964
FL 200947
FL 201048
NY 200350
NY
This is very basic. Have you made **any** effort to learn R -- e.g. by
going through an R tutorial? If not, please do this before posting
further. This will save you -- and foks on this list, probably -- a
lot of grief in the long (or even short) run.
Also, if/when you do post further, post in pla
> On Jul 31, 2015, at 1:49 PM, Adam Jauregui wrote:
>
> Hello R-help,
>
> I am trying to compute the mean of a quarterback's career fantasy football
> stats, but I wish to exclude his 2014 stats from the mean, as that will be
> the test data for the model I am trying to build for my academic un
Hi Adam,
Possibly subset() or & would be helpful. Or even aggregate(),
depending on your ultimate goal.
Without a reproducible example that includes some sample data provided
using dput() (fake is fine), the code you used, and some clear idea of
what output you expect, it's impossible to figure o
Hello R-help,
I am trying to compute the mean of a quarterback's career fantasy football
stats, but I wish to exclude his 2014 stats from the mean, as that will be
the test data for the model I am trying to build for my academic undergrad
research.
The code for figuring out the mean of his Yds fo
Three responses to your question
1. Missing values in R are denoted by "NA". When reading in your data you want to use
the "na.strings" option so that the internal form of the data has missing values properly
denoted.
2. If this is done, then coxme will notice the missings and remove them
Hi all,
I have a data set like this:
Test.cox file:
V1V2 V3Survival Event
ann 13 WTHomo 41
ben 20 *51
tom 40 Variant 61
w
Hi,
If the column is "numeric" class, you don't need as.numeric(as.character(...)).
My response was based on your original post
"
I am analyzing two columns (both are factors):"
Using the same example,
indx1 <- with(dat1,year <=2007 |year >2012)
Warning messages:
1: In Ops.factor(year, 2007) :
Hi,
May be this helps:
set.seed(49)
dat1 <- data.frame(group=factor(sample(4,20,replace=TRUE)),
year=factor(sample(2003:2014,20,replace=TRUE)))
indx <- with(dat1, as.numeric(as.character(year)) <=2007 |
as.numeric(as.character(year)) >2012 )
with(dat1[!indx,],chisq.test(group,year))
A.K.
I
Hi,
Try:
##Assuming X and Y are matrices (as stated)
Y[!Y %in% X,,drop=FALSE]
# numberall
#[1,] "gen3"
#[2,] "gen4"
#[3,] "genx4"
A.K.
I would like to exclude entire lines in matrix "Y" based in 2 collumns in
matrix "X":
Matrix "X":
number1 number2
gen1 genx1
On Jul 5, 2012, at 1:34 PM, David Winsemius wrote:
On Jul 5, 2012, at 1:25 PM, Eiko Fried wrote:
Hello,
I have many hundred variables in my longitudinal dataset and lots of
missings. In order to plot data I need to remove missings.
If I do
data <- na.omit(data)
that will reduce my datase
4 16.59528 0.5981594 NA
A.K.
- Original Message -
From: Eiko Fried
To: r-help@r-project.org
Cc:
Sent: Thursday, July 5, 2012 1:25 PM
Subject: [R] Exclude missing values on only 1 variable
Hello,
I have many hundred variables in my longitudinal dataset and lots of
missings. In or
Be careful!! The plots could be potentially misleading. The problem is the
nature of the missingness. The approach you are taking is based on assuming
MCAR missingness (look it up, if necessary). If that is not the case --
e.g. if there is censoring, MAR, or informative missingness -- the plots
may
On Jul 5, 2012, at 1:25 PM, Eiko Fried wrote:
Hello,
I have many hundred variables in my longitudinal dataset and lots of
missings. In order to plot data I need to remove missings.
If I do
data <- na.omit(data)
that will reduce my dataset to 2% of its original size ;)
So I only need to lis
Hello,
I have many hundred variables in my longitudinal dataset and lots of
missings. In order to plot data I need to remove missings.
If I do
> data <- na.omit(data)
that will reduce my dataset to 2% of its original size ;)
So I only need to listwise delete missings on 3 variables (the ones I a
May 23, 2012 7:45 PM
> To: r-help@r-project.org
> Subject: [R] Exclude when sd=0
>
> How do I trim a matrix to exclude columns that have no standard
> deviation?
>
> Thanks,
>
> Chris
>
> [[alternative HTML version deleted]]
>
> _
Perhaps this?
X[, apply(X, 2, sd) < 1e-10]
HTH,
Jorge.-
On Wed, May 23, 2012 at 8:44 PM, Chris Burns <> wrote:
> How do I trim a matrix to exclude columns that have no standard deviation?
>
> Thanks,
>
> Chris
>
>[[alternative HTML version deleted]]
>
>
On May 23, 2012, at 8:44 PM, Chris Burns wrote:
How do I trim a matrix to exclude columns that have no standard
deviation?
mtx[ , as.logical(apply(mtx, 2, sd))]
--
David Winsemius, MD
West Hartford, CT
__
R-help@r-project.org mailing list
ht
How do I trim a matrix to exclude columns that have no standard deviation?
Thanks,
Chris
[[alternative HTML version deleted]]
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide ht
Or, for this specific application
rowSums(XXX, na.rm = TRUE)
Michael
On Thu, Nov 17, 2011 at 5:51 AM, Jim Holtman wrote:
> change to
>
>> row.sums.m <- apply(dummy.curr.res.m,1,sum, na.rm = TRUE)
>
> Sent from my iPad
>
> On Nov 17, 2011, at 5:18, Vikram Bahure wrote:
>
>> Dear R users,
>>
>>
change to
> row.sums.m <- apply(dummy.curr.res.m,1,sum, na.rm = TRUE)
Sent from my iPad
On Nov 17, 2011, at 5:18, Vikram Bahure wrote:
> Dear R users,
>
> I am new to R and have some query.
>
> I am having a dataset with binary output 0's and ones. But along with it it
> has NA's too. I want
Dear R users,
I am new to R and have some query.
I am having a dataset with binary output 0's and ones. But along with it it
has NA's too. I want to sum all the rows and get the sum total for each
column.
But whenever there is a NA in an row the sum of the row is returned as NA
so I am not able
elp-boun...@r-project.org] On
> Behalf Of Samir Benzerfa
> Sent: Wednesday, October 12, 2011 8:35 AM
> To: r-help@r-project.org
> Subject: [R] exclude columns with at least three consecutive zeros
>
> Hi everyone,
>
>
>
> I have a large data set with about 3'0
Hi everyone,
I have a large data set with about 3'000 columns and I would like to exclude
all columns which include three or more consecutive zeros (see below
example). A further issue is that it should just jump NA values if any. How
can I do this?
In the below example R should exclude col
If you know the names will always work (i.e., names of y are always names of
x and the rows always have names) this should do it:
x[!(rownames(x) %in% rownames(y)),]
I.e., those rows of x such that their names are NOT included in the row
names of y.
Hope this helps,
Michael Weylandt
On Sat, Au
Dear List,
I am a beginner of R and have an easy question, which I couldnt find out.
I like to exclude all rows of matrix y from matrix x (like a subset of
x, without y).
The matrix x is of the structure
>str(x)
num [1:346, 1:8] 0.055 0.6833 0.9121 0.0819 0.1223 ...
- attr(*
That worked.
Thanks a lot David - I appreciate it.
Paul
--
View this message in context:
http://n4.nabble.com/Exclude-data-using-logical-tp1689992p1690090.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing
On Mar 24, 2010, at 7:46 PM, pgseye wrote:
Hi,
I'm wanting to exclude data more than 2 sd's from the mean before
proceeding
with further analyses. I've created new logical variables (a and b)
and
written them to the existing dataframe. I want to be able to subset
the TRUE
observations
Hi,
I'm wanting to exclude data more than 2 sd's from the mean before proceeding
with further analyses. I've created new logical variables (a and b) and
written them to the existing dataframe. I want to be able to subset the TRUE
observations based on another 2 factor variable. I'm assuming this
On Tue, Oct 27, 2009 at 12:07 PM, Dieter Menne
wrote:
>
>
>
> Joel Fürstenberg-Hägg wrote:
>>
>>
>>
>> Now I'm trying to make xyplots to compare the result from three different
>> categories:
>>
>> # Plot Pro against Glc for each of the three categories
>> xyplot(Pro ~ Glc | Categories_BBCH_I
Joel Fürstenberg-Hägg wrote:
>
>
>
> Now I'm trying to make xyplots to compare the result from three different
> categories:
>
> # Plot Pro against Glc for each of the three categories
> xyplot(Pro ~ Glc | Categories_BBCH_ID, data=fieldTrial0809, pch="°",
> layout=c(1, 3), aspect=1, inde
Hi all,
I'm searching for a way to exclude outliers from my dataset while making
xyplots. While plotting using pairs(), I exclude specific row in my data frame
and save the settings as a variable which I later include as an argument:
# Discard outliers and save settings as idx
idx=with(fieldTr
Perhaps subset the data first?
subset(x, x[,2] >=0)
--- On Mon, 10/26/09, e-letter wrote:
> From: e-letter
> Subject: [R] exclude data for boxplot stats using mathematical operator
> To: r-help@r-project.org
> Received: Monday, October 26, 2009, 3:25 AM
> Readers,
>
&
Try this:
boxplot.stats(x[x[,2]>0,2],do.conf=FALSE)
HTH,
Stephan
e-letter schrieb:
Readers,
I have a data set as follows:
1,1
2,2
3,3
4,4
5,3
6,2
7,-10
8,-9
9,-3
10,2
11,3
12,4
13,5
14,4
15,3
16,2
17,1
I entered this data set using the command 'read.csv'. I want to
exclude values fewer than
Readers,
I have a data set as follows:
1,1
2,2
3,3
4,4
5,3
6,2
7,-10
8,-9
9,-3
10,2
11,3
12,4
13,5
14,4
15,3
16,2
17,1
I entered this data set using the command 'read.csv'. I want to
exclude values fewer than zero in column 2 so then I tried the
following command:
boxplot.stats(x[>0,2],do.conf=
Thank you it worked well
--
View this message in context:
http://www.nabble.com/Exclude-0-values-from-plot-tp25235290p25244045.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org mailing list
https://stat.ethz.ch/ma
test[test==0]<-NA
see previous post:
http://www.nabble.com/Replacing-0s-with-NA-td23995885.html#a23996183
swertie wrote:
>
> Hello, I have a matrix of species abundance with a lot of 0 values. I
> would like to plot the species abundance vs date, but I don't want that
> the 0 values appear
Hello, I have a matrix of species abundance with a lot of 0 values. I would
like to plot the species abundance vs date, but I don't want that the 0
values appear as points on my graph. Do you know how I could represent only
non-0 values? Thank you very much
--
View this message in context:
http:
Try this:
setdiff(pop, sample(pop, 2))
On Mon, Dec 1, 2008 at 5:16 PM, Hamid Hamid <[EMAIL PROTECTED]> wrote:
> Dear All,
> I am trying to build a program which will take repeated samples (w/o
> replacement) from a population of values. The interesting catch is that I
> would like the sample va
uot; "Z" "I"
>
Now each column is a sample, us apply or a for loop to work on each one.
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111
> -Original Message-
> From: [EMAIL
Dear Hamid,
Try this:
> pop<-c(1,5,14,7,9,12,18,19,65,54)
> pop
[1] 1 5 14 7 9 12 18 19 65 54
> spop<-sample(pop,2)
> spop
[1] 14 19
> newpop=pop[!pop%in%spop]
> newpop
[1] 1 5 7 9 12 18 65 54
See ?"%in%"" for more information.
HTH,
Jorge
On Mon, Dec 1, 2008 at 2:16 PM, Hamid Hamid
Dear All,
I am trying to build a program which will take repeated samples (w/o
replacement) from a population of values. The interesting catch is that I
would like the sample values to be removed from the population, after each
sample is taken.
For example:
pop<-c(1,5,14,7,9,12,18,19,65,54)
sa
Gabor Grothendieck wrote:
There are the timeDate and timeSeries packages with very powerful
possibilities to handle weekdays, weekends and public holidays for the
G7 countries and CH. You can create your own holiday calenders for many
countries including fix and moveable holidays.
Note, this
chron has some facilities for this that also work with "Date" class:
library(chron)
startDate <- as.Date("2008-08-15")
endDate <- as.Date("2008-09-15")
AllDays <- seq(startDate, endDate, by="day")
Holidays <- as.chron(as.Date("2008-09-01"))
is.workday <- !is.holiday(AllDays, Holidays) & !is.weeken
On Wed, Nov 19, 2008 at 12:54 PM, Brigid Mooney <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I am iterating through dated materials, with variable start and end dates,
> and would like to skip procedures everytime I encounter a weekend or
> holiday. To do this, I thought the easiest way would be to cr
Hi All,
I am iterating through dated materials, with variable start and end dates,
and would like to skip procedures everytime I encounter a weekend or
holiday. To do this, I thought the easiest way would be to create a
TRUE/FALSE vector corresponding to each day where it is TRUE if a workday,
an
On Tue, Oct 21, 2008 at 03:52:05PM +0200, Jim Gustafsson wrote:
> I have the following type of table (with number of rows = 4765) and want
> to exclude each row where Net=0. Could this be done in a simple way?
subset(A, Net!=0)
or
A[A$Net!=0, ]
See manual, section 2.7
cu
Philipp
--
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jim Gustafsson
Sent: Tuesday, October 21, 2008 6:52 AM
To: [EMAIL PROTECTED]
Subject: [R] Exclude rows in table
Dear R-Help,
I have the following type of table (with number of rows = 4765) and want
to
Tena koe Jim
A[A[,'Net']!=0,]
or
A[!A[,'Net']%in%0,]
Peter Alspach
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Jim Gustafsson
> Sent: Wednesday, 22 October 2008 2:52 a.m.
> To: [EMAIL PROTECTED]
&
Dear R-Help,
I have the following type of table (with number of rows = 4765) and want
to exclude each row where Net=0. Could this be done in a simple way?
Thanks in advance
Jim
> A
Business.Unit Event1 Net Date
1General Fraud 170.000 2006-01-01
2Gen
54 matches
Mail list logo