[R] Data Frame (Very Simple Problem)

Rui Barradas ruipbarradas at sapo.pt
Thu Sep 20 00:41:15 CEST 2012


Hello,

Your code is reproducible and completely explains the issue, thanks.
First I had the impression of a well organized question.
Then I've read point 4.

4. The sequence 1:1 starts and ends at 1. You don't need b[1:1, 1:1], 
b[1, 1] will do.

Then you assign a different value to 'b'. This time it's a vector, not a 
data.frame.
The ifelse corrected is

# 'b' is now 1-dim
ifelse(b[1] < Sys.time()+5*60, rnorm(1,0,5), Sys.sleep)

(Why the '*' and the double quotes?)

Then I've realized that you had restarted the counting, but starting 
with point 2.

Hope this helps,

Rui Barradas

Em 19-09-2012 22:54, Bhupendrasinh Thakre escreveu:
> Hi List Members,
>
> This is a very stupid problem but I am not able to know what the solution
> can be.
> I am trying to run a query like below
>
> *Program Flow :*
>
> 1. a <- data.frame(table( cut( Sys.time() + seq(0,82800,3600), "60 mins")
> ))      # It generates the 60 minute intervals. Thanks David
> 2. b <- data.frame(a$Var1)
>                             # To extract only First Column i.e. Var1
> 3. class(b)
>                                   # checking class
> 4. b[1:1,1:1]
>                                  # Trying to access the first row and the
> problem starts.
> 2. b <-  Sys.time()+ 5*60
>                           # 5 minute interval increase
> 3. ifelse(b[1:1,1:1] *"<" *Sys.time()+5*60,rnorm(1,0,5),Sys.sleep)
>
> Error: unexpected string constant in "ifelse(b[2:2,1:1] "<"
>
> My only aim is to run "ifelse" for checking whether the program is running
> or not.Please help
>
> *Data :*
>
> a <- structure(list(Var1 = structure(1:24, .Label = c("2012-09-19
> 16:40:00",
> "2012-09-19 17:40:00", "2012-09-19 18:40:00", "2012-09-19 19:40:00",
> "2012-09-19 20:40:00", "2012-09-19 21:40:00", "2012-09-19 22:40:00",
> "2012-09-19 23:40:00", "2012-09-20 00:40:00", "2012-09-20 01:40:00",
> "2012-09-20 02:40:00", "2012-09-20 03:40:00", "2012-09-20 04:40:00",
> "2012-09-20 05:40:00", "2012-09-20 06:40:00", "2012-09-20 07:40:00",
> "2012-09-20 08:40:00", "2012-09-20 09:40:00", "2012-09-20 10:40:00",
> "2012-09-20 11:40:00", "2012-09-20 12:40:00", "2012-09-20 13:40:00",
> "2012-09-20 14:40:00", "2012-09-20 15:40:00"), class = "factor"),
>      Freq = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
>      1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("Var1",
> "Freq"), row.names = c(NA, -24L), class = "data.frame")
>
> *Session Info *
>
> R version 2.15.1 (2012-06-22)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United States.1252
> [2] LC_CTYPE=English_United States.1252
> [3] LC_MONETARY=English_United States.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats     graphics  grDevices datasets  utils
> [6] methods   base
>
> other attached packages:
> [1] rcom_2.2-5     rscproxy_2.0-5
>
> loaded via a namespace (and not attached):
> [1] tools_2.15.1
>
> Best Regards,
>
>
> Bhupendrasinh Thakre
>
> *Disclaimer :*
>
> The information contained in this communication is confi...{{dropped:11}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list