I have several input data files in my working dir, I would like to read all input data and find one MAX value of all values stored in those files. Here is the code:
##. identify files to read in
filesToProcess <- (Sys.glob("*.csv"))
filesToProcess
## Read all file and store in a list
listOfFiles <- lapply(filesToProcess, function(x) read.table(x, header = FALSE))
max(listOfFiles) #-- error
Can anyone give me suggestion how to get the MAX? Thanks a lot.
Pandas DataFrame max() Method The max() method returns a Series with the maximum value of each column. By specifying the column axis ( axis='columns' ), the max() method searches column-wise and returns the maximum value for each row.
How to get the max value in a list in R? First, use the unlist() function to convert the list into a vector, and then use the max() function to get the maximum value.
Select first N Rows from a Dataframe using head() function In Python's Pandas module, the Dataframe class provides a head() function to fetch top rows from a Dataframe i.e. It returns the first n rows from a dataframe. If n is not provided then default value is 5.
In Python, there is a built-in function max() you can use to find the largest number in a list. To use it, call the max() on a list of numbers. It then returns the greatest number in that list.
The max
operation is not defined for a list of data.frame
's, only for vectors of numbers. To get the max value of all values, you can simply use:
max(unlist(listOfFiles))
where unlist
recursively reduces the list of data.frame
's to one vector of numbers.
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