R language data conversion 2

The transpose of the data frame The
transpose t() function of row and column, transpose a row separately, use the rev function to be used for vector or data frame
eg
Insert picture description here

Modify the value data box,
eg the women dataset transposition centimeters inches tall and
Insert picture description here
more above if you need to modify the value of the method is not efficient, you can use transfor function can modify the value column of data in any box
Insert picture description here
if you do not modify the original For data, you can define another
Insert picture description here
function related to sorting in R:
sort : sort the vector, the return value is the result vector after sorting, the default value is from small to large, and the string is in alphabetical order with the rev function in the reverse order Sort
order: Sort a vector and the returned value is the position of the vector. You can sort the data frame indirectly by index. Add-in front of the column you want to sort in the order.
Rank: a function to find the rank, the return value is The ranking of the corresponding elements of the vector

The apply series of functions can be applied to data types such as matrix array data frames. It is more convenient:
group calculation tapply (parameter: vector return value: vector) apply (parameter: list, data.frame, array)
multi-parameter calculation mapply (parameter: vector, Unlimited return value: vector, matrix)
loop iteration lapply (parameter: list, data.frame return value: list)
environment space traversal eapply (parameter: environment return value: list)

Data centralization and standardization:
Data centralization refers to the data in the data set minus the mean of the data set.
Data standardization refers to dividing by the standard deviation of the data set after centralization, that is, the data in the data set minus the mean of the data set and then divided by the standard deviation of the data set.
mean mean function sd standard deviation function
can also directly use the function scale function, the parameter center=T for centralization processing scale=T for standardization processing
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_46445293/article/details/105468015