Displaying 20 results from an estimated 29 matches for "df4".
Did you mean:
df
2009 Feb 19
3
Multiple merge, better solution?
...mmon column. I can of course use merge many times
(see below) but what would be more sophisticated solution? For loop?
Any ideas?
DF1 <- data.frame(var1 = letters[1:5], a = rnorm(5))
DF2 <- data.frame(var1 = letters[3:7], b = rnorm(5))
DF3 <- data.frame(var1 = letters[6:10], c = rnorm(5))
DF4 <- data.frame(var1 = letters[8:12], d = rnorm(5))
g <- merge(DF1, DF2, by.x="var1", by.y="var1", all=T)
g <- merge(g, DF3, by.x="var1", by.y="var1", all=T)
merge(g, DF4, by.x="var1", by.y="var1", all=T)
Thanks in advance.
-Laur...
2004 Mar 15
1
gzfile & read.table on Win32
Hello ...
Are there any known problems or even gotchas to look out for when using a
gzfile connection in read.csv/read.table in Windows?
In the package PROcess, available at
www.bioconductor.org/repository/devel/package/html/PROcess.html
there are two files in the PROcess/inst/Test directory which are of the
extension *.csv.gz.
With both files, if I open up a gzfile connection, say:
vv <-
2010 Jun 08
3
more dates and data frames
Dear R People:
So thanks to your help, I have the following:
> dog3.df <- read.delim("c:/Users/erin/Documents/dog1.txt",header=FALSE,sep="\t")
> dog3.df
V1 V2
1 1/1/2000 dog
2 1/1/2000 cat
3 1/1/2000 tree
4 1/1/2000 dog
5 1/2/2000 cat
6 1/2/2000 cat
7 1/2/2000 cat
8 1/2/2000 tree
9 1/3/2000 dog
10 1/3/2000 tree
11 1/6/2000 dog
12 1/6/2000
2010 Nov 11
4
How to get a specific named element in a nested list
Hello,
I have a nested named list structure, like the following:
x <- list(
list(
list(df1,df2)
list(df3,
list(df4,df5))
list(df6,df7)))
with df1...d7 as data frames. Every data frame is named.
Is there a way to get a specific named element in x?
so, for example,
x[[c("df5")]] gives me the data frame 5?
Thank you in advance!
Best,
Friedericksen
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
...- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2);
var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15, 8) # just example
df <- data.frame(clvar, yvar, var1, var2, var3, var4, var5)
# manual splitting
df1 <- subset(df, clvar == 1)
df2 <- subset(df, clvar == 2)
df3<- subset(df, clvar == 3)
df4<- subset(df, clvar == 4)
df5<- subset(df, clvar == 5)
# i tried to mechanize it
*
for(i in 1:5) {
df[i] <- subset(df, clvar == i)
}
I know it should not work as df[i] is single variable, do it did. But I
could not find away to output multiple dataframes from this loop. My li...
2012 Jan 26
1
How to remove rows representing concurrent sessions from data.frame?
I have a dataset like this (dput for this below) which represents user
computer sessions:
username machine start end
1 user1 D5599.domain.com 2011-01-03 09:44:18 2011-01-03 09:47:27
2 user1 D5599.domain.com 2011-01-03 09:46:29 2011-01-03 10:09:16
3 user1 D5599.domain.com 2011-01-03 14:07:36 2011-01-03 14:56:17
4 user1 D5599.domain.com
2009 Oct 07
1
merging dataframes with an unequal number of variables
...quot;a","b","a","b","a","a")
var3=c(1,NA,NA,2,3,NA)
var4=c(100,200,300,100,200,300)
df1=data.frame(cbind(var1,var2,var3,var4))
# Data frame 2 and three has two of the 4 variables and 4 has eveything
df2=df1[,c(1,2,4)]
df3=df1[,c(2,3,4)]
df4=df1
# I wanted to do this but it produces an error because the number of
variable differ
df=data.frame(rbind(df1,df2,df3,df4))
#I have figured out how to print the names of variable that do match the
'master' list (in this case df1):
# example with df3
names(df3[,na.omit(match(names(df...
2007 Sep 27
2
create data frame(s) from a list with different numbers of rows
...i can do some calculations
# the only way i can figure out how to do this is "one by one" in very
clunky fashion.
# here is an example of my code
sample.df1 <-data.frame(list.sample[[1]])
sample.df2 <-data.frame(list.sample[[2]])
sample.df3 <-data.frame(list.sample[[3]])
sample.df4 <-data.frame(list.sample[[4]])
sample.df5 <-data.frame(list.sample[[5]])
sample.df6 <-data.frame(list.sample[[6]])
sample.df1
sample.df2
sample.df3
sample.df4
sample.df5
sample.df6
# In the future i will have up to 1,200 of these small dataframes to create.
# is there a way to loop thro...
2011 Dec 07
2
Dividing rows when time is overlapping
Hi all,
I have dataframe that was created from the fusion of two dataframes. Both
spanned over the same time intervall but contained different information.
When I put them together, the info overlapped since there is no holes in the
time interval of one of the dataframe. Here is an example where the rows
"sp=A and B" are part of a first df and the rows "sp=C" come from a
2010 Jan 20
1
Reshaping data with xtabs giving me 'extra' data
...ot;, "Doctor Who")
>
> df1 <- data.frame(Date = dates[1], Time = times[1], Show = shows, Score = 1:3)
> df2 <- data.frame(Date = dates[1], Time = times[2], Show = shows, Score = 1:3)
> df3 <- data.frame(Date = dates[1], Time = times[4], Show = shows, Score = 1:3)
> df4 <- data.frame(Date = dates[2], Time = times[1], Show = shows, Score = 1:3)
> df5 <- data.frame(Date = dates[2], Time = times[2], Show = shows, Score = 1:3)
> df6 <- data.frame(Date = dates[2], Time = times[3], Show = shows, Score = 1:3)
> df7 <- data.frame(Date = dates[2], Time...
2010 Dec 16
2
Compare two dataframes
Hello,
I have two dataframes DF1 and DF2 that should be identical but are not
(DF1 has some rows that aren't in DF2, and vice versa). I would like
to produce a new dataframe DF3 containing rows in DF1 that aren't in
DF2 (and similarly DF4 would contain rows in DF2 that aren't in DF1).
I have a solution for this problem (see self contained example below)
but it's awkward and requires making a new "ID" column by pasting
together all of the columns in each DF and them comparing the two DFs
based on this unique ID.
I...
2008 Mar 24
6
vlookup in R
Hi,
Is there are function similar to excel vlookup in R. Please let me know.
Thanks,
Sachin
____________________________________________________________________________________
[[alternative HTML version deleted]]
2010 Sep 04
4
Please explain "do.call" in this context, or critique to "stack this list faster"
...ckMerge.R
## Paul Johnson <pauljohn at ku.edu>
## 2010-09-02
## rbind is neat,but how to do it to a lot of
## data frames?
## Here is a test case
df1 <- data.frame(x=rnorm(100),y=rnorm(100))
df2 <- data.frame(x=rnorm(100),y=rnorm(100))
df3 <- data.frame(x=rnorm(100),y=rnorm(100))
df4 <- data.frame(x=rnorm(100),y=rnorm(100))
mylist <- list(df1, df2, df3, df4)
## Usually we have done a stupid
## loop to get this done
resultDF <- mylist[[1]]
for (i in 2:4) resultDF <- rbind(resultDF, mylist[[i]])
## My intuition was that this should work:
## lapply( mylist, rbind...
2007 Oct 22
3
median value dataframe coming from multiple dataframes
Hi all,
I am not a skillful R programmer and has I am handling with large dataframes (about 30000 x 300) I am in need of an efficient function.
I have 4 dataframes with the same dimension. I need to generate other dataframe with the some dimension than the others where in each position it has the median value of the 4 values in the same position coming from the 4 dataframes.
Grateful by your
2012 Jun 03
2
merging single column from different dataframe
Hi all,
probably really simple to solve, but having no background in programming I
haven't been able to figure this out: I have two dataframes like
df1 <- data.frame(names1=c('aa','ab', 'ac', 'ad'), var1=c(1,5,7,12))
df2 <- data.frame(names2=c('aa', 'ab', 'ac', 'ad', 'ae'),
var2=c(3,6,9,12,15))
Now I want merge
2012 Jul 10
1
Why 95% "quantile" empty in R or why 95% "quantile" = 1 with data values between 0 and 1?
...c(0.50,0.75, 0.90,
0.91,0.92,0.93,0.94,0.95,0.96,0.97,0.98)
) }))
}
colsGTQuantile <- function(x, qs, q) {
sapply(rownames(x), function(rn) {
cat(sprintf("*** row name = %s, q = %s, val = %f\n", rn, q, qs[rn, q]))
names(x[rn, x[rn,] > qs[rn, q]])
}, simplify = TRUE)
}
df4 <- colsGTQuantile(km$points, qs, "95%")
--
View this message in context: http://r.789695.n4.nabble.com/Why-95-quantile-empty-in-R-or-why-95-quantile-1-with-data-values-between-0-and-1-tp4635934.html
Sent from the R help mailing list archive at Nabble.com.
2013 Jun 11
1
mapply on multiple data frames
...ave the same structure.
Here is my code so far:
f<-function(x,y) {
test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=="num",],paired=T,alternative="greater")
out<-test$p.value
return(out)
}
all_nums<-list(num1,num2,num3,num4)
all_dfs<-list(df1,df2,df3,df4)
mapply(f,all_dfs,all_nums)
This tells me that $ operator is invalid for atomic vectors. I have tried shifting to notation using [ ,] to denote columns, but that gives me this error: incorrect number of dimensions.
Thank you in advance,
Elizabeth
2006 Nov 03
1
man page for as.matrix for data frames outdated?
...rInts)
> storage.mode(as.matrix(df2))
[1] "integer"
> fourDoubles <- rep(pi,4)
> df3 <- data.frame(c=fourDoubles, a=fourLogicals, b=fourInts)
> storage.mode(as.matrix(df3))
[1] "double"
> fourComplexes <- (-1:2)+3i
> df4 <- data.frame(a=fourLogicals, d=fourComplexes, b=fourInts,
c=fourDoubles)
> storage.mode(as.matrix(df4))
[1] "complex"
If one column is of mode character, then 'as.matrix' will effectively
return a character matrix:
> df5 <- data.frame(toto=c("a&...
2012 Jun 12
4
replacing NA for zero
Dear R users,
I have a very basic query, but was unable to find a proper anwser.
I have the following data.frame
x y
2 0.12
3 0.25
4 0.11
6 0.16
7 0.20
and, due to further calculations, I need the data to be stored as
x y
1 0
2 0.12
3 0.25
4 0.11
5 0
6 0.16
7 0.20
8 0
How do
2010 Sep 09
0
Fast / dependable way to "stack together" data frames from a list
...run this, I hope you will feel smarter, as I do!
:)
## stackListItems.R
## Paul Johnson <pauljohn at ku.edu>
## 2010-09-07
## Here is a test case
df1 <- data.frame(x=rnorm(100),y=rnorm(100))
df2 <- data.frame(x=rnorm(100),y=rnorm(100))
df3 <- data.frame(x=rnorm(100),y=rnorm(100))
df4 <- data.frame(x=rnorm(100),y=rnorm(100))
mylist <- list(df1, df2, df3, df4)
## Here's the way we have done it. We understand this,
## we believe the result, it is easy to remember. It is
## also horribly slow for a long list.
resultDF <- mylist[[1]]
for (i in 2:4) resultDF <- rb...