Hi,
I met another practice about R for beginner like me. How could I get the value( in "dat1" dataframe) corresponding id number(in "id" dataframe) other than the missing value? Also, is it possible to output the value(in "dat1" dataframe, except NA)coordinates? We may output one dataframe that contains them?
Thank you for help in advance!
Hi,@DavoWW,
My problem has been almost solved. I am very appreciative of your effort and time on this matter. Would you mind if I ask other question about this matter? I am sorry to disturb you.
My first question is about the code: What's the meaning of "names(. )[1]", assignment value?And what 's "4" in "lapply(c("1","2","3","4"), subset_section)" represent?it seems that "id" and "dat1" dataframe are both 3rows, 3cols.
Second is that if the data has changed: there are many columns and rows. And the column names and rownames seems not regular. Just we still input "1", "2",........"17","18","19" in final step? Or make some adjustment?
I have great respect for the fruits of your labour and thank you for your help. I only have these questions because I have just started learning R and some knowledge is not well understood by myself. I put example code to show my thought now.
Hi @Comede_way,
This code parse_number(names(.)[1])) simply extracts only the numeric part of the first column name.
Using lapply(c("1","2","3","4"), subset_section) just shows you that if that subset doesn't exist in the data (i.e. subset "4") then the function fails (as expected).
Larger numbers of subsets should work provided that the columns to be paired can be "matched" by having the same number as part of the column names. If the number is not present (as in your latest example) then column indexing may be needed. Although, in your new example the names of the two dataframes could be matched by making them all the same case.
Thank you very much. So, as you could see in my new example, there are 19 rows. After i making the name of two dataframe all the case, in the last step, lapply(), i need input “1”, “2”,“3”,……“19”?And if there are more than 100rows, still one by one? or maybe use a small function?