Google News
R Programing Interview Questions
RDA file format : These are the R objects that are used to attaching and loading files in R.

.Rfiles : These are the files that are created inside the R editor by the dump function.

.txt files : The .txt files are used to store datasets. R uses theread.table() and write.table() function.

.csv files : The comma-separated values files are common data files.
Repeat loop executes a sequence of statements multiple times. It doesn’t put the condition at the same place where we put the keyword repeat.
Example :
>name <-c(“Peeter”,”Danny”)
>temp <-5
> repeat {
temp <- temp +2
if(temp >11){
This would return the name vector four times. First, it prints the name and increases the temperature to 7 and so on.
Decision making in R is performed in the same way as in other languages. The three main decision-making statements contain:
* If statement
* If.else statement
* Switch statement
outer join - merge (x= df1, y=df2, by= “id”, all= TRUE)
left join - merge (x= df1, y= df2, by = “id”, all.x = TRUE)
right join - merge (x= df1, y= df2, by = “id”, all.y = TRUE)
inner join - merge (x= df1, y= df2, by = “id”)
cross join - merge (x= df1, y= df2, by = NULL)
It is used to get aggregate after melt(). So, now we have data arranged in some order, if we want to aggregate the columns with similar company_name and age, then we should use the cast() function.
Example :
Casted_data_set <- cast(new_data_set, company_name+age ~ variable, sum)
The function gives the aggregate salary and number of children with the same company and age.
Scatterplot is a graph which shows many points plotted in the Cartesian plane. Each point holds two values that are present on the x-axis and y-axis. The simple scatterplot is plotted using plot() function.
The syntax for scatterplot is :


x is the data set whose values are the horizontal coordinates
y is the data set whose values are the vertical coordinates
main is the tile in the graph
xlab and ylab is the label in the horizontal and vertical axis
xlim and ylim are the limits of values of x and y used in the plotting
axes indicate whether both axes should be there on the plot.
plot(x = input$wt,y = input$mpg,
xlab = “Weight”,
ylab = “Mileage”,
xlim = c(2.5,5)
ylim = c(15,30)
main = “Weight vs Mileage”
The sink() function defines the direction of the output.
#direct output to a file
sink(“myfile”, append = FALSE, split = FALSE)
#return output to the terminal sink()
The append option controls whether output overwrites or adds to a file. The split option determines if the output is also sent to the screen as the output file.