search for: dfnew

Displaying 17 results from an estimated 17 matches for "dfnew".

Did you mean: fnew
2009 Aug 12
4
paste first row string onto every string in column
...t a data frame such that the string in the first line is appended onto the beginning of each element in the subsequent rows. The data looks like this: > df V1 V2 V3 V4 1 DPA1* DPA1* DPB1* DPB1* 2 0103 0104 0401 0601 3 0103 0103 0301 0402 . . and what I want is this: >dfnew V1 V2 V3 V4 1 DPA1* DPA1* DPB1* DPB1* 2 DPA1*0103 DPA1*0104 DPB1*0401 DPB1*0601 3 DPA1*0103 DPA1*0103 DPB1*0301 DPB1*0402 any help is much appreciated, I am new to this and struggling. Jill ___ Jill Hollenbach, PhD, MPH Assistant Staff Scientist Center for Genetic...
2008 Jan 24
2
boxplot axis labelling
...,times=fqcvd)) kcvd3<-c(kcvd3,rep(NA,times=length(k3)-length(kcvd3))) kcan3<-with(df3,rep(x,times=fqcan)) kcan3<-c(kcan3,rep(NA,times=length(k3)-length(kcan3))) knoncan3<-with(df3,rep(x,times=fqnoncan)) knoncan3<-c(knoncan3,rep(NA,times=length(k3)-length(knoncan3))) dfnew<-data.frame(kcvd3,kcan3,knoncan3,k3) boxplot(dfnew,log='y', ylim=c(1,4000)) This produces x axis labels 'kcvd3,kcan3,knoncan3,k3', one for each plot as you might expect. However, I would like all plot to sit next to each other with a single label. Could anybody he...
2008 May 03
1
recode involving a count rule
...ta frame below called df. I want to add a variable c, based on the following logic: if df$a < 5 then the first two times this condition is met place a 1 in c, the next two times this condition is met place a 2 in c and when the condition is not met let c equal df$b. The result would look like, dfnew, shown below. a <- rep(c(3,5,7), 4) b <- rep(c(NA,1,2), 4) df <- data.frame(a,b) > df a b 1 3 NA 2 5 1 3 7 2 4 3 NA 5 5 1 6 7 2 7 3 NA 8 5 1 9 7 2 10 3 NA 11 5 1 12 7 2 c <- c(1 , 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2) dfnew <- data.frame(a, b,c) > dfne...
2017 Nov 01
0
Adding Records to a Table in R
...ts=c(100,100,500,325), CargoTons=c(1000,1080,3785,4200) ) #Generate the complete set of dates as a data frame dfDates<- data.frame( TransitDate=seq(from=as.Date("1985-04-01"),by="1 month",length=13) ) # do the merge adding the "missing" rows (where NA will appear) dfNew <- merge(dfDates, dfOrig, by="TransitDate", all.x=TRUE ) # replace the NA's by zero dfNew[is.na(dfNew)] <- 0 HTH, Eric On Wed, Nov 1, 2017 at 9:45 PM, Paul Bernal <paulbernal07 at gmail.com> wrote: > Dear R friends, > > I am currently working with time serie...
2017 Nov 01
3
Adding Records to a Table in R
Dear R friends, I am currently working with time series data, and I have a table(as data frame) that has looks like this (TransitDate are in format = "%e-%B-%Y") : TransitDate Transits CargoTons 1985-04-01 100 2500 1985-05-01 135 4500 1985-06-01 120 1750 1985-07-01 100 3750 1985-08-01 200
2010 Apr 21
2
Table to List Transformation Scenario
I have a series of tables, one for each environment indicating a date (row) and a sample at each hour of the day (0 to 23) Test1 Table: Date,Hour1,Hour2,...Hour23 1/1/10,123,123,...,123 I would like to model this as a time series but how can I translate the table into a list such that I can get: 1/1/10 00:00, 123 1/1/10 01:00, 123 1/1/10 02:00, 123 ... 1/1/10 23:00, 123 Any suggestions on how
2017 Nov 08
3
Adding Records to a Table in R
...c(1000,1080,3785,4200) ) > > #Generate the complete set of dates as a data frame > dfDates<- data.frame( TransitDate=seq(from=as.Date("1985-04-01"),by="1 > month",length=13) ) > > # do the merge adding the "missing" rows (where NA will appear) > dfNew <- merge(dfDates, dfOrig, by="TransitDate", all.x=TRUE ) > > # replace the NA's by zero > dfNew[is.na(dfNew)] <- 0 > > HTH, > Eric > > > On Wed, Nov 1, 2017 at 9:45 PM, Paul Bernal <paulbernal07 at gmail.com> > wrote: > >> Dear R fri...
2013 Apr 09
4
Converting matrix to data frame without losing an assigned dimname
Hello All, Would like to be able to convert a matrix to a dataframe without losing an assigned dimname. Here is an example that should illustrate what I'm talking about. tableData <- state.x77[c(7, 38, 20, 46), c(7, 1, 8)] names(dimnames(tableData)) <- c("State", "") tableData State Frost Population Area Connecticut 139 3100 4862
2010 Feb 17
3
Extending data frame with longer columns
Hi, I am a beginner in R and have only read a few chapters in the R book, I was not able to find a solution for this simple problem. I have an empty data frame: a=data.frame(name="test") which I would like to extend in a for-loop (with data extracted from a database). Ideally I would like to extend the data frame like this: a["new_1"] = 1:10 a["new_1"] = 1:12
2017 Nov 08
0
Adding Records to a Table in R
...> > > > #Generate the complete set of dates as a data frame > > dfDates<- data.frame( TransitDate=seq(from=as.Date("1985-04-01"),by="1 > > month",length=13) ) > > > > # do the merge adding the "missing" rows (where NA will appear) dfNew > > <- merge(dfDates, dfOrig, by="TransitDate", all.x=TRUE ) > > > > # replace the NA's by zero > > dfNew[is.na(dfNew)] <- 0 > > > > HTH, > > Eric > > > > > > On Wed, Nov 1, 2017 at 9:45 PM, Paul Bernal <paulbernal07...
2011 Jan 16
3
transform a df with a condition
Dear all, for each A == 3 in 'df' I would like to change the variables B and K. My result should be the whole df and not the subset (A==3)... df <- data.frame(A = c(1,1,3,2,2,3,3), B = c(2,1,1,2,7,8,7), K = c("a.1", "d.2", "f.3", "a.1", "k.4", "f.9",
2006 Aug 18
1
Insert rows - how can I accomplish this in R
...26", "27")) There is some discontinuity in the data. For example month 6, 9,10 data (2nd year) and month 6 data (3rd year) are absent. I want to insert the rows in place of these missing months and set the corresponding B column to zero. i.e., the result should look like: DFNEW <- structure(list(A = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8), B = c(0, 0, 0, 8, 0, 19, 5, 19, 0, 0, 0, 11, 0, 8, 5, 11, 19, 0, 8, 11, 0, 0, 10, 0, 8, 36, 10, 16, 10, 0, 0, 22)), .Names = c("A", "B"),...
2009 Oct 05
3
how to have 'match' ignore no-matches
Hi all, I think this is a very basic question, but I'm new to this so please bear with me. I'm using match to translate elements of a data frame using a lookup table. If the content of a particular cell is not found in the lookup table, the function returns NA. I'm wondering how I can just ignore those cells, and return the original contents if no match is found in the lookup table.
2008 May 15
2
Adding columns to dataframe
Hi, I have a dataframe SDF1 that looks like this: Char1 Char2 Char 3 W.2007.02 W.2007.09 W.2007.16 W.2008.13 A C1 F1 F2 F3 A C2 F4 B C3 F5 F6 I have another dataframe SDF2 with 163 cols that has the following column names Char1 Char2 Char 3 W.2007.02 W.2007.03 W.2007.04
2011 Dec 12
0
using dcast to reshape a DF from long to wide with multiple measured variables per obs
...umeric(DF$v2)   It represents data in long format that needs to be reshaped by person, with each fill number+v2 and fill number+v3 as a column, with missing values in cases where a person does not have a fill number.   Essentially, I would like the DF to eventually assume the following strucutre:   DFnew <- structure(list(person = 1:3, fillno1_v2 = c(14975L, 14975L, 14975L ), fillno1_v3 = c(30L, 30L, 30L), fillno2_v2 = c(15006L, 15006L, 15006L), fillno2_v3 = c(30L, 30L, 30L), fillno3_v2 = c(15034L, 15034L, 15034L), fillno3_v3 = c(30L, 30L, 30L), fillno4_v2 = c(15065L, 15065L, 15065L), fillno4...
2009 Aug 12
0
Re : paste first row string onto every string in column
...g to edit a data frame such that the string in the first line is appended onto the beginning of each element in the subsequent rows. The data looks like this: > df       V1  V2  V3  V4  1  DPA1* DPA1* DPB1* DPB1* 2  0103 0104 0401 0601 3  0103 0103 0301 0402 . . and what I want is this: >dfnew       V1  V2  V3  V4  1  DPA1* DPA1* DPB1* DPB1* 2  DPA1*0103 DPA1*0104 DPB1*0401 DPB1*0601 3  DPA1*0103 DPA1*0103 DPB1*0301 DPB1*0402 any help is much appreciated, I am new to this and struggling. Jill ___ Jill Hollenbach, PhD, MPH     Assistant Staff Scientist     Center for Genetics     Ch...
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