List/Grid

Tag Archives: splus R

Pass parameters in perl script and use it for R script

Pass parameters in perl script and use it for R script

To run a R script from a perl script, this is what you need to do: system(“R CMD BATCH –r_script_name.r r_script_name.out”); //This will execute r_script_name.r from this perl script. Now… Read more »

Get current date in Splus/R

Get current date in Splus/R

Today i will discuss, how to get current date in splus/r and format it to your needs. To get current date do: > today < - Sys.Date() //Display current date... Read more »

Select non consecutive rows from data frame – R

Select non consecutive rows from data frame – R

We can easily select consecutive rows from a data frame using dataframe[n1:n2,], where n1 and n2 are the starting and end rows, however it is bit tricky to select non… Read more »

Create empty data frame with column names – R

Create empty data frame with column names – R

It is easy to create a empty data frame, but some how tricky to create a empty data frame with columns defined. To create a simple empty data frame you… Read more »

Passing parameters to a R file (.r file)

Passing parameters to a R file (.r file)

While dealing with a R script, i came across a issue where i needed to send parameters to a R script and use inside my script. With perl its very… Read more »

Unexpected ELSE error – R

Unexpected ELSE error – R

While writing a R code i came across a error: Error in source(“test.r”) : test.r:69:1: unexpected ‘else’ 68: } 69: else ^ My code was something like this: if (… Read more »

Select rows from a data frame on condition – R

Select rows from a data frame on condition – R

Lets say you have a data frame(ds), Here is how top 8 rows look like: > ds[1:8,] agr ppe pe score 1063 3 5.46666 5.61640 1.0000000 1096 7 4.20765 4.83111… Read more »

Rearrange columns of a data frame – R

Here i will explain how can we rearrange the columns of a data frame and also how can we rename columns. I will use the data frame that i used… Read more »

Add columns in a data frame – R

If you have a data frame and you wish to add a column then here is how you should do it: Lets say your data frame is > data date_… Read more »

Delete rows from a data frame with NA’s

Here is how to delete all the rows from a dataframe where any of the column value had the value NA. For Example, this is my data frame: > data… Read more »