similar to: merging 2 frames while keeping all the entries from the "reference" frame

Displaying 20 results from an estimated 3000 matches similar to: "merging 2 frames while keeping all the entries from the "reference" frame"

2011 Jul 14
2
cbind in aggregate formula - based on an existing object (vector)
Hello! I am aggregating using a formula in aggregate - of the type: aggregate(cbind(var1,var2,var3)~factor1+factor2,sum,data=mydata) However, I actually have an object (vector of my variables to be aggregated): myvars<-c("var1","var2","var3") I'd like my aggregate formula (its "cbind" part) to be able to use my "myvars" object. Is it
2011 Apr 18
1
using "aggregate" when variable names contain spaces
Hello! my data set has many variables. Unfortuantely, many of those variables contain spaces in their names. I need advice on: how to refer to variable names in the formula for "aggregate". See example below: ### Generating example data set: mydate = rep(seq(as.Date("2008-12-01"), length = 3, by = "month"),4) value1=c(1,10,100,2,20,200,3,30,300,4,40,400)
2011 Mar 30
2
summing values by week - based on daily dates - but with some dates missing
Dear everybody, I have the following challenge. I have a data set with 2 subgroups, dates (days), and corresponding values (see example code below). Within each subgroup: I need to aggregate (sum) the values by week - for weeks that start on a Monday (for example, 2008-12-29 was a Monday). I find it difficult because I have missing dates in my data - so that sometimes I don't even have the
2011 May 19
1
Creating a "shifted" month (one that starts not on the first of each month but on another date)
Hello! I have a data frame with dates. I need to create a new "month" that starts on the 20th of each month - because I'll need to aggregate my data later by that "shifted" month. I wrote the code below and it works. However, I was wondering if there is some ready-made function in some package - that makes it easier/more elegant? Thanks a lot! # Example data:
2012 Jan 11
1
Help with speed (replacing the loop?)
Dear R-ers, I have a loop below that loops through my numeric variables in data frame x and through levels of the factor "group" and multiplies (group by group) the values of numeric variables in x by the corresponding group-specific values from data frame y. In reality, my: dim(x) is 300,000 rows by 100 variables, and dim(y) is 120 levels of "group" by 100 variables. So, my
2009 Oct 06
2
Extracting year from a date object
Hi all, this one left me a bit puzzled, as I don't seem to find a function to perform this easily. I must have overlooked the obvious, so sorry in advance. I have a list of dates in numerical format (i.e. 34576), defined as the number of days that passed since january 1st 1900. So I apply the function : > MyDate <-as.Date(34576,origin="1900-01-01") > MyDate [1]
2006 May 21
1
POSIX, time zone and Windows
Dear Listers, Apologize to pile up on the 'tz' issue in POSIX objects. I have a 'simple' thing on which I must make up my mind but cannot do it from the existing R-help threads. I am currently working on dog telemetry in China, and download time information from GPS collars. I would like to set up the corresponding POSIXxx variables in R to a given time zone. Eg Pekin
2011 May 03
0
turning data with start and end date into daily data
Hello! I have data that contain, among other things the date for the beginning and for the end of a (daily) time series (see example below - "mydata") mystring1<-c("String 1", "String 2") mystring2<-c("String a", "String b") starts<-c(as.Date("2011-02-01"),as.Date("2011-03-02"))
2011 Mar 01
2
Does POSIXlt extract date components properly?
I would like to use POSIX classes to store dates and extract components of dates. Following the example in Spector ("Data Manipulation in R"), I create a date > mydate = as. POSIXlt('2005-4-19 7:01:00') I then successfully extract the day with the command > mydate$day [1] 19 But when I try to extract the month > mydate$mon [1] 3 it returns the wrong month. And
2013 Apr 02
2
Create a vector without using an external 'if statement'
Dear R-users, suppose I have three dataframes like these df1: mydate min_temp 31032013 12 01042013 8 02042013 -999 df2: mydate min_temp 31032013 10 01042013 11 02042013 14 df3: mydate min_temp 31032013 4 01042013 3 02042013 5 where -999 means that the temperature data is not available (at the moment I cannot change it to NA because I am not the db administrator); suppose also that oggi is
2011 Oct 27
1
plotting large time series
hello, I got a problem with plotting large time series, since I want to store the results in a .PDF file (I want to store several pages of plots). The PDF files get too large to be handled (> 10MB, one was even 200MB big). So I wonder, if there would be a possibilty to either - reduce the file size of the PDF - change the way the plot is generated to reduce the plot size? I use:
2009 Aug 28
2
new data.frame summed by date
Hi, I wonder if someone can suggest how to create a new data.frame Y from X where X$PL_Pos is summed by each unique X$MyDate. Y should end up with two (or more) columns Y$MyDate and Y$PL_Sum with its value being the cumsum of all the values in X for that date. - a 'daily cumsum'. Thanks, Mark TStoDate = function (TSDate) { X = strptime(TSDate + 19e6L, "%Y%m%d")
2011 Feb 25
6
preventing repeat in "paste"
Hello! s<-"start"; e<-"end" middle<-as.character(c(1,2,3)) I would like to get the following result: "start 123 end" or "start 1 2 3 end" or "start 1,2,3 end" How can I avoide this (undesired) result: paste(s,middle,e,sep=" ") Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com
2010 Oct 01
3
Suppressing printing in the function
Hello! I wrote a function that returns a data frame. Nowhere in the function do I say print(my.data.frame), but when I run the function - the data frame is printed on the console. Is there any way to suppress it? Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com
2009 Oct 13
4
replacing period with a space
Dear R-ers! I have x as a variable in a data frame x. x<-data.frame(x=c("aa.bb","cc.dd.ee")) x$x<-as.character(x$x) x I am sorry for such a simple question - but how can I replace all periods in x$x with spaces? sub('.', ' ', x$x) - removes all letters to the left of each period... Thanks a lot for your advice! -- Dimitri Liakhovitski Ninah.com
2020 Mar 10
2
Fwd: Windows upssched does not work
Hi, I have problem with upssched on windows. Upssched is not executed. I have 2 scripts, 1 for notification in upsmon and second for scheduling in upssched. Monitoring is working fine, script write to log. I'm using binary windows installer 2.6.5-6 from NUT. Here are my configs: --- nut.conf MODE=netclient --- upsmon.conf MONITOR ups_1000 at 192.168.3.95 1 <user> <password> slave
2011 Mar 11
2
insertion of a row between individuals
Can someone help with a fairly simple task? I have a data set where I would like to insert a 0 time event between individuals: what I have: VAR DATE TIME CONC COVAR 1 NOV2 0.25 10 group1 1 NOV2 0.5 20 group1 1 NOV2 1 5 group1 1 NOV2 2 1 group1 1 NOV2 3 0.1 group1 2 NOV2 0.25 10
2010 Mar 04
4
Analogue to SPSS regression commands ENTER and REMOVE in R?
I am not sure if this question has been asked before - but is there a procedure in R (in lm or glm?) that is equivalent to ENTER and REMOVE regression commands in SPSS? Thanks a lot! -- Dimitri Liakhovitski Ninah.com Dimitri.Liakhovitski at ninah.com
2011 Aug 24
2
data manipulation and summaries with few million rows
I have a data set with about 6 million rows and 50 columns. It is a mixture of dates, factors, and numerics. What I am trying to accomplish can be seen with the following simplified data, which is given as dput output below. > head(myData) mydate gender mygroup id 1 2012-03-25 F A 1 2 2005-05-23 F B 2 3 2005-09-08 F B 2 4 2005-12-07 F B 2
2010 Oct 25
3
finding the year of a date
I know that I can use as.yearmon in the package "zoo" to find the year and the month of a date. I can use as. yearqtr to find the year and the quarter. But how can one find just the year of a date? Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com