I have the following file:
Apple Pear
Apple Raspberry
Raspberry Pear
Lemon Pear
Lime Plum
Pineapple Grape
As output, I'd like a list of chains of fruits--on each line, associate any two fruits that ever appear together on a line, e.g., one line would be Pineapple, Grape because each appears once and only once, together.
I'm looking for the following output:
Apple Pear Raspberry Lemon
Lime Plum
Pineapple Grape
Does anybody have any suggestions?
Thank you!
It seems you're basically after creating a network of the fruits, so you're best off using the network package (which I just learned about in answering this question, so it's probably got all sorts of functionality I don't understand yet).
To read that text, use read.table(text=...):
x<-read.table(text="Apple Pear
Apple Raspberry
Raspberry Pear
Lemon Pear
Lime Plum
Pineapple Grape")
Then simply create a network object from x:
library(network)
net<-network(x)
For example, you can plot the network:
plot(net)
Haven't quite figured out how to get your exact desired output, but you can see in the plot above that we've achieved the association you wanted. Not sure your end goal, but check out some tutorials for network.
Related
I want to get the data that you wear the Apple watch on your left-hand or right-hand.
In addition, I hope to know the way to get the data that your Digital Crown is on the right or left of the Apple watch.
However, I cannot find the way to do it.
Please teach me how to if you know the way.
Thank you in advance.
WKInterfaceDevice.current().wristLocation
https://developer.apple.com/documentation/watchkit/wkinterfacedevice/1650810-wristlocation
WKInterfaceDevice.current().crownOrientation
https://developer.apple.com/documentation/watchkit/wkinterfacedevice/1650805-crownorientation
I’m in a situation like this:
"Cream Corner" by Lynn
An ice cream cone is a kind of edible thing.
An ice cream cone has a number called scoop count.
Rule for printing the name of an ice cream cone:
say "[the scoop count in words]-scoop ice cream cone".
The Cream Corner is a room.
The player holds an ice cream cone with scoop count 3.
Now I want > eat three-scoop to work. I can do this:
Understand "one-scoop" as an ice cream cone
when the scoop count of the item described is 1.
Understand "two-scoop" as an ice cream cone
when the scoop count of the item described is 2.
Understand "three-scoop" as an ice cream cone
when the scoop count of the item described is 3.
[ ... ]
But of course, ideally, I’d like to write a rule like this:
Understand "[number]-scoop" as an ice cream cone
when the scoop count of the item described is the number understood.
However, the Inform documentation specifies that this is impossible:
So we cannot safely say "when the noun is the fir cone", for instance, or refer to things like "the number understood". (We aren't done understanding yet.) If we want more sophisticated handling of such cases, we need to write checking rules and so on in the usual way.
All the same, it isn’t clear to me how to replace such a rule with a checking rule “in the usual way”. How do I use checking rules to make [number]-scoop in the player’s command be interpreted as “an ice cream cone with that many scoops”?
I'm not quite sure what the documentation is implying we do there, but I can help solve the base problem. A partial solution is these two lines:
Understand the scoop count property as referring to an ice cream cone.
Understand "scoop" as an ice cream cone.
This allows the player to type things like three scoop cone or three ice cream cone, and have the three-scoop cone be understood.
This is only a partial solution, as we don't include the dash*, so something like take three-scoop cone wouldn't be understood correctly. The obvious way of solving this problem is by replacing the dash entirely before the command is read, something like this:
[Nonfunctional solution!]
After reading a command:
If the player's command includes "-scoop":
replace the matched text with " scoop";
This doesn't seem to work however, as the above rule matches only whole words--i.e., three -scoop, but not three-scoop. Attempting to do the same with only replacing - fails similarly.
*You can also argue that three ice cream cone shouldn't be a valid match.
I'd like to have two columns on a slide in R Presentation, with the column-split after a full-width paragraph, but I can only get this:
I want the "Ice Cream" section to take up the full width of the slide, and the "Ben's Ice Cream Palace" and "Jerry's Ice Cream Castle" sections to appear next to each other below that. Changing the level of the section headings doesn't seem to have any effect. Is there a way to do this?
Troubleshooting
========================================================
## Ice Cream
My town has two ice-cream parlours, Ben's Ice Cream Palace and Jerry's Ice Cream Castle. It would be nice to show the two establishments' flavours side-by-side so that we could compare them easily when deciding where to go buy ice cream on a hot sunny day.
### Ben's Ice Cream Palace
- Chocolate
- Vanilla
- Neopolitan
- Rum Raisin
- Butter Pecan
- Mint Chocolate Chip
***
### Jerry's Ice Cream Castle
- Chocolate
- Vanilla
- Strawberry
- Chunky Monkey
- Chocolate Chip Cookie Dough
Working on producing a customizable bag and need to combine individual components to make full bag.
The bag following 4 components:
Body
Handle
Metal
Zip
Each bag has set of leathers or colored metal or colored cloth which can be used.
Example:
"Body" has the following leathers as applicable options...
Leather01, Leather02, Leather03, Leather04, Leather05
"Handle" has the following leathers as applicable options...
Leather01, Leather02, Leather03, Leather04, Leather05
"Metal" has the following colored metals as options...
Gold and Silver
"Zip" has the following colored cloth options...
Beige and Black
Considering the above, how do I get the permutations and combinations of making the bag.
Use cases:
A bag can built with the following:
body: Leather01
Handle: Leather01
Metal: Gold
Zip: Beige
Also, I am looking for half built bags as well, like...
body: Leather01
Or
body: Leather01
Zip: Beige
Looking for a way to calculate the possible combinations.
I have a df that looks like:
selection.body selection.hair selection.eyes selection.breasts selection.butt selection.skin
normal blonde other large medium tanned
normal blonde other xl medium tanned
normal blonde other large medium tanned
chubby blonde blue xl large tanned
slim blonde other medium small white
Let's imagine this dataset as the answer to a survey:
each row represents the choice of a single responder, selecting his preference from a closed set of preferences.
What I did already is checking the frequencies of each choice but I want to move forward with that.
My goal is to:
identify the most common combinations of choices.
group the users on the basis of this combination.
the correlations between the choices
Thanks for your hints.
Finding the most common combinations isn't clustering, but frequent itemset mining.
Have you tried apriori?