Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)

I know that we can extract the data from a dataframe on a [x,y] coordinate basis, like as follows:

df[[144]][[1]]

And we can also extract the data from a dataframe on a column name basis, like as follows:

df$column.name[[row.num]] or df[["column.name"]][[row.num]]

I just wanted to ask that is there a way for extracting the data from a dataframe on a column name And also on a row name basis? Something like:

df[["column.name"]][["row.name"]] 

1 Answer

0 votes
by (107k points)

It is very simple to perform in R. I will show you how you can do that. I am using the inbuilt dataset that the RStudio provides that is mtcars.csv:

mtcars['Valiant', 'mpg']

#[1] 18.1

The by default syntax is:

df['row.name', 'column.name'] 

If you are a beginner and want to know more about R programming then do check out this blog which will help you to understand basic syntax that are used in RStudio. 

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...