search for: df2

Displaying 20 results from an estimated 130 matches for "df2".

Did you mean: df
2011 Mar 28
problem in simple saving and loading data frames
...table option), cost me time and sometime computer decomes not responsive. So I need a way to save my dataframe in my workdirectory as such. Execuse me if the problem is too simple. I tried the following, I do not know what is wrong with it: Example data: x <- 1:10 y <- 21:30 z <- 31:40 df2 <- data.frame(x,y, z) save(df2, file="df2.RData") My trials # trying to load data(df2) Warning message: In data(df2) : data set ''df2'' not found data(df2.RData) Warning message: In data(df2.RData) : data set ''df2.RData'' not found data("df2.RD...
2013 Feb 26
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 funct...
2013 Jan 02
rbind: inconsistent behaviour with empty data frames?
The rbind on empty and nonempty data frames behaves inconsistently. I am not sure if by design. In the first example, first row is deleted, which may or may not be on purpose: df1 <- data.frame() df2 <- data.frame(foo=c(1, 2), bar=c("a", "b")) rbind(df1, df2) foo bar 2 2 b Now if we continue: df1 <- data.frame(matrix(0, 0, 2)) names(df1) <- names(df2) foo bar 2 1 a 3 2 b So now data frames combined successfully, but the row names have bee...
2012 Sep 27
Colsplit, removing parts of a string
Hi, I am using colsplit (package = reshape) to split all strings in a column according to the same patterns. Here an example: library(reshape2) df1 <- data.frame(x=c("str1_name2", "str3_name5")) df2 <- data.frame(df1, colsplit(df1$x, pattern = "_", names=c("str","name"))) This is nearly what I want but I want to remove the words "str" and "name" from the values, because the columns are already named with that words. Is there a way to remove...
2011 May 16
rbind with partially overlapping column names
Hello, I would like to merge two data frames with partially overlapping column names with an rbind-like operation. For the follow data frames, df1 <- data.frame(a=c("A","A"),b=c("B","B")) df2 <- data.frame(b=c("b","b"),c=c("c","c")) I would like the output frame to be (with NAs where the frames don''t overlap) a b c A B NA A B NA NA b c NA b c I am familiar with ?merge and ?rbind, but neither seem...
2017 Oct 10
About multiple panels with limited space in-between
Hi R users, I have a question about plotting. The following two datasets are an example. What I have in mind is like the attached figure, but just have two rows, top row is for DF1, bottom row is for DF2. The top and bottom rows, have x-axis as var1, var2, var3, etc, while the y-axis represents A. For each row, only the leftmost panel has y-axis ticks and label. For the two rows, only the bottom row has x-axis ticks and label. I am not very clear about the coding. Thanks if you could give me any su...
2011 Jun 06
Merge two columns of a data frame
...) prefix2 <- c("cheap", "budget") roots2 <- c("car insurance", "auto insurance") roots3 <- c("car insurance", "auto insurance") suffix3 <- c("quote", "quotes") df1 <- expand.grid(prefix, roots, suffix) df2 <- expand.grid(prefix2, roots2) df3 <- expand.grid(roots3, suffix3) df1; df2; df3 df1, df2, and df3 are seperate data structures with seperate columns for root, prefix, and suffix. Var1 Var2 Var3 1 cheap car insurance quote 2 budget car insurance quote 3 cheap auto insur...
2016 Apr 24
Dividing rows in groups
Hi I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1. df1: 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 3 0 5 2...
2010 Jan 22
Question on Merge/Lookup
I need to merge three datasets and don''t know how. If I were using SQL, I would use df3, look up the characteristics of each date in df1 and the value for each observation in df2. df1 - unique list of Dates and characteristics of those dates Date, YYYYMM, YYYYWW, DOW df2 - the raw data Date, Place, Value df3 - all posibile combinations of Date + Place (via expand.grid(unique(df2$Date),unique(df2$Place)) Date, Place I need to end up with: Date, YYYYMM, YYYYWW, DOW,...
2017 Jul 13
about plotting a special case
Thanks, Jim. The code works, but I don't understand why you use q1090 <- quantile(DF1$B, probs=c()), rather than DF1$A? Also, how to add a legend for both points DF1 and DF2? On Wed, Jul 12, 2017 at 8:25 PM, Jim Lemon <drjimlemon at> wrote: > Hi lily, > Here is the first plot: > > plot(DF1$A,DF1$B,pch=19,col="red") > meanA<-mean(DF1$A) > meanB<-mean(DF1$B) > points(meanA,meanB,pch=18,col="red") > q1090...
2005 Jul 11
exact values for p-values - more information.
Hi there, If I do an lm, I get p-vlues as p-value: < 2.2e-16 This is obtained from F =39540 with df1 = 1, df2 = 7025. Suppose am interested in exact value such as p-value = 1.6e-16 (note = and not <) How do I go about it? stephen
2012 Jan 02
Conditionally adding a constant
I am trying to add a constant to the previous value of a variable based on certain conditions. Maybe there is a simple way to do this that I am missing completely. I have given an example below: df <- data.frame(x = c(1,2,3,4,5), y = c(10,20,30,NA,NA)) > df x y 1 1 10 2 2 20 3 3 30 4 4 NA 5 5 NA I want to add 2 to the previous value of y, if x exceeds 3 (also will have to handle NAs in
2013 Jan 15
SQLDF column errors
I am trying to exclude integer values from a small data frame 1, d1 that have matching hits in data frame 2, d2 (Very big) which involves matching those hits first. I am trying to use sqldf on the df''s in the following fashion: df1: V1 12675 14753 16222 18765 df2: head(df2) V1 V2 13647 rd1500 14753 rd1580 15987 rd1590 16222 rd2020..... df1_new<-sqldf("select df1.V1, df2.V2 where rs10.V1 = d10.pos”) - Ideally I would like to try to use "delete" or not equal to "!=" though I can only find that delete w...
2003 Apr 21
index after rbind
I am using rbind to concatenate two dataframes, but after the rbind I get a strange "double" index. I am using rbind a number of times to make one large dataset. Is there a way to prevent the "double" index? Or is there some other way to concatenate the data (it looks like merge only works by columns)? Here is an example of the "double" index.
2017 Jul 13
about plotting a special case
...> >> values A and B have different ranges. Therefore you would want >> horizontal error bars for the B mean. The dispersion function doesn't >> do horizontal error bars, so you can use plotCI also in plotrix. Here >> is an example with two databases: >> >> DF2<-read.table(text="A B C >> 62 22 54 >> 69 24 55 >> 51 28 56 >> 47 25 53 >> 70 21 52 >> 61 23 50 >> 40 19 51 >> 58 18 57 >> 38 24 58 >> 37 27 53",header=TRUE) >> plot(DF...
2013 Sep 22
Coding several dummy variables into a single categorical variable
Colleagues, I have generated several dummy variables: n$native0 <- 1 * (n$re=="white" & n$usborn=="yes") n$native1 <- 1 * (n$re=="afam" & n$usborn=="yes") n$native2 <- 1 * (n$re=="carib" & n$usborn=="yes") n$native3 <- 1 * (n$re=="carib" & n$usborn=="no") I would now like to combine these
2010 Sep 10
Counting occurances of a letter by a factor
I''m trying to find a more elegant way of doing this. What I''m trying to accomplish is to count the frequency of letters (major / minor alleles) in a string grouped by the factor levels in another column of my data frame. Ex. > DF<-data.frame(c("CC", "CC", NA, "CG", "GG", "GC"), c("L", "U",
2011 May 16
Fwd: Re: rbind with partially overlapping column names
...t; values (sorry for the poor test case) so I will cook up something like Ian > and Dennis suggested. For what it''s worth, you could always augment your dataframes with non-overlapping variables and then William''s merge(all=TRUE,...) will work: df1$w <- 1:nrow(df1) df2$w <- 1:nrow(df2) + nrow(df1) df3 <- merge(df1, df2, all=TRUE)[c("a","b","c")] Peter Ehlers > > Thanks again. > > Jonathan > > On Mon, May 16, 2011 at 12:28 AM, Ian Gow<iandgow at> wrote: > >> That approach relies...
2004 Jun 29
nls fitting problems (singularity)
...ingularity with starting parameters. # x-values x<-c(-1,5,8,11,13,15,16,17,18,19,21,22) # y1-values (first data set) y1=c(-55,-22,-13,-11,-9.7,-1.4,-0.22,5.3,8.5,10,14,20) # y2-values (second data set) y2=c(-92,-42,-15,1.3,2.7,8.7,9.7,13,11,19,18,22) # data frames df1<-data.frame(x=x, y=y1) df2<-data.frame(x=x, y=y2) # start list for parameters sl<-list( d=0, b=10, c1=90, c2=20) # y1-Analysis - Result: Error in ... singular gradient nls(y~d+(x-b)*c1*(x-b<0)+(x-b)*c2*(x-b>=0), data=df1, start=sl) # y2-Analysis - Result: working... nls(y~d+(x-b)*c1*(x-b<0)+(x-b)*c2*(x-b&g...
2013 Jan 27
Re: Removing values containing a specific character
Awesome, thanks Arun, that''s exactly what I was looking for! On Sat, Jan 26, 2013 at 9:21 PM, arun kirshna [via R] <> wrote: > Hi, > Try this: > df[]<-lapply(df,as.character) > df2<-df > df[,1][grep("@",df$names)]<- "" > df > #names emails > #1 bob > #2 joe > #3 > #4 emily > #5 > > #2nd part: >...