I have got a function :
aggreg <- function(fileName, param){
contents <- read.csv(fileName, header=T)
#print(contents) #This displays all contents
print(contents$param) #gives NULL
}
> aggreg("test.csv","Close.Price")
> NULL
Please guide further. Thanks:)
Method 1 : Using paste() method In order to modify the column names, the paste function in R can be used. The paste() method, can be used for the concatenation of string vectors together to form a larger string or sentence. The string vector arguments are joined using the separator specified in the paste function.
In R, you can pass a function as an argument. You can also pass function code to an argument. Then, you can assign the complete code of a function to a new object.
To pick out single or multiple columns use the select() function. The select() function expects a dataframe as it's first input ('argument', in R language), followed by the names of the columns you want to extract with a comma between each name.
Because, usually R dataframes do not allow exact same names (when you create them using data. frame() ). Which means dataframes should not have the same column names.
you need to use another way of accessing the columns in the dataframe than via $
. There are two other ways:
1.
print(content[[param]])
2.
print(content[,param])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With