Displaying 20 results from an estimated 11000 matches similar to: "Partial comparison in string vector"
2007 Aug 20
2
how to collapse a list of 1 column matrix to a matrix?
Hi,
I encounter a situation where I have a list whose element is a column matrix. Says,
$'1'
[,1]
1
2
3
$'2'
[,1]
4
5
6
Is there fast way to collapse the list into a matrix like a cbind operation in this case? Meaning, the result should be a matrix that looks like:
[,1] [,2]
[1,] 1 4
[2,] 2 5
[3,] 3 6
I can loop through all elements and do
2008 Jan 18
1
Assigning into each of a list of dataframes
What is the right way to assign a new variable into each a of list of
data frames? Here is my failed attempt:
mylist <- list(df1 = data.frame(A = runif(5), B = runif(5)),
df2 = data.frame(A = runif(5), B= runif(5)))
lapply(mylist, function(x){x$Y <- x$A * x$B})
$df1
[1] 0.25589928 0.03446026 0.94992362 0.21388326 0.08668821
$df2
[1] 0.08771839 0.05643553 0.09036894
2008 Sep 14
5
difference of two data frames
Hello
I have 2 data frames DF1 and DF2 where DF2 is a subset of DF1:
DF1= data.frame(V1=1:6, V2= letters[1:6])
DF2= data.frame(V1=1:3, V2= letters[1:3])
How do I create a new data frame of the difference between DF1 and DF2
newDF=data.frame(V1=4:6, V2= letters[4:6])
In my real data, the rows are not in order as in the example I provided.
Thanks much
Joseph
[[alternative HTML version
2011 May 31
0
filling in a dataframe with another dataframe
Hello All,
I have two dataframes and I wish to insert the values of one dataframe into
another (let's call them DF1 and DF2). DF1 looks like this:
col1.....col2
a...........1
b...........2
c...........3
d...........4
e...........5
f............6
g...........7
where col1 (which is just the first column of the dataframe) is a list of
characters and col2 is the numeric value associated with
2017 Jul 13
0
about plotting a special case
If you want colors mapped to the _values_ in DF1$C, there are a number
of ways to do it:
Color_unq<-color.scale(DF1$C,c(1,0),c(0,0,c(0,1))
This will produce colors from the lowest values (red) through the
highest (blue). See the help page for color.scale to get different
colors. With this you can use color.legend to add a mapping of the
values and colors.
If you just want different colors,
2011 Aug 18
2
Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
Dear expeRts,
What is the best approach to create a third data frame from two given ones, when
the new/third data frame has last column computed from the last columns of the two given
data frames?
## Okay, sounds complicated, so here is an example. Assume we have the two data frames:
df1 <- data.frame(Year=rep(2001:2010, each=2), Group=c("Group 1","Group 2"), Value=1:20)
2013 Feb 26
2
merging or joining 2 dataframes: merge, rbind.fill, etc.?
#I want to "merge" or "join" 2 dataframes (df1 & df2) into a 3rd
(mydf). I want the 3rd dataframe to contain 1 row for each row in df1
& df2, and all the columns in both df1 & df2. The solution should
"work" even if the 2 dataframes are identical, and even if the 2
dataframes do not have the same column names. The rbind.fill function
seems to work. For
2006 Jul 01
1
noncentral F-distributed random numbers (PR#9055)
Full_Name: Long Qu
Version: 2.3.1
OS: Windows XP
Submission from: (NULL) (64.113.93.235)
The QQ-plot of two versions of simulating noncentral F-distributed random
numbers has quite different scales:
> qqplot(rf(1000,2,15,3),qf(runif(1000),2,15,3))
The rf() function reads:
> rf
function (n, df1, df2, ncp = 0)
{
if (ncp == 0)
.Internal(rf(n, df1, df2))
else rchisq(n, df1,
2012 Oct 11
1
as.data.frame.matrix() returns an invalid object
Hi,
Two ways to create what should normally be the same data frame:
> df1 <- data.frame(a=character(0), b=character(0))> df1
[1] a b
<0 rows> (or 0-length row.names)
> df2 <- as.data.frame(matrix(character(0), ncol=2,
dimnames=list(NULL, letters[1:2])))
> df2
[1] a b
<0 rows> (or 0-length row.names)
unique() works as expected except that I
2011 Nov 08
2
compare linear regressions
Hi,
I'm trying to compare two linear regressions. I'm using the
following approach:
##################
xx<-1:100
df1 <- data.frame(x = xx, y = xx * 2 + 30 + rnorm(n=length(xx),sd=10), g = 1)
df2 <- data.frame(x = xx, y = xx * 4 + 9 + rnorm(n=length(xx),sd=10), g = 2)
dta <- rbind(df1, df2)
dta$g <- factor(dta$g)
2005 Jan 21
0
R: chi-Squared distribution
Hi,
Attention chi-squared distribution, unlike F
distribution, has only df1 as parameter, not df1 and
df2. So correct into:
outer(1:3, 1:3, function(df1, df2) qchisq(0.95, df1,
df2))
outer(1:3, 1:3, function(df1, df2) qchisq(0.95, df1))
^^^^^^^^^^^^^^^^^^^^
Regards,
Vito
you wrote:
Dear Rs:
outer(1:3, 1:3, function(df1, df2) qf(0.95, df1, df2))
I compare this F
2011 May 16
0
Fwd: Re: rbind with partially overlapping column names
I had meant to copy the list on this; must have hit 'Reply'
instead of 'Reply All'.
P Ehlers
-------- Original Message --------
Subject: Re: [R] rbind with partially overlapping column names
Date: Mon, 16 May 2011 11:14:11 -0600
From: Peter Ehlers <ehlers at ucalgary.ca>
To: Jonathan Flowers <jonathanmflowers at gmail.com>
On 2011-05-16 08:56, Jonathan Flowers wrote:
2004 Feb 19
1
Comparing two regression slopes
I would suggest the method of Sokal and Rholf (1995) S. 498, using the F
test.
Below I repeat the analysis by Spencer Graves:
Spencer:
> df1 <- data.frame(x=1:3, y=1:3+rnorm(3))
> df2 <- data.frame(x=1:3, y=1:3+rnorm(3))
> fit1 <- lm(y~x, df1)
> s1 <- summary(fit1)$coefficients
> fit2 <- lm(y~x, df2)
> s2 <- summary(fit2)$coefficients
> db <-
2010 Apr 23
0
A distance measure between top-k list
Hi folks,
Here is the problem. I am giving an example .I want to find a measure
of similarity or dissimilarity among ranking (of students of a same class
of size say 50)by two judges. But instead of observing the rank of all the
50 students
(Where we could have used rank correlation measures)in each case what I have
is
2 list of top 20 students chosen by each judge.
The following paper gives out
2005 Jun 09
1
Subassignments involving NAs in data frames
I'm seeing some inconsistent behavior when re-assigning values in a data
frame. The first assignment turns all of the 0s in my data frame to 2s,
the second fails to do so.
> df1 <- data.frame(a = c(NA, 0, 3, 4))
> df2 <- data.frame(a = c(NA, 0, 0, 4))
> df1[df1 == 0] <- 2 ## Works
> df2[df2 == 0] <- 2
Error: NAs are not allowed in subscripted assignments
Checking an
2011 Mar 18
1
Problem with Slope.test function
Hi all,
I need to test the significnce of difference between slopes of two regression lines and regression line with theoretical line. I try to use Slope.test function from emu package,
but an error occured...
library(emu)
d1<-data.frame(P1=c(1,2,3,5,7,8,9,13,14,15),
P2=c(1,2,5,8,11,13,15,15,18,24),
R=c(2,7,8,9,16,21,27,31,33,36)) # First data set
m1<-lm(R~P1+P2+P1*P2,data=d1) # Regr.
2007 May 05
1
loop in function
Dear Mailing-List,
I think this is a newbie question. However, i would like to integrate a
loop in the function below. So that the script calculates for each
variable within the dataframe df1 the connecting data in df2. Actually it
takes only the first row. I hope that's clear. My goal is to apply the
function for each data in df1. Many thanks in advance. An example is as
follows:
df1
2011 Nov 30
1
Replace columns in a data.frame randomly splitted
Dear community,
I'm working with the data.frame attached (
http://r.789695.n4.nabble.com/file/n4122926/df1.xls df1.xls ), let's call it
df1.
I typed: df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, rowNames=
TRUE)
Then I splited randomly df1 using splitdf function
(http://gettinggeneticsdone.blogspot.com/2011/03/splitting-
dataset-revisited-keeping.html)
2007 May 05
1
(no subject)
Dear Mailing-List,
I think this is a newbie question. However, i would like to integrate a
loop in the function below. So that the script calculates for each
variable within the dataframe df1 the connecting data in df2. Actually it
takes only the first row. I hope that's clear. My goal is to apply the
function for each data in df1. Many thanks in advance. An example is as
follows:
df1
2016 Apr 24
0
Dividing rows in groups
This will handle all the columns; it assumes the ones you want to start
with are in column 2 through the end:
> library(dplyr)
> df1 <- read.table(text = "ID A B
+ 1 1 2
+ 1 0 3
+ 2 5 NA
+ 2 1 3
+ 3 1 4
+ 4 NA NA
+ 4 0 1
+ 4