r – Delete duplicate rows and sum the corresponding values ​​of the last column in a data frame

If we want to remove the duplicates from a data frame dfwe just have to write df(!duplicated(df),) and duplicates are removed from it. I have the following data frame:

df <- data.frame(from = c("z","y","z","w","y"), to=c("x","w","x","z","w"), weight=c(2,1,3,5,6))

I want to get something else. in the df(,1:2), the first and third rows are the same between them and I want to: 1) delete one of them; 2) add up the corresponding weight values. For example, In this example, the expected result is:

   from to weight
     z  x      5
     y  w      7
     w  z      5

Anyway if I use:

which(duplicated(df2) | duplicated(df2(nrow(df2):1, ))(nrow(df2):1))

I get

(1) 1 2 3 5

which does not allow me to get the desired result (e.g. 1 and 3 are equal between them, 2 and 5 are equal between them, but this information is not included in the latter result).

How to delete partitions – ask differently

I recently bought a used 2017 iMac 27 ". It has a 2TB hard drive and the type that previously ran Windows on Bootcamp. I tried to merge the partitions with the Disk Utility app, but no luck. Me I keep getting an error message there is corruption. I want to have all 2 TB for my MacOS. Since I am not familiar with the terminal, I don’t want to delete anything important.

Thank you very much

Enter the image description here

hp – Install Ubuntu 18.04 on UEFI and delete Windows 8


HP 19-2113w ALL IN ONE PC With Windows 8 (sticker). I think they have upgraded to Windows 10.

Just reset to factory settings (which have been restored to Windows 8). Seems to be working properly.

I want to install Ubuntu 18.04 but can't get the PC to see a USB drive or Ubuntu installation DVD. I think it has something to do with Secure Boot. If you try to restart the PC, you have to deactivate the safe start (what I do in the BIOS) and activate the legacy start (cannot because it is grayed out). You can only enable legacy startup if you disable the Safe Start menu says it is disabled.

I haven't used Windows since XP and I'm not sure what it will do. If I could just start my USB stick and erase the hard drive and install Ubuntu, everything would be fine. Any ideas would be welcome.

I have another 500 GB hard drive. If I plug it into my Ubuntu computer, install Ubuntu 18.04 and then replace the hard drives, the PC boots on Ubuntu without screwing with Secure Boot

mysql – delete a row with 2 variables with limit from the table

I am developing a PHP script that stores the user's session in a database.

If a user logs out of the server, remove only one line (since the same user can log in more than once).

When the server restarts, remove all user sessions from this server with the same IP address.

  • Table name:
  • Column in table:
    • ID (int, autoincrement, 11)
    • Serverip (Mediumint)
    • User ID (text)

Run on:

mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

The query runs correctly but does not delete anything.

    elseif ($_GET('status') == "logout"){
        $sql = "DELETE FROM totalconcurrent WHERE (serverip,userid) IN ((INET_ATON('".get_server_ip()."'),'".$_GET('id')."')) LIMIT 1;";
        if ($conn->query($sql) === TRUE) {
            echo "1 Session of ".$_GET('id')." removed";
        } else {
            echo "Error: " . $sql . "
" . $conn->error; } }

The query runs correctly but does not delete anything.

    elseif ($_GET('status') == "reboot"){
        $sql = "DELETE FROM totalconcurrent WHERE serverip IN ((INET_ATON('".get_server_ip()."')));";

        if ($conn->query($sql) === TRUE) {
            echo "Server rebooted, removed all session stored in this server";
        } else {
            echo "Error: " . $sql . "
" . $conn->error; } }

I have tried many times and many types of queries to do this without finding the right way to do it.

What questions do I need?