similar to: for loop if else conditional

Displaying 20 results from an estimated 6000 matches similar to: "for loop if else conditional"

2007 Oct 15
1
String concatenation, File Path Handling to pass to download.file( ) [backslash in DOS paths]
Gabor, Thanks much. Your solution is elegant. My overall scheme is to take present date, and check whether it is a weekend, if not, then create a string based on the date, to concatenate into a url link for download.file( ). The files I need to download have a part which is in the format: mmddyy. I am working to make myself a system to connect to exchanges, and download end of day files from
2007 Oct 16
1
try / tryCatch for download.file( ) within a for loop when URL does not exist
I am trying to download a bunch of files from a server, for which I am using download.file( ) within a for loop. The script is working fine except until download.file hits a URL which has no file, at which point it exits. I want to change this behavior to simple log the failure and maintain state within the for loop and iterate to next. I read about try / tryCatch but am having trouble
2008 Jan 10
5
diff in a dataframe
I have a dataframe say: date price_g price_s 0.34 0.56 0.36 0.76 . . . . . . and so on. say, 1000 rows. Is it possible to add two columns to this dataframe, by computing say diff(log(price_g) and diff(log(price_s)) ? The elements in the first row of these columns cannot be computed, but
2011 May 14
2
changing the day of the week in dates format
Dear all, I have a question related to the POSIXlt function in R. I have a set of dates and times, for exmaple: startx <- as.POSIXct("2011-01-01 00:00:00") finx <- as.POSIXct("2011-12-31 00:00:00") daysx<- seq(startx, finx, by="24 hours") I want to change the dates of all the days falling on a Saturday to the next working day (i.e. Monday). So I
2008 Apr 04
1
RODBC / odbcConnectExcel Issue
Can someone throw light on the following problem I am having with RODBC? There's an Excel file I am trying to read from, it has one sheet named 'nameclass'. Thanks in anticipation. Vishal Belsare > library(RODBC) > con = odbcConnectExcel(file.choose()) > tbls <- sqlTables(con) > tbls TABLE_CAT TABLE_SCHEM TABLE_NAME TABLE_TYPE REMARKS 1
2009 Mar 26
1
ApEn (Approximate Entropy), Total Corr, Information Interaction
Is there any existing implementation in R/S of : 1] Pincus & Kalman's approximate entropy (ApEn) measure 2] Total Correlation / Multiinformation 3] Information Interaction A search doesn't quite reveal anything, but I'd be keen to not reinvent in case someone has worked on it. Many thanks in anticipation. Best, Vishal Belsare
2008 Jan 14
1
zoo object
I have an ordered series of 3 month t-bill rates (annual). I transform this to a daily series, however, the observations are constructed only from the dates on which the t-bills were issued, which is every week. So now I have ordered observations of the daily 'risk-free rate' for one day every week. I want to expand this zoo object to give a value for every day, and to do so, copy the
2008 May 25
1
n Realizations of a Stochastic Process assigned to dynamically generated variable names?
I am interested in creating multiple (say 1000) time series, from a given stochastic process, of length 250. I want to refer to each realization with its own variable name, of the format say, tsn, where n is the n'th simulation. i.e. ts1, ts2, ts3, ts4, .... , ts1000 The way I am thinking of doing this is placing the following code within another loop, and the 'tsn' assignment should
2013 Oct 04
2
Possible POSIXlt / wday glitch & bugs.r-project.org status
Wanted to raise two questions: 1. Is bugs.r-project.org down? I haven't been able to reach it for two or three days: ``` ping bugs.r-project.org PING rbugs.research.att.com (207.140.168.137): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2 Request timeout for icmp_seq 3 Request timeout for icmp_seq 4 Request timeout for icmp_seq 5
2008 May 31
1
Representing 'Date' as 'Year - Quarter'
I have financial data on a a set of firms, with a quarterly period (fundamental data). The data spans 10 years, and four quarters per year. The present file (.csv) reads the Date columns as "200706" for the second quarter of 2007; "199809" for the third quarter of 1997. Is there a way I can convert it to something like "2007 Q2", "1998 Q3"? I am aware of
2008 Dec 11
3
getting ISO week
Hi all, Is there a simple function already implemented for getting the ISO weeks of a Date object? I couldn't find one, and so wrote my own function to do it, but would appreciate a pointer to the "default" way. If a function is not yet implemented, could the code below be of interest to submit to CRAN? Best Regards, Gustaf --------------------
2005 Oct 06
2
isdst
Can someone, please, explain the difference is results below (notice the isdst value) > unlist(as.POSIXlt('2005-7-1')) sec min hour mday mon year wday yday isdst 0 0 0 1 6 105 5 181 1 > unlist(as.POSIXlt(as.Date('2005-7-1'))) sec min hour mday mon year wday yday isdst 0 0 0 1 6 105 5 181 0
2020 Oct 23
2
The presence/absence of `zone` in POSIXlt depending on time zone as a cause of possible inconsistences?
Dear all, I have just detected what seems a minor inconsistence with data types. If one unlists a POSIXlt time with GMT zone gets a numeric vector, since the POSIXlt list has no `zone` element, while if one unlists a POSIXlt time with a non GMT zone (also non specifying tz if the Sys.timezone is not GMT) gets a character vector due to including the `zone` element. > x <-
2020 Oct 01
3
timezone tests and R-devel
The return value of Sys.time() today with a timezone of US/Eastern is unchanged between 4.0.3-patched and devel, but on devel the following test fails all.equal(x, as.POSIXlt(x)) with x = Sys.time() This means that devel does not complete make tests (failure on tests/reg-tests-2.R) It is entirely possible that it is an error on my end, I use export TZ="US/Eastern" but I have been
2007 Dec 11
3
Wrong length of POSIXt vectors (PR#10507)
Full_Name: Petr Simecek Version: 2.5.1, 2.6.1 OS: Windows XP Submission from: (NULL) (195.113.231.2) Several times I have experienced that a length of a POSIXt vector has not been computed right. Example: tv<-structure(list(sec = c(50, 0, 55, 12, 2, 0, 37, NA, 17, 3, 31 ), min = c(1L, 10L, 11L, 15L, 16L, 18L, 18L, NA, 20L, 22L, 22L ), hour = c(12L, 12L, 12L, 12L, 12L, 12L, 12L, NA, 12L,
2002 Oct 17
4
Posix Problem, difftime
I am having a series of problems using date time data that has been converted into a POSIXt and POSIXlt classes. I have hourly time series data from 1900 that has been converted from text data. I assume most of my problems come from a mis-underdanding of the POSIX class. My matrix named (aa) for this year is approx 8700 by 4. When I try to calculate the length of posit column ( which is the
2010 Dec 27
1
Can't merge on datetime?
x = structure(list(date = structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), hour = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(1L, 2L, 3L, 4L, 5L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 22L, 23L, 24L,
2003 Aug 13
1
Problems with addition in big POSIX dates
Have you noticed any problems with big dates (>=1/1/2040) in R? Here is the bit of code that I'm having trouble with: > test.date <- strptime("1/1/2040",format="%m/%d/%Y") > > unlist(test.date) sec min hour mday mon year wday yday isdst 0 0 0 1 0 140 0 0 0 > > date.plus.one <- as.POSIXct(test.date) +
2020 Oct 02
2
timezone tests and R-devel
Yes, the potential issue I see is that make check fails when I explicitly set TZ. However, I set it to be the same as what the system reports when I login. Details: The system (RHEL) I am working on has $ strings /etc/localtime | tail -n 1 EST5EDT,M3.2.0,M11.1.0 $ date +%Z EDT $ echo $TZ US/Eastern On Fri, Oct 2, 2020 at 9:48 AM Sebastian Meyer <seb.meyer at fau.de> wrote: > Thank
2012 Apr 22
2
difficulty in Formatting time series data
Dear R-Gurus I have a data frame (from CSV file) which has its first column called Date. The Date is in the format mm/dd/yyyy. I was trying to get the weekday for these dates and I tried using wday() and day.of.week() functions and both of them gave me precisely the wrong answers. I think the issue lies in the proper formatting of dates. The class of this column is a factor class and hence I