I have a dataframe that I'm trying to loop through, printing out the values from each dataframe... I'm new to R and am more familiar with python and javascript so I'm gonna pseudo-code what I'm trying to say here:
df <- read.table(text="
a b c d e f g
1 5 6 7 3 4 7
3 2 8 4 1 9 4
6 5 2 5 4 6 1
",header=TRUE,stringsAsFactors = FALSE)
my javascript mentality...(I only want to select from columns 4 and on):
for (i = 3; i < df.length; i++) {
console.log(i)
}
and it would return to me
d e f g
7 3 4 7
4 1 9 4
5 4 6 1
to understand this better, I'm making a dashboard where when I hover over certain data points only values from certain columns are being displayed in a tooltip, which is why i still need to keep the original dataframe without shortening it, yet write an algorithm that will return values from specific columns in the dataframe just for the tooltip