Displaying 20 results from an estimated 14000 matches similar to: "Subsetting dataframe"
2003 Sep 10
2
dataframe subsetting
I can create a small dataset, "x" below, and subset out rows based on
values of a certain variable. However, on the dataset I'm working on now,
"latdata" below, I get a subscript error. Any advice is appreciated!
Ryan
Successful:
> is.data.frame(x)
[1] TRUE
> x
X1 X2 X3
1 1 3 5
2 2 4 6
> x[x$X2 %in% c(3),]
X1 X2 X3
1 1 3 5
Unsuccessful:
>
2003 Aug 26
3
Subsetting a dataframe
Hi R-people
I have a question concerning subsetting. I have a dataframe which contains among other variables the variable "subject". For each subject number there are several rows, e.g.:
subject treatment concentration day
19 a 15,4 1
19 a 18,3 2
19 a 2,3 3
etc.
Im trying to subset the dataframe to get for
2012 Apr 26
2
Subsetting dataframe with missing values
Dear R-community,
I am using R (V 2.14.1) on Windows 7. I have a dataset which consists of 19
variables for 91 individuals or rows. Two of my variables are Age
(adult/chick, with no NA values) and Sex (0 for females/1 for females, with
quite a few NA values). The sex of many adult birds is unknown (entered as
NA in dataframe). At some point of my analyses, I happen to need to need to
work with
2003 Jan 22
1
dataframe subsetting behaviour
Hi,
I'm trying to understand a behaviour that I have encountered
and can't fathom.
Here's some code I will use to illustrate the behaviour:
# start with some data frame "a" having some named columns
a <- data.frame(a=rep(1,3),c=rep(2,3),d=rep(3,3),e=rep(4,3))
# create a subset of the original data frame, but include a
# name "b" that is not present in my
2013 Apr 06
1
Multiple subsetting of a dataframe based on many conditions
Hello Everybody,
I'm working with a dataframe that has 18 columns. I would like to subset the data in one of these columns, "present", according to combinations of data in six of the other columns within the data frame and then save this into a text file. The columns I would like to use to subset "present" are:
* answer (1:4) [answer takes the values 1 to 4]
*p.num
2010 Mar 24
1
flexible alternative to subsetting dataframe inside nested loops
I have a dataFrame variable:
L1 L2 L3 ... v1 v2 ...
1
2
3
4
...
I want to process subsets of it as defined by combinations of L1-L2-L3. I do
it successfully using nested loops:
for (i in valuesOfL1 {
for (j in valuesOfL2) {
for (k in valuesOfL3) {
tempData <- subset(dataFrame, (L1 == i & L2 == j & L3 == k,
select=c(v1,v2) ))
if
2010 Jun 04
1
subsetting a dataframe
Hi there,
> a<-data.frame(c(1,2,2,5,9,9),c("A","B","C","D","E","F"))
> names(a)<-c("x1","x2")
> max(table(a$x1))
[1] 2
>
The above shows the max count for x1 is 2, which is correct. But we can't tell
there are 2 groups that meet this criteria: 2,2 and 9,9.
I then want to extract the
2007 Jul 19
2
Subsetting dataframes
Dear all!
W2k, R 2.5.1
I am working with an ongoing malting barley variety evaluation within
Sweden. The structure is 25 cultivars tested each year at four sites, in
field trials with three replicates and 'lattice' structure (the replicates
are divided into five sub blocks in a structured way). As we are normally
keeping around 15 varieties from each year to the next, and take in 10 new
2013 Jan 31
2
use name (not values!) of a dataframe inside a funktion
Dear Listers,
can anyone help me, please.
Since several days i try to figure out, how to assign values, vectors,
functions etc to variables with dynamically generated names inside of
functions.
Sometimes I succeed, but the success is rather arbitrary, it seems. up to
now i don't fully understand, why things like get, assign, <<- etc do
sometimes work, and sometimes not.
here's one
2010 May 26
1
problem with not in in subseting dataframe
Hi all,
I have a problem while subsetting a dataframe that is
while I am using *%in%* condition like
*stemp<-subset(temp, obj1 %in% obj2,select=c(temp))*
this is working and giving results that what ever is there is both *obj1*and
*obj2*
**
**
but I want to get values which is there in *obj1* but not in *obj2 *
can anyone help me how to get those values.
i tried with *%o%* but i am not
2018 Mar 12
0
Dataframe Subsetting comparison
Hello All,
I am facing a unique issue and am unable to find any help in R help pages
or online. I will appreciate your help for the following problem:
I have 2 data-frames, samples below and there is an expected output
R Dataframe1:
C1 C2 C3 C4...... CN
R1 0 1 0 1
R2 1 0 1 1
R3
2010 Oct 24
1
Subsetting a dataframe
Hi,
I have a dataframe with 43 columns and a 1000 rows. Each entry in the
dataframe can be either P or A.
here is a small chunk:
c1 c2 ... c43
r100 P A ... P
r101 A A ... A
r102 P P ... P
How does one subset this data frame to select those rows that have only P's
in them?
Thanks in advance.
Anjan
--
===================================
2003 Nov 24
2
1.8.1 and subsetting dataframes
I've encountered something that didn't arise using earlier versions of
R (Linux).
A dataframe is created and new columns added to it by doing
calculations using apply with various functions on some of the
original columns. It's somewhat too involved to give a toy example
that's reproducible. However, the resulting phenemonon can be
characterised by the following:
Browse[1]>
2009 Jul 08
1
subsetting a dataframe with a string logical expression
Hi,
I am trying to subset a dataset based on a filter defined by a user...
I prompt the user for input.. resulting in a string logical expression
("X1 < 3").
I have tried using subset, but it is looking for a logical expression, not
a character string.
I keep getting the error: 'subset' must evaluate to logical.
Example:
x <- data.frame(matrix(1:15, nrow=5, ncol=3))
2003 Apr 07
4
subsetting a dataframe
How does one remove a column from a data frame when the name of
the column to remove is stored in a variable?
For Example:
colname <- "LOT"
newdf <- subset(olddf,select = - colname)
The above statement will give an error, but thats what I'm trying to
accomplish.
If I had used:
newdf <- subset(olddf,select = - LOT)
then it would have worked, but as I said the column
2007 Jul 18
2
Subsetting Enigma: More rows after dataframe[-list,]?
Hello again,
I'm trying to purge the indexes in i.delete from frame and end up with more
rows!? Please be so kind and let me know where I screw this up ...
Joh
> i.delete
[1] 40 45 165 212 253 270 280 287 301 352 421 433 463 467
487
[16] 517 537 542 573 594 596 612 614 621 635 650 696 699 707
732
[31] 738 776 826 891 892 936 937 935 940 976
2012 Jan 27
3
Subsetting for the ten highest values by group in a dataframe
Hello,
I am looking for a way to subset a data frame by choosing the top ten
maximum values from that dataframe. As well this occurs within some
factor levels.
## I've used plyr here but I'm not married to this approach
require(plyr)
## I've created a data.frame with two groups and then a id variable (y)
df <- data.frame(x=rnorm(400, mean=20), y=1:400,
2005 Aug 29
2
reexpand a matrix after subsetting
Hi,
suppose I have a matrix (or dataframe)
as a result from subsetting.
mat <- matrix(1:20,ncol=2)
mat[c(3,6,9),] <- NA
cc <- complete.cases(mat)
sub <- mat[cc,,drop=FALSE]
sub <- sub * 2
#some caluculations with sub.
now I would like to expand sub somehow
so row 3,6, and 9 would be filled with
NAs but the rest should be in place again.
Is there a simple function for this?
2004 Jan 04
0
termplot; failure to subset non-dataframe carriers (PR#6327)
termplot() does not carry subsetting over to carriers that
are in the environment but not in the data frame. This
generates a "subscript out of bounds" error.
> data(ToothGrowth)
> logdose <- log(ToothGrowth$dose)
> tooth.lm <- lm(len ~ logdose, data=ToothGrowth)
> termplot(tooth.lm) ## Works fine
> toothVC2.lm <- lm(len ~ poly(dose,2),
2006 Dec 03
1
passing an argument to a function which is also to be a dataframe column name
any suggestions on the following gratefully welcome,
I have a dataframe, which I am subsetting via labels
atpi[, creativity]
where (for example)
atpi = as.data.frame(matrix(1:50, ncol = 5, nrow = 10))
names(atpi) = c("Q1", "Q2", "Q3", "Q4", "Q5")
and
creativity = c("Q1", "Q3", "Q4")
I want to add an extra column