Displaying 20 results from an estimated 10000 matches similar to: "Keep rows where a variable matches one item of a vector"
2009 Dec 13
2
Reshape a data set
I am trying to reshape a data set. Could someone please help me with the
reshape, cast, and melt functions? I am new to R and I have tried reading
up on how to use the reshape package, but I am very confused. Here is an
example of what I am trying to do:
subject coder score time
[1,] 1 1 20 5
[2,] 1 2 30 4
[3,] 2 3 10 10
[4,] 2 2
2010 Mar 06
2
Plot interaction in multilevel model
I am trying to plot an interaction in a multilevel model. Here is some
sample data. In the following example, it is longitudinal (i.e., repeated
measures), so the outcome, score (at each of the three time points), is
nested within the individual. I am interested in the interaction between
gender and happiness predicting score.
id <- c(1,1,1,2,2,2,3,3,3)
age <-
2011 Sep 07
1
Reshaping data from wide to tall format for multilevel modeling
Hi,
I'm trying to reshape my data set from wide to tall format for multilevel
modeling. Unfortunately, the function I typically use (make.univ from the
multilevel package) does not appear to work with unbalanced data frames,
which is what I'm dealing with.
Below is an example of the columns of a data frame similar to what I'm
working with:
ID a1 a2 a4 b2 b3 b4 b5 b6
Below
2011 Sep 03
2
Change properties of line summary in interaction.plot
Is it possible to change the color/thickness of the summary line in an
interaction.plot without changing the other individual data lines? I would
like to make the line from the summary function (mean) the color red and
thicker than the surrounding black lines. How can I do that?
Here is a link to interaction.plot:
http://stat.ethz.ch/R-manual/R-patched/library/stats/html/interaction.plot.html
2012 Sep 26
1
Interaction scatterplots in ggplot with multiple regression lines
I'm trying to treat a continuous variable as discrete for plotting
multiple regression lines in a scatterplot as a function of the level
on the moderating variable. In the example below, there is only one
regression line plotted to the whole data. I would like a separate
regression line for each discrete level of the moderator. The
moderator is continuous, so I'd like to treat it as
2011 Jun 30
1
Match strings across two differently sized dataframes and copy corresponding row to dataframe
Hello-
Sorry, this is a bit of a noob question, but I can't seem to progress
it any further.
I have two dataframes which contain a series of strings which exactly
match. The problem is one has more rows than the other (more cases
have been added) and they have been sorted so that they are not in the
same order. The smaller dataframe, though, contains in another column
which has codes
2010 Apr 03
1
"moving product", by rows, of a dataframe?
What is a "good" way to calculate the "moving product", for each row of a dataframe, where I wish to be able to specify the length of the moving product? Depending on my needs, I'd like to be able to specify the "length" over which to calculate the moving average (in this example, length=3).
For example, if I have a dataframe with 20 rows and 6 columns, and I
2010 Apr 05
2
find the "next non-NA" value within each row of a data-frame
#I wish to find the "next non-NA" value within each row of a data-frame.
#e.g. I have a data frame mydata. Rows 1, 2 & 3 have soem NA values.
mydata <- data.frame(matrix(seq(20*6), 20, 6))
mydata[1,3:5] <- NA
mydata[2,2:3] <- NA
mydata[2,5] <- NA
mydata[3,6] <- NA
mydata[1:3,]
#this loop accomplishes the task; I am tryign toi learn a "better" way
for(i
2013 Dec 07
1
How to perform clustering without removing rows where NA is present in R
I have a data which contain some NA value in their elements.
What I want to do is to **perform clustering without removing rows**
where the NA is present.
I understand that `gower` distance measure in `daisy` allow such situation.
But why my code below doesn't work?
__BEGIN__
# plot heat map with dendogram together.
library("gplots")
library("cluster")
2011 Aug 08
3
Distance between a vector and matrix rows
I am trying to find the distance between a vector and each row of a
dataframe. I am using the function "distancevector" in the package "hopach"
as follows:
mydata<-as.data.frame(matrix(c(1,1,1,1,0,1,1,1,1,0),nrow=2))
V1 V2 V3 V4 V5
1 1 1 0 1 1
2 1 1 1 1 0
vec <- c(1,1,1,1,1)
d2<-distancevector(mydata,vec,d="euclid")
The Euclidean distance
2011 Oct 24
1
How to delete rows using conditions on all columns
n <- 10
P1 <- runif(n)
P2 <- runif(n)
P3 <- P1 + P2 + runif(n)/100
P4 <- P1 + P2 + P3 + runif(n)/100
mydata <- data.frame(cbind(P1,P2,P3,P4))
mydata[1,1] <- 8
mydata[3,1] <- -5
mydata[2,3] <- -6
mydata[7,3] <- 7
f=function(z){quantile(z, c(0.01, 0.99)) }
temp1 <- lapply(mydata, f)
temp1
$P1
1% 99%
-4.542391 7.354209
$P2
1% 99%
2011 Apr 04
2
merging 2 frames while keeping all the entries from the "reference" frame
Hello!
I have my data frame "mydata" (below) and data frame "reference" -
that contains all the dates I would like to be present in the final
data frame.
I am trying to merge them so that the the result data frame contains
all 8 dates in both subgroups (i.e., Group1 should have 8 rows and
Group2 too). But when I merge it it's not coming out this way. Any
hint would be
2010 Oct 20
4
How to select not continous rows?
Hello
How can I select several not continuous rows ?
If I wanted to select rows 1 to 7 I'll write
mydata[,1:7]
But what if I need to select rows 1 to 5 and 10 to 15?
--
View this message in context: http://r.789695.n4.nabble.com/How-to-select-not-continous-rows-tp3003840p3003840.html
Sent from the R help mailing list archive at Nabble.com.
2011 Aug 24
2
data manipulation and summaries with few million rows
I have a data set with about 6 million rows and 50 columns. It is a
mixture of dates, factors, and numerics.
What I am trying to accomplish can be seen with the following
simplified data, which is given as dput output below.
> head(myData)
mydate gender mygroup id
1 2012-03-25 F A 1
2 2005-05-23 F B 2
3 2005-09-08 F B 2
4 2005-12-07 F B 2
2012 Jan 04
1
Merging and subsetting with row names XXXX
Hello everyone,
I have two questions:
1)
I want to create a subset of a data frame column-wise and simultaneously
extract the row names into a "proper" variable. I tried this, but received
an error:
> myleft<-mydata[c(id=row.names(mydata),"workshop","gender","q1","q2")]
Error in `[.data.frame`(mydata, c(id = row.names(mydata),
2012 May 25
1
Correlograms: using boxes and different variables on rows and columns
I'm trying to make correlograms using corrgram. See below for a simple
example.
####
library(corrgram)
data(baseball)
vars1 <- c("Assists","Atbat","Errors","Hits","Homer","logSal")
vars2 <- c("Putouts","RBI","Runs","Walks","Years")
2010 Aug 10
1
partial match of one column in data frame to another character vector
Here is some data (dput output below)
> myData
id group
1 D599 A
2 002-0004 B
3 F01932 A
18 F16 B
19
2012 Apr 02
2
sampling rows from a list
Hi:
I'm sure this seems like a rudimentary question, but I am not well versed
with R syntax for lists. I have a ragged array from which I've removed
records (entire rows) with missing data. The functions I used to remove the
missing cases resulted in the generation of an R list class object, that
looks something like this;
mydata
[[1]]
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4
2017 Aug 18
2
R Issues with packages
so I am trying to get my R setup to run this users package. Any help would
be great THANKS
devtools::install_github(repo = "dadrivr/ffanalytics")
I get this
devtools::install_github(repo = "dadrivr/ffanalytics")
Downloading GitHub repo dadrivr/ffanalytics at master
from URL https://api.github.com/repos/dadrivr/ffanalytics/zipball/master
Installing ffanalytics
2008 Feb 12
6
Matching Problem
Hi
I have this vector of strings.
MyData <- c("Test1","Test2","I(Test1^2)","I(Test2^3)","I(Test1.Test2^2)")
where I want to extract only the text after "I(" and before "^" so that the
string returned only contain c("Test1","Test2","Test1.Test2")
I am not very skilled in the use of matching