r shape of dataframe code example Example: R dataframe shape df = data.frame(col1=c(1,2,3), col2=c(4,5,6)) dim(df) # Output: [1] 3 2