similar to: Adding Records to a Table in R

Displaying 20 results from an estimated 800 matches similar to: "Adding Records to a Table in R"

2017 Nov 01
0
Adding Records to a Table in R
Hi Paul, #First I set up some sample data since I don't have a copy of your data dtOrig <- as.Date( c("1985-04-01","1985-07-01","1985-12-01","1986-04-01")) dfOrig <- data.frame( TransitDate=dtOrig, Transits=c(100,100,500,325), CargoTons=c(1000,1080,3785,4200) ) #Generate the complete set of dates as a data frame dfDates<- data.frame(
2017 Nov 08
3
Adding Records to a Table in R
Dear Eric, Hope you are doing great. I also tried the following: #First I created the complete date sequence TransitDateFrame <- data.frame(TransitDate=seq(as.Date(dataset1[1,1]), as.Date(dataset1[nrow(dataset1),1]), by = "month")) #Then I did the merging dataset1NEW <- merge(TransitDateFrame, dataset1, by="TransitDate", all.x=TRUE) Now it has, as expected the
2017 Nov 08
0
Adding Records to a Table in R
Hi Instead of attachments copy directly result of dput(TransitDateFrame) and dput(dataset1) to your email. Or, if your data have more than about 20 rows you could copy only part of it. dput(TransitDateFrame[,1:20]) dput(dataset1[,1:20]) Only with this approach we can evaluate your data in all aspects and provide correct answer. Cheers Petr > -----Original Message----- > From: R-help
2017 Jun 19
3
How to Transform a Factor Variable into a Date
Dear all, Hope you are doing great. I have a .csv file that I read into R, the .csv file consistss of two fields (TransitDate and CargoTons). The TransitDate I formatted from Excel in the fashion mmm-yy (e.g.: Apr-2013). However R does not recognize the field TransitDate as a date field. Here is the code: library(lubridate) Dataset <- read.table("U:/NEWCargoData.csv",
2017 Jun 19
0
How to Transform a Factor Variable into a Date
A couple thoughts: 1. converting factors into dates often requires that they be converted to character first. 2. you don't really have dates; you have just months and years 3. therefore perhaps the as.yearmon() function in the zoo package could help library(zoo) my.factor <- factor("Feb 2017") as.yearmon(my.factor) ## gets around the factor-vs-character issue On Mon, Jun
2009 Aug 12
4
paste first row string onto every string in column
Hi, I am trying 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
2008 Jan 24
2
boxplot axis labelling
Hi, i'm very new to R, so sorry for what i'm sure is a very basic question. I'm producing a boxplot with the data below: df3<-data.frame( x=c(10,11,115,12,13,14,16,17,18,21,22,23,24,26,27,28,29,3,30,32,33,34,35,4,4 1,45,5,50,52,56,58,6,67,6738,68,7,8,9), fq=c(8,11,1,2,4,4,2,2,6,3,4,2,2,1,1,1,4,51,3,1,1,1,1,35,1,1,19,2,1,1,1,14,1, 1,1,10,13,5),
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
2008 May 03
1
recode involving a count rule
Hello, R-helpers. I have a data 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),
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
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",
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
2006 Aug 18
1
Insert rows - how can I accomplish this in R
Hi, I have following dataframe. Column A indicates months. DF <- structure(list(A = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 7, 8, 11, 12, 1, 2, 3, 4, 5, 8), B = c(0, 0, 0, 8, 0, 19, 5, 19, 0, 0, 0, 11, 0, 8, 5, 11, 19, 8, 11, 10, 0, 8, 36, 10, 16, 10, 22)), .Names = c("A", "B"), class = "data.frame", row.names = c("1",
2013 Sep 09
1
Fitting Arima Models and Forecasting Using Daily Historical Data
Hello everyone, I was trying to fit an arima model to a daily historical data, but, for some reason, havent been able to. I basically have 212 observations (from 12/1/2012 to 06/30/2013) containing the number of transits for a particular vessel. The following messages are produced by R: dailytrans.fit<-arima(dailytrans$transits, order=c(0,1,2), seasonal=list(order=c(0,1,2), period=365),
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
2009 Apr 28
3
help working with date values
My data contains a variable "observation_date" and it contains values as: 1985-09-02 1985-09-15 1985-07-31 1985-09-02 I need to process data annually rather than daily, therefore I'm trying to 1) either extract the first 4 digits from this field and use them as a new variable "year" or 2) keep the variable as it is and process the analysis using the first 4 digits of
2011 Apr 25
2
Problem with ddply in the plyr-package: surprising output of a date-column
Hi Together, I have a problem with the plyr package - more precisely with the ddply function - and would be very grateful for any help. I hope the example here is precise enough for someone to identify the problem. Basically, in this step I want to identify observations that are identical in terms of certain identifiers (ID1, ID2, ID3) and just want to save those observations (in this step,
2011 Jan 26
1
Using diff and transform
I want to use diff to take the differences in a column "Close" of a data frame "y". But I'd like to do it using the transform function so a new data frame is created with a difference column. The problem is that diff gives one less than the number of elements in the original data frame. So transform gives an error message. I know the first element of diff should be NA or